#define CMD_FILE_PRG   1
#define CMD_FILE_C     2
#define CMD_FILE_HBC   3
#define CMD_FLAG_PRG   4
#define CMD_FLAG_C     5
#define CMD_FLAG_LINK  6
#define CMD_NAME       7
#define CMD_PATH_INC   8
#define CMD_PATH_LIB   9
#define CMD_FILE_LIB   10
#define CMD_WORKDIR    11
#define CMD_EXTRA      12
#define CMD_INVALID    13

FUNCTION Main( ... )

   LOCAL aCompile := Array( CMD_INVALID ), oElement, aParamType := Array( CMD_INVALID )

   SetMode( 25, 80 )
   FOR EACH oElement IN aCompile
      oElement := {}
   NEXT
   aParamType[ CMD_FILE_PRG ]  := "file prg"
   aParamType[ CMD_FILE_C ]    := "File C"
   aParamType[ CMD_FILE_HBC ]  := "file hbc"
   aParamType[ CMD_FLAG_PRG ]  := "flag prg"
   aParamType[ CMD_FLAG_C ]    := "flag c"
   aParamType[ CMD_FLAG_LINK ] := "flag link"
   aParamType[ CMD_NAME ]      := "project name"
   aParamType[ CMD_PATH_INC ]  := "ch path"
   aParamType[ CMD_PATH_LIB ]  := "lib path"
   aParamType[ CMD_FILE_LIB ]  := "lib files"
   aParamType[ CMD_WORKDIR ]   := "workdir"
   aParamType[ CMD_EXTRA ]     := "extra"
   aParamType[ CMD_INVALID ]   := "invalid"
   FOR EACH oElement IN hb_AParams()
      PRocParam( oElement, aCompile )
   NEXT

   FOR EACH oElement IN aCompile
      IF Len( aCompile[ oElement:__EnumIndex ] ) != 0
         ? aParamType[ oElement:__EnumIndex ] + ": " + Show( aCompile, oElement:__EnumIndex )
      ENDIF
   NEXT
   Inkey(0)

   RETURN NIL

FUNCTION ProcParam( oElement, aCompile )

   LOCAL nType

      nType := CMD_INVALID
      DO CASE
      CASE oElement == "-w0"                 ; nType := CMD_FLAG_PRG
      CASE oElement == "-w1"                 ; nType := CMD_FLAG_PRG
      CASE oElement == "-w2"                 ; nType := CMD_FLAG_PRG
      CASE oElement == "-w3"                 ; nType := CMD_FLAG_PRG
      CASE oElement == "-es0"                ; nType := CMD_FLAG_PRG
      CASE oElement == "-es1"                ; nType := CMD_FLAG_PRG
      CASE oElement == "-es2"                ; nType := CMD_FLAG_PRG
      CASE oElement == "-G0"                 ; nType := CMD_FLAG_C
      CASE Left( oElement, 8 ) == "-workdir" ; nType := CMD_WORKDIR
      CASE Left( oElement, 2 ) == "-I"       ; nType := CMD_PATH_INC
      CASE Left( oElement, 3 ) == "-o"       ; nType := CMD_NAME
      CASE ".hbc" $ oElement                 ; nType := CMD_FILE_HBC
      CASE Right( oElement, 4 ) == ".prg"    ; nType := CMD_FILE_PRG
      CASE Right( oElement, 2 ) == ".c"      ; nType := CMD_FILE_C
      CASE Left( oElement, 2 ) == "-L"       ; nType := CMD_PATH_LIB
      CASE Left( oELement, 2 ) == "-l"       ; nType := CMD_FILE_LIB
      CASE oElement == "-inc"                ; nType := CMD_EXTRA
      CASE oElement == "-warn=yes"           ; nType := CMD_EXTRA
      CASE oElement == "-compr"              ; nType := CMD_EXTRA
      CASE oElement == "-strip"              ; nType := CMD_EXTRA
      CASE "-hbx" $ oElement                 ; nType := CMD_EXTRA
      CASE oElement == "-hblib"              ; nType := CMD_EXTRA
      ENDCASE
      AAdd( aCompile[ nType ], oElement )

   RETURN NIL

FUNCTION TrocaMacro( cText )

   LOCAL oElement
   LOCAL aToFrom := { ;
      { "${hb_install_prefix}", "d:\harbour" }, ;
      { "${hb_plat}", "win" }, ;
      { "${hb_comp}", "mingw" }, ;
      { "${hb_name}", "main" } }
   FOR EACH oElement IN aToFrom
      oElement := StrTran( cText, oElement[ 1 ], oElement[ 2 ] )
   NEXT

   RETURN cText

FUNCTION Show( aCompile, nType )

   LOCAL cText := "", oElement

   FOR EACH oElement IN aCompile[ nType ]
      cText += oElement + " "
   NEXT

   RETURN cText
