diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6099fc7be8..cd6db70d16 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,52 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-12 01:14 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * include/hbapi.h + + Added xhb compatibility #define for hb_storclenAdopt() + (equivalent to Harbour's hb_storclen_buffer()) + + * contrib/xhb/hbcompat.ch + + Added xhb IsDirectory() <-> hb_DirExists() translation. + Harbour version works using access(), while xhb version + does a filefind, so Harbour will return a more accurate + result more quickly, but it won't work with wildcards. + + * source/rtl/persist.prg + % Using hb_StrShrink() + + * common.mak + * utils/hbdoc/Makefile + * utils/hbdoc/ffile1.prg + * utils/hbdoc/genasc.prg + * utils/hbdoc/genchm.prg + * utils/hbdoc/genhtm.prg + * utils/hbdoc/genng.prg + * utils/hbdoc/genos2.prg + * utils/hbdoc/genpdf1.prg + * utils/hbdoc/genrtf.prg + * utils/hbdoc/gentrf.prg + * utils/hbdoc/hbdoc.prg + * utils/hbdoc/html.prg + * utils/hbdoc/ng.prg + * utils/hbdoc/os2.prg + * utils/hbdoc/rtf.prg + + utils/hbdoc/teeasc.prg + + Synced with xhb. + ; Someone who uses this tool, pls test. + + * common.mak + * utils/hbmake/Makefile + * utils/hbmake/ft_funcs.prg + * utils/hbmake/hbmake.prg + * utils/hbmake/hbmutils.prg + * utils/hbmake/pickarry.prg + * utils/hbmake/radios.prg + + utils/hbmake/readline.c + + utils/hbmake/tmake.prg + + Synced with xhb. + ; Someone who uses this tool, pls test. + 2007-11-11 22:26 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * common.mak * source/rtl/Makefile diff --git a/harbour/common.mak b/harbour/common.mak index 3dee40efdd..2fc99ef66a 100644 --- a/harbour/common.mak +++ b/harbour/common.mak @@ -1007,6 +1007,7 @@ HBDOC_EXE_OBJS = \ $(OBJ_DIR)\genos2$(OBJEXT) \ $(OBJ_DIR)\genrtf$(OBJEXT) \ $(OBJ_DIR)\gentrf$(OBJEXT) \ + $(OBJ_DIR)\teeasc$(OBJEXT) \ $(OBJ_DIR)\html$(OBJEXT) \ $(OBJ_DIR)\ng$(OBJEXT) \ $(OBJ_DIR)\os2$(OBJEXT) \ @@ -1040,6 +1041,8 @@ HBMAKE_EXE_OBJS = \ $(OBJ_DIR)\ffile1$(OBJEXT) \ $(OBJ_DIR)\ft_funcs$(OBJEXT) \ $(OBJ_DIR)\hbmlang$(OBJEXT) \ + $(OBJ_DIR)\readline$(OBJEXT) \ + $(OBJ_DIR)\tmake$(OBJEXT) \ #********************************************************** diff --git a/harbour/contrib/xhb/hbcompat.ch b/harbour/contrib/xhb/hbcompat.ch index 8382f6c0fc..debae87b87 100644 --- a/harbour/contrib/xhb/hbcompat.ch +++ b/harbour/contrib/xhb/hbcompat.ch @@ -69,6 +69,7 @@ #xtranslate hb_adler32([]) => hb_checksum() #xtranslate hb_setLastKey([])=> setLastKey() #xtranslate hb_CStr([]) => CStr() + #xtranslate hb_DirExists() => IsDirectory() #xtranslate hb_HexToNum([]) => HexToNum() #xtranslate hb_NumToHex([]) => NumToHex() @@ -126,6 +127,7 @@ #xtranslate hb_checksum([]) => hb_adler32() #xtranslate setLastKey([]) => hb_setLastKey() #xtranslate CStr([]) => hb_CStr() + #xtranslate IsDirectory() => hb_DirExists() #xtranslate HexToNum([]) => hb_HexToNum() #xtranslate NumToHex([]) => hb_NumToHex() diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index c7333113b6..35ded715cc 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -634,6 +634,7 @@ extern HB_EXPORT void hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns #define hb_retcAdopt( szText ) hb_retc_buffer( (szText) ) #define hb_retclenAdopt( szText, ulLen ) hb_retclen_buffer( (szText), (ulLen) ) #define hb_retcStatic( szText ) hb_retc_const( (szText) ) +#define hb_storclenAdopt hb_storclen_buffer #ifdef HB_API_MACROS diff --git a/harbour/source/rtl/persist.prg b/harbour/source/rtl/persist.prg index 5da9dccd7a..46ce2a2e65 100644 --- a/harbour/source/rtl/persist.prg +++ b/harbour/source/rtl/persist.prg @@ -234,13 +234,13 @@ static function ExtractLine( cText, nFrom ) if nAt > 0 cText := SubStr( cText, nFrom, nAt - nFrom ) if Right( cText, 1 ) == Chr( 13 ) - cText := Left( cText, Len( cText ) - 1 ) + cText := hb_StrShrink( cText, 1 ) endif nFrom := nAt + 1 else cText := SubStr( cText, nFrom ) if Right( cText, 1 ) == Chr( 13 ) - cText := Left( cText, Len( cText ) - 1 ) + cText := hb_StrShrink( cText, 1 ) endif nFrom += Len( cText ) + 1 endif diff --git a/harbour/utils/hbdoc/Makefile b/harbour/utils/hbdoc/Makefile index 64a154e20e..853602de9b 100644 --- a/harbour/utils/hbdoc/Makefile +++ b/harbour/utils/hbdoc/Makefile @@ -18,6 +18,7 @@ PRG_SOURCES=\ genrtf.prg \ genhpc.prg \ genasc.prg \ + teeasc.prg \ html.prg \ ng.prg \ os2.prg \ diff --git a/harbour/utils/hbdoc/ffile1.prg b/harbour/utils/hbdoc/ffile1.prg index 1b70f8785b..68d5ed9608 100644 --- a/harbour/utils/hbdoc/ffile1.prg +++ b/harbour/utils/hbdoc/ffile1.prg @@ -72,8 +72,6 @@ CLASS FileBase FROM FileMan DATA nPosition // This holds the position in the file at DATA lAtBottom // This is a value to show if at bottom of file DATA lAtTop // This is a value to show if at top of file - DATA cCRLF // OS dependant End of Line marker - DATA nCRLFLen // Length of cCRLF METHOD new( cname ) // This is the constructor for the file METHOD FOPEN() // This opens the specified file @@ -104,7 +102,7 @@ ENDCLASS */ METHOD new( cName ) CLASS FileBase - ::super:new() + super:new() // first thing to do is check to see if there is a valid file ::nSkipLength := 1 @@ -112,9 +110,6 @@ METHOD new( cName ) CLASS FileBase ::nCreateMode := 0 // Mode for which to create the file ::cName := cName - - ::cCRLF := HB_OSNewLine() // Set our End of Line marker - ::nCRLFLen := len(::cCRLF) // and its length RETURN ( self ) @@ -365,15 +360,15 @@ METHOD goBottom() CLASS FileBase cBuffer := SPACE( pBUFFER_LENGTH ) FSEEK( Self:nDosHandle, - ( pBUFFER_LENGTH ), 2 ) FREAD( Self:nDosHandle, @cBuffer, pBUFFER_LENGTH ) - IF RIGHT( cBuffer, ::nCRLFLen ) == ::cCRLF // We need to remove this extra one! - cBuffer := LEFT( cBuffer, LEN( cBuffer ) - ::nCRLFLen ) + IF RIGHT( cBuffer, 2 ) == pCRLF // We need to remove this extra one! + cBuffer := LEFT( cBuffer, LEN( cBuffer ) - 2 ) lWithCRLF := pTRUE ENDIF - cBuffer := SUBSTR( cBuffer, RAT( ::cCRLF, cBuffer ) + ::nCRLFLen ) - ::nSkipLength := LEN( cBuffer ) + IF( lWithCRLF, ::nCRLFLen, 0 ) + cBuffer := SUBSTR( cBuffer, RAT( pCRLF, cBuffer ) + 2 ) + ::nSkipLength := LEN( cBuffer ) + IF( lWithCRLF, 2, 0 ) ::nposition := FSEEK( Self:nDosHandle, - ( LEN( cBuffer ) ), 2 ) IF lWithCRLF - ::nposition := FSEEK( Self:nDosHandle, -( ::nCRLFLen), 1 ) + ::nposition := FSEEK( Self:nDosHandle, - 2, 1 ) ENDIF ENDIF @@ -458,11 +453,11 @@ METHOD WRITE( cChar ) CLASS FileBase cBuffer := SPACE( ::nposition - nRead ) FREAD( Self:nDosHandle, @cBuffer, ( ::nposition - nRead ) ) - IF RIGHT( cBuffer, ::nCRLFLen ) == ::cCRLF // with line already - cBuffer := LEFT( cBuffer, LEN( cBuffer ) - ::nCRLFLen ) + IF RIGHT( cBuffer, 2 ) == pCRLF // with line already + cBuffer := LEFT( cBuffer, LEN( cBuffer ) - 2 ) lWithCRLF := pTRUE ENDIF - nLocation := LEN( cBuffer ) - ( RAT( ::cCRLF, cBuffer ) ) + nLocation := LEN( cBuffer ) - ( RAT( pCRLF, cBuffer ) ) ELSE cBuffer := SPACE( pBUFFER_LENGTH ) @@ -472,7 +467,7 @@ METHOD WRITE( cChar ) CLASS FileBase // Now, parse the string. and file - nLocation := AT( ::cCRLF, cBuffer ) + nLocation := AT( pCRLF, cBuffer ) // Now, if there is NO CRLF in the buffer and if the value of the // number of bytes read is less than the buffer length, then we @@ -500,8 +495,8 @@ METHOD appendLine( cLine ) CLASS FileBase IF LEN( cLine ) == 0 // Valid line IF Self:noDosError() .AND. Self:nDosHandle > 0 // No error - IF !( ::cCRLF $ cLine ) // No CRLF, so add - cLIne += ::cCRLF + IF !( pCRLF $ cLine ) // No CRLF, so add + cLIne += pCRLF ENDIF FSEEK( Self:nDosHandle, 0, 2 ) FWRITE( Self:nDosHandle, cLine ) @@ -577,12 +572,12 @@ METHOD GOTO( nValue ) CLASS FileBase lContinue := ( FREAD( Self:nDosHandle, @cBuffer, pBUFFER_LENGTH ) == ; pBUFFER_LENGTH ) cBuffer := cLine + cBuffer - WHILE ::cCRLF $ cBuffer + WHILE pCRLF $ cBuffer IF ++ nCount == nValue lContinue := pFALSE EXIT ENDIF - cBuffer := SUBSTR( cBuffer, AT( ::cCRLF, cBuffer ) + ::nCRLFLen ) + cBuffer := SUBSTR( cBuffer, AT( pCRLF, cBuffer ) + 2 ) ENDDO cLine := cBuffer ENDDO @@ -624,11 +619,11 @@ METHOD BufferGet( lForward ) CLASS FileBase cBuffer := SPACE( ::nposition - nRead ) FREAD( Self:nDosHandle, @cBuffer, ( ::nposition - nRead ) ) - IF RIGHT( cBuffer, ::nCRLFLen ) == ::cCRLF // with line already - cBuffer := LEFT( cBuffer, LEN( cBuffer ) - ::nCRLFLen ) + IF RIGHT( cBuffer, 2 ) == pCRLF // with line already + cBuffer := LEFT( cBuffer, LEN( cBuffer ) - 2 ) lWithCRLF := pTRUE ENDIF - nLocation := LEN( cBuffer ) - ( RAT( ::cCRLF, cBuffer ) ) + nLocation := LEN( cBuffer ) - ( RAT( pCRLF, cBuffer ) ) ELSE cBuffer := SPACE( pBUFFER_LENGTH ) @@ -638,7 +633,7 @@ METHOD BufferGet( lForward ) CLASS FileBase // Now, parse the string. and file - nLocation := AT( ::cCRLF, cBuffer ) + nLocation := AT( pCRLF, cBuffer ) // Now, if there is NO CRLF in the buffer and if the value of the // number of bytes read is less than the buffer length, then we diff --git a/harbour/utils/hbdoc/genasc.prg b/harbour/utils/hbdoc/genasc.prg index accb7d1822..e955189979 100644 --- a/harbour/utils/hbdoc/genasc.prg +++ b/harbour/utils/hbdoc/genasc.prg @@ -132,7 +132,7 @@ FUNCTION ASCIIFiles() LOCAL cSeeAlso LOCAL cTemp LOCAL cChar - LOCAL nDocCnt + LOCAL nDocCnt := 0 LOCAL lBlankLine := .F. // Blank line encountered and sent out LOCAL lAddBlank := .F. // Need to add a blank line if next line is not blank LOCAL lFunc := .T. // currently a function rather than a command @@ -248,7 +248,7 @@ FUNCTION ASCIIFiles() ENDIF FWRITE( nWriteHandle, CRLF ) FWRITE( nWriteHandle, " Source: " + aDirList[ i, F_NAME ] + CRLF + CRLF ) - IF lAuthor + IF lAuthor .and. !empty( cAuthor ) FWRITE( nWriteHandle, " Author: " + cAuthor + CRLF ) ENDIF IF .NOT. EMPTY( cSeeAlso ) @@ -308,7 +308,7 @@ FUNCTION ASCIIFiles() nEnd := 1 nCount := 0 DO WHILE nEnd > 0 - nEnd := ASCAN( aDocInfo, { | a | a[ 4 ] == cFileName + ".hdf" } ) + nEnd := ASCAN( aDocInfo, { | a | a[ 4 ] == cFileName + ".txt" } ) IF nEnd > 0 // This will break if there are more than 10 files with the same first @@ -324,12 +324,12 @@ FUNCTION ASCIIFiles() ENDDO // Add on the extension - cFileName := LEFT( cFileName, 8 ) + ".hdf" + cFileName := LEFT( cFileName, 8 ) + ".txt" - nWriteHandle := FCREATE( "hdf\" + cFileName ) + nWriteHandle := FCREATE( "txt\" + cFileName ) IF nWriteHandle < 1 - ? "Error creating", cFileName, ".hdf" - WRITE_ERROR( "Error creating",,,, cFileName + ".hdf" ) + ? "Error creating", cFileName, ".txt" + WRITE_ERROR( "Error creating",,,, cFileName + ".txt" ) ENDIF // 2) Category ELSEIF AT( cCat, cBuffer ) > 0 diff --git a/harbour/utils/hbdoc/genchm.prg b/harbour/utils/hbdoc/genchm.prg index 8d5354a12d..31d75390d7 100644 --- a/harbour/utils/hbdoc/genchm.prg +++ b/harbour/utils/hbdoc/genchm.prg @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * GENCHM support module for hbdoc document Extractor + * GENCHM support module for hbdoc document Extractor * * Copyright 2000 Luiz Rafael Culik * www - http://www.harbour-project.org @@ -71,6 +71,7 @@ MEMVAR aDirList MEMVAR aDocInfo MEMVAR aWww MEMVAR aResult + STATIC aAlso STATIC aFiTable := {} STATIC aSiTable := {} @@ -86,6 +87,14 @@ STATIC lWasTestExamples := .f. STATIC aColorTable := { 'aqua', 'black', 'fuchia', 'grey', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow' } +// Static variables added for the chm2 addition +STATIC nArrayItem := 1 // Index used to loop through the array of the array +STATIC nArrayItemLine := 1 // Index used to loop through the items in the array of the array +STATIC oHtmClass +STATIC oHtmClassContent +STATIC cFileName := "" // Stores filenames of files that will be created +STATIC cInherits := "" // Stores the inheritance of a class (if known and present) + *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ *+ Function ProcessWww() @@ -137,7 +146,6 @@ FUNCTION ProcessChm() LOCAL lEndSyntax := .F. LOCAL lEndReturns := .F. LOCAL lEndData := .F. - LOCAL lBlankLine := .F. // Blank line encountered and sent out LOCAL lAddBlank := .F. // Need to add a blank line if next line is not blank LOCAL oChm @@ -181,8 +189,8 @@ FUNCTION ProcessChm() // Entry Point // // Put up information labels - @ INFILELINE, 20 SAY "Extracting: " - @ MODULELINE, 20 SAY "Documenting: " + @ INFILELINE, 20 SAY "Extracting: " + @ MODULELINE, 20 SAY "Documenting: " // loop through all of the files lFirstArg := .T. lFirstPass := .T. @@ -319,7 +327,7 @@ FUNCTION ProcessChm() // Open a new file IF AT( "FT_", cFuncName ) > 0 - cTemp := upper(SUBSTR( cFuncName, 4 )) + cTemp := upper(SUBSTR( cFuncName, 4 )) ELSE cTemp := upper(cFuncName) ENDIF @@ -792,6 +800,489 @@ oChm:writeText("
") //:endpar() NEXT RETURN nil + + +FUNCTION ProcessChm2() + LOCAL aTempArray := {} // Temporary array used for storing list of methods and properties + LOCAL cTempString // Temporary string used for storing random strings + LOCAL cTempString2 // Temporary string used for storing random strings + LOCAL cTemp + LOCAL nEnd + LOCAL j + LOCAL cChar + LOCAL nCount + LOCAL cDocType := "" + LOCAL nClassNamePos // Stores the position in the array where the classname can be found + LOCAL nFunctionNamePos // Stores the position in the array where the functionname can be found + LOCAL nReadHandle // Stores the text file's workarea + LOCAL nSubArrayItem := 1 // Index used to loop through the items of the array of the array + LOCAL nTemp1 := 1 // Used to scroll through the DirList array + LOCAL nTemp2 := 1 // Used to scroll through the aFunctionItems array + LOCAL nPropertyListAnker // Used to add an html-anker in the page + LOCAL nMethodListAnker // Used to add an html-anker in the page + LOCAL aFunctionItems := {{"Category", "Category"}, {"Syntax", "Syntax"}, {"Arguments", "Arguments"}, ; + + {"Returns", "Returns"}, {"Description", "Description"}, {"Examples", "Examples"}, {"Tests", "Tests"}, ; + + {"Status", "Status"}, {"Compliance", "Compliance"}, {"Platforms", "Platforms"}, {"Files", "Files"}, ; + + {"Seealso", "See also"}} + + FOR nTemp1 := 1 TO LEN(aDirList) + // Calculate the amount of characters the source files uses each line + nCommentLen := IIF(AT(".ASM", UPPER(aDirList[nTemp1, F_NAME])) > 0, 2, 4) + // Select the file to read from + nReadHandle := FT_FUSE(aDirList[nTemp1, F_NAME]) + + IF nReadHandle < 0 + WRITE_ERROR("Can't open file: (Dos Error " + STR( FERROR() ) + ")",,,, aDirList[ nTemp1, F_NAME ]) + @ ERRORLINE, 0 CLEAR TO ERRORLINE, MAXCOL() + @ ERRORLINE, 20 SAY "Can't open file: (Dos Error " + STR( FERROR() ) + ") File=" + aDirList[ nTemp1, F_NAME ] + LOOP + ENDIF + + // Read the entire file into the aCurDoc array + ReadFromTop3(nReadHandle) + + // Generate a new document, based on the name of the class or function + // Check if the file contains a class or function definition + IF LEN(aCurDoc) > 0 .AND. nArrayItem <= LEN(aCurDoc) + IF ASCAN(aCurDoc[nArrayItem], " $CLASSDOC$") > 0 + cDocType := "Class" + nClassNamePos := ASCAN(aCurDoc[nArrayItem], " $CLASS$", ASCAN(aCurDoc[nArrayItem], " $CLASSDOC$") + 1) + 1 + cFileName := aCurDoc[nArrayItem][nClassNamePos] + ELSEIF ASCAN(aCurDoc[nArrayItem], " $DOC$") > 0 + cDocType := "Function" + nFunctionNamePos := ASCAN(aCurDoc[nArrayItem], " $FUNCNAME$") + 1 + cFileName := aCurDoc[nArrayItem][nFunctionNamePos] + ELSE + LOOP + ENDIF + + // Check whether the function name has "FT_" in it, if so, ignore the first three characters + IF AT("FT_", cFileName) > 0 + cTemp := UPPER(SUBSTR(cFileName, 4)) + ELSE + cTemp := UPPER(cFileName) + ENDIF + + // Check whether the function name has "(" in it, if so, ignore it + the following chars + IF (nEnd := AT("(", cTemp)) > 0 + cTemp := LEFT(cTemp, nEnd - 1) + ENDIF + + // Strip off any other non-alphabetical or -numeric characters + cFileName := "" + FOR j := 1 TO LEN( cTemp ) + cChar := SUBSTR( cTemp, j, 1 ) + IF ( cChar >= "0" .AND. cChar <= "9" ) .OR. ( cChar >= "A" .AND. cChar <= "Z" ) .OR. cChar = "_" + cFileName += cChar + ENDIF + NEXT + + // Check whether the file name already exists, if so, modify the name + cFileName := LEFT(cFileName, 36) + nEnd := 1 + nCount := 0 + DO WHILE nEnd > 0 + nEnd := ASCAN(aDocInfo, { | a | a[ 2 ] == cFileName + ".htm" }) + IF nEnd > 0 + IF LEN( cFileName ) = 36 + cFileName := STUFF( cFileName, 36, 1, STR( nCount, 1, 0 ) ) + ELSE + cFileName = cFileName + STR( nCount, 1, 0 ) + ENDIF + nCount ++ + ENDIF + ENDDO + + // Add the file extension + cFileName := LEFT( cFileName, 36 ) + ".htm" + oHtmClass := THTML():New( 'chm\' + cFileName ) + + // If file creation was successful + IF oHtmClass:nHandle > 0 + // Add a title to the HTML + nPropertyListAnker := .F. + nMethodListAnker := .F. + + // Add CSS to the HTML + oHtmClass:WriteText("") + + // Loop through the first array (list with arrays) + DO WHILE nArrayItem <= LEN(aCurDoc) + nSubArrayItem := 1 + + IF cDocType = "Class" + // Loop through the second array (list with methods, properties, ...) + + IF ASCAN(aCurDoc[nArrayItem], " $CLASS$") > 0 + // Write class name + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "CLASS" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("" + cTempString + " - Class overview") + oHtmClass:WriteText("
Class " + cTempString + "
") + + // Add classname and filename to the docinfo array + AADD(aDocInfo, { cTempString, cFileName, "C1", {} }) + + // Write oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
" + cTempString + "
") + + // Write inheritance + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "INHERITS" $ UPPER(a)}) + 1 + IF nArrayItemLine - 1 <> 0 .AND. !EMPTY(aCurDoc[nArrayItem][nArrayItemLine]) //.AND. FILE(aCurDoc[nArrayItem][nArrayItemLine] + ".txt") + cInherits := aCurDoc[nArrayItem][nArrayItemLine] + cTempString := "" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + "" + ELSE + cTempString := "-" + ENDIF + oHtmClass:WriteText("
» " + "Inherits" + "
") + oHtmClass:WriteText("
" + cTempString + "
") + + WriteClass3("Constructor", "Constructor") + WriteClass3("Syntax", "Syntax") + WriteClass3("Arguments", "Arguments") + WriteClass3("Returns", "Returns") + WriteClassDataMethod3("Method", "Methods", nArrayItem, nArrayItemLine) + WriteClassDataMethod3("Data", "Properties", nArrayItem, nArrayItemLine) + WriteClass3("Category", "Category") + WriteClass3("Description", "Description") + WriteClass3("Seealso", "See also") + + oHtmClass:WriteText("") + + // Create new HTML for the properties and methods + IF LEN(aCurDoc) > 1 + cFileName := LEFT(cFileName, LEN(cFileName) - 4) + "_content.htm" + oHtmClassContent := THTML():New( 'chm\' + cFileName ) + + IF oHtmClassContent:nHandle > 0 + // Add a title to the HTML + oHtmClassContent:WriteText("Harbour - Reference Guide") + + // Add CSS to the HTML + oHtmClassContent:WriteText("") + + // Write class name + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "CLASS" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("" + cTempString + " - Class details") + oHtmClassContent:WriteText("
Class " + cTempString + "
") + ENDIF + ENDIF + ELSEIF ASCAN(aCurDoc[nArrayItem], " $DATA$") > 0 + IF oHtmClassContent:nHandle > 0 + // Write property name + IF nPropertyListAnker = .F. + oHtmClassContent:WriteText("") + nPropertyListAnker = .t. + ENDIF + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "DATA" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
") + + //IF ASCAN(aDocInfo, {|a| a[2] = cFileName} ) > 0 + //?? cFileName + //AADD(aDocInfo[ASCAN(aDocInfo, {|a| a[2] = cFileName} )][4] := {cTempString, "D"} + //ENDIF + AADD(aDocInfo[LEN(aDocInfo)][4], {"Data", cTempString}) + + // Write property oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
" + cTempString + "
") + + WriteData3("Category", "Category") + WriteData3("Description", "Description") + ENDIF + ELSEIF ASCAN(aCurDoc[nArrayItem], " $METHOD$") > 0 + IF oHtmClassContent:nHandle > 0 + // Write method name + IF nMethodListAnker = .F. + oHtmClassContent:WriteText("") + nMethodListAnker = .t. + ENDIF + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "METHOD" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
") + + AADD(aDocInfo[LEN(aDocInfo)][4], {"Method", cTempString}) + + // Write method oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
" + cTempString + "
") + + WriteMethod3("Syntax", "Syntax") + WriteMethod3("Arguments", "Arguments") + WriteMethod3("Returns", "Returns") + WriteMethod3("Description", "Description") + ENDIF + ELSE + // ... + ENDIF + ELSE + // Write function name + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "FUNCNAME" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
Function " + cTempString + "
") + + // Add function name and filename to the docinfo array + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "CATEGORY" $ UPPER(a)}, 2) + 1 + cTempString2 := aCurDoc[nArrayItem][nArrayItemLine] + IF cTempString2 $ "WinAPI" + AADD( aDocInfo, { cTempString, cFileName, "F2" } ) + ELSE + AADD( aDocInfo, { cTempString, cFileName, "F1" } ) + ENDIF + + // Write function oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
" + cTempString + "
") + + // Write selected function items + DO WHILE nTemp2 <= LEN(aFunctionItems) + WriteFunction3(aFunctionItems[nTemp2][1], aFunctionItems[nTemp2][2]) + nTemp2 ++ + ENDDO + ENDIF + + nArrayItem ++ + ENDDO + + IF cDocType = "Class" + oHtmClassContent:WriteText("") + ELSE + oHtmClass:WriteText("") + ENDIF + //aDocInfo[1][4] := {} + ELSE + // HTML file could not be created, skip current source file + LOOP + ENDIF + ENDIF + + NEXT +RETURN NIL + + +FUNCTION ReadFromTop3(nh) + LOCAL cBuffer := '' + LOCAL aTempArray := {} + + DO WHILE FReadLine(nH, @cBuffer, 4096) + cBuffer := TRIM(SUBSTR(cBuffer, nCommentLen)) + + AADD(aTempArray, cBuffer) + IF AT(DELIM + "END" + DELIM, cBuffer) > 0 + AADD(aCurdoc, aTempArray) + aTempArray := {} + ENDIF + ENDDO + + FT_FGOTOP() +RETURN NIL + + +FUNCTION WriteClass3(cItem, cTitle) + LOCAL cTempString + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + IF nArrayItemLine - 1 <> 0 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ELSE + cTempString := "-" + ENDIF + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClass:WriteText("
» " + cTitle + "
") + oHtmClass:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION WriteClassDataMethod3(cItem, cTitle, nArrayItem, nArrayItemLine) + LOCAL cTempString + LOCAL nPrevArrayItem := nArrayItem + LOCAL nPrevArrayItemLine := nArrayItemLine + LOCAL aTmpArray := {} + LOCAL nTmpCount := 1 + + nArrayItem ++ + cTempString := "" + DO WHILE nArrayItem <= LEN(aCurDoc) + nArrayItemLine := ASCAN(aCurDoc[nArrayItem], {|a| "$" + UPPER(cItem) + "$" $ UPPER(a)}) + 1 + IF nArrayItemLine -1 <> 0 + AADD(aTmpArray, {"• " + aCurDoc[nArrayItem][nArrayItemLine] + "
", aCurDoc[nArrayItem][nArrayItemLine]}) + nTmpCount ++ + ENDIF + nArrayItem ++ + ENDDO + + ASORT(aTmpArray,,, {|x, y| UPPER(x[2]) < UPPER(y[2])}) + FOR nTmpCount := 1 TO LEN(aTmpArray) + cTempString = cTempString + aTmpArray[nTmpCount][1] + NEXT + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClass:WriteText("
» " + cTitle + "
") + oHtmClass:WriteText("
" + cTempString + "
") + + nArrayItem = nPrevArrayItem + nArrayItemLine = nPrevArrayItemLine + + LinkInheritance3(cItem) +RETURN NIL + + +FUNCTION LinkInheritance3(cItem) + LOCAL nTemp1 := 1 + + DO WHILE nTemp1 <= LEN(aDirList) + IF UPPER(aDirList[nTemp1][1]) = UPPER(cInherits + ".TXT") + oHtmClass:WriteText("") + ENDIF + nTemp1 ++ + ENDDO +RETURN NIL + + +FUNCTION WriteData3(cItem, cTitle) + LOCAL cTempString + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClassContent:WriteText("
» " + cTitle + "
") + oHtmClassContent:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION WriteMethod3(cItem, cTitle) + LOCAL cTempString + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + cTempString := HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClassContent:WriteText("
» " + cTitle + "
") + oHtmClassContent:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION WriteFunction3(cItem, cTitle) + LOCAL cTempString + + nArrayItemLine := ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + cTempString := aCurDoc[nArrayItem][nArrayItemLine] + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat3(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClass:WriteText("
» " + cTitle + "
") + oHtmClass:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION HTMFormat3(cTempString) + LOCAL cTmpString1 := cTempString + LOCAL cTmpString2 := "" + LOCAL cTmpChar := "" + LOCAL nTmpCount := 1 + + DO WHILE nTmpCount <= LEN(cTmpString1) + cTmpChar := SUBSTR(cTmpString1, nTmpCount, 1) + + DO CASE + CASE cTmpChar = "<" + cTmpString2 = cTmpString2 + "<" + CASE cTmpChar = ">" + cTmpString2 = cTmpString2 + ">" + OTHERWISE + cTmpString2 = cTmpString2 + cTmpChar + ENDCASE + + nTmpCount ++ + ENDDO +RETURN cTmpString2 + /*********************************** * Function ProcChmBuf(cBuffer) -> cTemp * Parameter cBuffer -> Strip the "<" and ">" symbols from the imput String @@ -920,7 +1411,7 @@ RETURN nil *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION FormatChmBuff( cBuffer, cStyle, oChm ) +FUNCTION FormatChmBuff( cBuffer, cStyle ) LOCAL creturn := '' LOCAL cline := '' @@ -929,9 +1420,7 @@ FUNCTION FormatChmBuff( cBuffer, cStyle, oChm ) LOCAL lEndBuffer := .f. LOCAL lArgBold := .f. LOCAL npos - - HB_SYMBOL_UNUSED( oChm ) - + //LOCAL nposend // Variable not used in fucntion, it may be deleted? creturn := cBuffer + ' ' IF AT( '', creturn ) > 0 .OR. EMPTY( cBuffer ) IF EMPTY( cbuffer ) @@ -1143,7 +1632,7 @@ FUNCTION ProcChmDesc( cBuffer, oChm, cStyle ) cbuffer := cReturn ENDIF ELSE - cBuffer := FormatChmBuff( cBuffer, cStyle, oChm ) + cBuffer := FormatChmBuff( cBuffer, cStyle ) ENDIF ENDIF ENDIF @@ -1439,4 +1928,4 @@ STATIC FUNCTION GetItem( cItem, nCurdoc ) ENDIF RETURN lReturn -*+ EOF: GENNG.PRG +*+ EOF: GENNG.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/genhtm.prg b/harbour/utils/hbdoc/genhtm.prg index 95946fdca2..4b71dd5574 100644 --- a/harbour/utils/hbdoc/genhtm.prg +++ b/harbour/utils/hbdoc/genhtm.prg @@ -68,7 +68,7 @@ #define LONGLINE 600 #define LONGONELINE 86 MEMVAR aDirList -MEMVAR aDocInfo +MEMVAR aDocInfo, aDocwwwInfo MEMVAR aWww,aResult STATIC aAlso @@ -80,11 +80,22 @@ STATIC lEof STATIC aFoiTable := {} STATIC atiTable := {} STATIC nNumTableItems := 0 -STATIC aCurDoc := {} +STATIC aCurDoc := {} // x +static cLastText := "" +Static clastBuffer := "" STATIC nCurDoc := 1 STATIC lWasTestExamples := .f. STATIC aColorTable := { 'aqua', 'black', 'fuchia', 'grey', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow' } +// Static variables added for the htm2 addition +STATIC cDocType := "" +STATIC nArrayItem := 1 // Index used to loop through the array of the array +STATIC nArrayItemLine := 1 // Index used to loop through the items in the array of the array +STATIC oHtmClass +STATIC oHtmClassContent +STATIC cFileName := "" // Stores filenames of files that will be created +STATIC cInherits := "" // Stores the inheritance of a class (if known and present) + *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ *+ Function ProcessWww() @@ -136,7 +147,6 @@ FUNCTION ProcessWww() LOCAL lEndSyntax := .F. LOCAL lEndReturns := .F. LOCAL lEndData := .F. - LOCAL lBlankLine := .F. // Blank line encountered and sent out LOCAL lAddBlank := .F. // Need to add a blank line if next line is not blank LOCAL oHtm @@ -176,9 +186,6 @@ FUNCTION ProcessWww() LOCAL cData := DELIM + "DATA" + DELIM LOCAL cMethod := DELIM + 'METHOD' + DELIM LOCAL cClassDoc := DELIM + "CLASSDOC" + DELIM -#ifdef GAUGE - Local aGauge,agauge1 -#endif LOCAL nDocs:=0 // // Entry Point @@ -197,7 +204,7 @@ FUNCTION ProcessWww() nCommentLen := IIF( AT( ".ASM", UPPER( aDirList[ i, F_NAME ] ) ) > 0, 2, 4 ) nReadHandle := FT_FUSE( aDirList[ i, F_NAME ] ) #ifdef GAUGE - if i == 1 + if i == 1 aGauge1:= Gauge():New( 5, 5, 7, MaxCol() - 5) Endif #endif @@ -393,11 +400,11 @@ FUNCTION ProcessWww() cFileName := LEFT( cFileName, 36 ) + ".htm" IF lDoc - oHtm := THTML():New( 'htm/' + cFileName ) + oHtm := THTML():New( 'htm\' + cFileName ) ENDIF IF lFirstPass .AND. lClassDoc lFirstPass := .F. - oHtm := THTML():New( 'htm/' + cFileName ) + oHtm := THTML():New( 'htm\' + cFileName ) ENDIF IF ohtm:nHandle < 1 ? "Error creating", cFileName, ".htm" @@ -447,8 +454,7 @@ FUNCTION ProcessWww() cBuffer := ReadLN( @lEof ) nLineCnt ++ // get the category - cCategory := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) - cCategory := strtran( cCategory, hb_OSNewLine(), '' ) + cCategory := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) // 3) One line description @@ -666,7 +672,7 @@ oHtm:writeText("
") //:endpar() IF lAddBlank lAddBlank := .F. ENDIF - prochtmdesc( cbuffer, oHtm, "Syntax" ) + prochtmdesc( cbuffer, oHtm, "Syntax" ,cFileName) ELSEIF nMode = D_ARG IF LEN( cBuffer ) > LONGLINE @@ -800,6 +806,478 @@ oHtm:writeText("
") //:endpar() NEXT RETURN nil + + +FUNCTION ProcessWww2() + LOCAL aTempArray := {} // Temporary array used for storing list of methods and properties + LOCAL cTempString // Temporary string used for storing random strings + LOCAL cTempString2 // Temporary string used for storing random strings + LOCAL nClassNamePos // Stores the position in the array where the classname can be found + LOCAL nFunctionNamePos // Stores the position in the array where the functionname can be found + LOCAL nReadHandle // Stores the text file's workarea + LOCAL nSubArrayItem := 1 // Index used to loop through the items of the array of the array + LOCAL nTemp1 := 1 // Used to scroll through the DirList array + LOCAL nTemp2 := 1 // Used to scroll through the aFunctionItems array + LOCAL nPropertyListAnker // Used to add an html-anker in the page + LOCAL nMethodListAnker // Used to add an html-anker in the page + LOCAL aFunctionItems := {{"Category", "Category"}, {"Syntax", "Syntax"}, {"Arguments", "Arguments"}, ; + + {"Returns", "Returns"}, {"Description", "Description"}, {"Examples", "Examples"}, {"Tests", "Tests"}, ; + + {"Status", "Status"}, {"Compliance", "Compliance"}, {"Platforms", "Platforms"}, {"Files", "Files"}, ; + + {"Seealso", "See also"}} + LOCAL cTemp + LOCAL nEnd + LOCAL j + LOCAL nCount + LOCAL cChar + + FOR nTemp1 := 1 TO LEN(aDirList) + // Calculate the amount of characters the source files uses each line + nCommentLen := IIF(AT(".ASM", UPPER(aDirList[nTemp1, F_NAME])) > 0, 2, 4) + // Select the file to read from + nReadHandle := FT_FUSE(aDirList[nTemp1, F_NAME]) + + IF nReadHandle < 0 + WRITE_ERROR("Can't open file: (Dos Error " + STR( FERROR() ) + ")",,,, aDirList[ nTemp1, F_NAME ]) + @ ERRORLINE, 0 CLEAR TO ERRORLINE, MAXCOL() + @ ERRORLINE, 20 SAY "Can't open file: (Dos Error " + STR( FERROR() ) + ") File=" + aDirList[ nTemp1, F_NAME ] + LOOP + ENDIF + + // Read the entire file into the aCurDoc array + ReadFromTop2(nReadHandle) + + // Generate a new document, based on the name of the class or function + // Check if the file contains a class or function definition + IF LEN(aCurDoc) > 0 .AND. nArrayItem <= LEN(aCurDoc) + IF ASCAN(aCurDoc[nArrayItem], " $CLASSDOC$") > 0 + cDocType := "Class" + nClassNamePos := ASCAN(aCurDoc[nArrayItem], " $CLASS$", ASCAN(aCurDoc[nArrayItem], " $CLASSDOC$") + 1) + 1 + cFileName := aCurDoc[nArrayItem][nClassNamePos] + ELSEIF ASCAN(aCurDoc[nArrayItem], " $DOC$") > 0 + cDocType := "Function" + nFunctionNamePos := ASCAN(aCurDoc[nArrayItem], " $FUNCNAME$") + 1 + cFileName := aCurDoc[nArrayItem][nFunctionNamePos] + ELSE + LOOP + ENDIF + + // Check whether the function name has "FT_" in it, if so, ignore the first three characters + IF AT("FT_", cFileName) > 0 + cTemp := UPPER(SUBSTR(cFileName, 4)) + ELSE + cTemp := UPPER(cFileName) + ENDIF + + // Check whether the function name has "(" in it, if so, ignore it + the following chars + IF (nEnd := AT("(", cTemp)) > 0 + cTemp := LEFT(cTemp, nEnd - 1) + ENDIF + + // Strip off any other non-alphabetical or -numeric characters + cFileName := "" + FOR j := 1 TO LEN( cTemp ) + cChar := SUBSTR( cTemp, j, 1 ) + IF ( cChar >= "0" .AND. cChar <= "9" ) .OR. ( cChar >= "A" .AND. cChar <= "Z" ) .OR. cChar = "_" + cFileName += cChar + ENDIF + NEXT + + // Check whether the file name already exists, if so, modify the name + cFileName := LEFT(cFileName, 36) + nEnd := 1 + nCount := 0 + DO WHILE nEnd > 0 + nEnd := ASCAN(aDocInfo, { | a | a[ 2 ] == cFileName + ".htm" }) + IF nEnd > 0 + IF LEN( cFileName ) = 36 + cFileName := STUFF( cFileName, 36, 1, STR( nCount, 1, 0 ) ) + ELSE + cFileName = cFileName + STR( nCount, 1, 0 ) + ENDIF + nCount ++ + ENDIF + ENDDO + + // Add the file extension + cFileName := LEFT( cFileName, 36 ) + ".htm" + oHtmClass := THTML():New( 'htm\' + cFileName ) + + // If file creation was successful + IF oHtmClass:nHandle > 0 + // Add a title to the HTML + nPropertyListAnker := .F. + nMethodListAnker := .F. + + oHtmClass:WriteText("Harbour - Reference Guide") + + // Add CSS to the HTML + oHtmClass:WriteText("") + + // Loop through the first array (list with arrays) + DO WHILE nArrayItem <= LEN(aCurDoc) + nSubArrayItem := 1 + + IF cDocType = "Class" + // Loop through the second array (list with methods, properties, ...) + + IF ASCAN(aCurDoc[nArrayItem], " $CLASS$") > 0 + // Write class name + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "CLASS" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
Class " + cTempString + "
") + + // Add classname and filename to the docinfo array + AADD( aDocInfo, { cTempString, cFileName, "C1" } ) + + // Write oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
" + cTempString + "
") + + // Write inheritance + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "INHERITS" $ UPPER(a)}) + 1 + IF nArrayItemLine - 1 <> 0 .AND. !EMPTY(aCurDoc[nArrayItem][nArrayItemLine]) //.AND. FILE(aCurDoc[nArrayItem][nArrayItemLine] + ".txt") + cInherits := aCurDoc[nArrayItem][nArrayItemLine] + cTempString := "" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + "" + ELSE + cTempString := "-" + ENDIF + oHtmClass:WriteText("
» " + "Inherits" + "
") + oHtmClass:WriteText("
" + cTempString + "
") + + WriteClass("Constructor", "Constructor") + WriteClass("Syntax", "Syntax") + WriteClass("Arguments", "Arguments") + WriteClass("Returns", "Returns") + WriteClassDataMethod("Method", "Methods", nArrayItem, nArrayItemLine) + WriteClassDataMethod("Data", "Properties", nArrayItem, nArrayItemLine) + WriteClass("Category", "Category") + WriteClass("Description", "Description") + WriteClass("Seealso", "See also") + + oHtmClass:WriteText("") + + // Create new HTML for the properties and methods + IF LEN(aCurDoc) > 1 + cFileName := LEFT(cFileName, LEN(cFileName) - 4) + "_content.htm" + oHtmClassContent := THTML():New( 'htm\' + cFileName ) + + IF oHtmClassContent:nHandle > 0 + // Add a title to the HTML + oHtmClassContent:WriteText("Harbour - Reference Guide") + + // Add CSS to the HTML + oHtmClassContent:WriteText("") + + // Write class name + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "CLASS" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
Class " + cTempString + "
") + ENDIF + ENDIF + ELSEIF ASCAN(aCurDoc[nArrayItem], " $DATA$") > 0 + IF oHtmClassContent:nHandle > 0 + // Write property name + IF nPropertyListAnker = .F. + oHtmClassContent:WriteText("") + nPropertyListAnker = .t. + ENDIF + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "$DATA$" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
") + + // Write property oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
" + cTempString + "
") + + WriteData("Datatype", "Property type") + WriteData("Category", "Category") + WriteData("Description", "Description") + ENDIF + ELSEIF ASCAN(aCurDoc[nArrayItem], " $METHOD$") > 0 + IF oHtmClassContent:nHandle > 0 + // Write method name + IF nMethodListAnker = .F. + oHtmClassContent:WriteText("") + nMethodListAnker = .t. + ENDIF + + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "METHOD" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
") + + // Write method oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClassContent:WriteText("
" + cTempString + "
") + + WriteMethod("Syntax", "Syntax") + WriteMethod("Arguments", "Arguments") + WriteMethod("Returns", "Returns") + WriteMethod("Description", "Description") + ENDIF + ELSE + // ... + ENDIF + ELSE + // Write function name + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "FUNCNAME" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
Function " + cTempString + "
") + + // Add function name and filename to the docinfo array + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "CATEGORY" $ UPPER(a)}, 2) + 1 + cTempString2 := aCurDoc[nArrayItem][nArrayItemLine] + IF cTempString2 $ "WinAPI" + AADD( aDocInfo, { cTempString, cFileName, "F2" } ) + ELSE + AADD( aDocInfo, { cTempString, cFileName, "F1" } ) + ENDIF + + // Write function oneliner + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| "ONELINER" $ UPPER(a)}, 2) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + oHtmClass:WriteText("
" + cTempString + "
") + + // Write selected function items + DO WHILE nTemp2 <= LEN(aFunctionItems) + WriteFunction(aFunctionItems[nTemp2][1], aFunctionItems[nTemp2][2]) + nTemp2 ++ + ENDDO + ENDIF + + nArrayItem ++ + ENDDO + + IF cDocType = "Class" + oHtmClassContent:WriteText("") + ELSE + oHtmClass:WriteText("") + ENDIF + ELSE + // HTML file could not be created, skip current source file + LOOP + ENDIF + ENDIF + + NEXT +RETURN NIL + + +FUNCTION ReadFromTop2(nh) + LOCAL cBuffer := '' + LOCAL aTempArray := {} + + DO WHILE FReadLine(nH, @cBuffer, 4096) + cBuffer := TRIM(SUBSTR(cBuffer, nCommentLen)) + + AADD(aTempArray, cBuffer) + IF AT(DELIM + "END" + DELIM, cBuffer) > 0 + AADD(aCurdoc, aTempArray) + aTempArray := {} + ENDIF + ENDDO + + FT_FGOTOP() +RETURN NIL + + +FUNCTION WriteClass(cItem, cTitle) + LOCAL cTempString + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + IF nArrayItemLine - 1 <> 0 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ELSE + cTempString := "-" + ENDIF + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClass:WriteText("
» " + cTitle + "
") + oHtmClass:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION WriteClassDataMethod(cItem, cTitle, nArrayItem, nArrayItemLine) + LOCAL nPrevArrayItem := nArrayItem + LOCAL nPrevArrayItemLine := nArrayItemLine + LOCAL aTmpArray := {} + LOCAL nTmpCount := 1 + LOCAL cTempString + + nArrayItem ++ + cTempString := "" + DO WHILE nArrayItem <= LEN(aCurDoc) + nArrayItemLine := ASCAN(aCurDoc[nArrayItem], {|a| "$" + UPPER(cItem) + "$" $ UPPER(a)}) + 1 + IF nArrayItemLine -1 <> 0 + AADD(aTmpArray, {"• " + aCurDoc[nArrayItem][nArrayItemLine] + "
", aCurDoc[nArrayItem][nArrayItemLine]}) + nTmpCount ++ + ENDIF + nArrayItem ++ + ENDDO + + ASORT(aTmpArray,,, {|x, y| UPPER(x[2]) < UPPER(y[2])}) + FOR nTmpCount := 1 TO LEN(aTmpArray) + cTempString = cTempString + aTmpArray[nTmpCount][1] + NEXT + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClass:WriteText("
» " + cTitle + "
") + oHtmClass:WriteText("
" + cTempString + "
") + + nArrayItem = nPrevArrayItem + nArrayItemLine = nPrevArrayItemLine + + LinkInheritance(cItem) +RETURN NIL + + +FUNCTION LinkInheritance(cItem) + LOCAL nTemp1 := 1 + + DO WHILE nTemp1 <= LEN(aDirList) + IF UPPER(aDirList[nTemp1][1]) = UPPER(cInherits + ".TXT") + oHtmClass:WriteText("") + ENDIF + nTemp1 ++ + ENDDO +RETURN NIL + + +FUNCTION WriteData(cItem, cTitle) + LOCAL cTempString + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClassContent:WriteText("
» " + cTitle + "
") + oHtmClassContent:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION WriteMethod(cItem, cTitle) + LOCAL cTempString + nArrayItemLine = ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + cTempString := HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClassContent:WriteText("
» " + cTitle + "
") + oHtmClassContent:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION WriteFunction(cItem, cTitle) + LOCAL cTempString + nArrayItemLine := ASCAN(aCurDoc[nArrayItem], {|a| UPPER(cItem) $ UPPER(a)}) + 1 + cTempString := aCurDoc[nArrayItem][nArrayItemLine] + DO WHILE "$" $ aCurDoc[nArrayItem][nArrayItemLine + 1] = .F. + nArrayItemLine ++ + cTempString = cTempString + "
" + HTMFormat(aCurDoc[nArrayItem][nArrayItemLine]) + ENDDO + IF EMPTY(cTempString) + cTempString := "-" + ENDIF + + oHtmClass:WriteText("
» " + cTitle + "
") + oHtmClass:WriteText("
" + cTempString + "
") +RETURN NIL + + +FUNCTION HTMFormat(cTempString) + LOCAL cTmpString1 := cTempString + LOCAL cTmpString2 := "" + LOCAL nTmpCount := 1 + LOCAL cTmpChar + + DO WHILE nTmpCount <= LEN(cTmpString1) + cTmpChar := SUBSTR(cTmpString1, nTmpCount, 1) + + DO CASE + CASE cTmpChar = "<" + cTmpString2 = cTmpString2 + "<" + CASE cTmpChar = ">" + cTmpString2 = cTmpString2 + ">" + OTHERWISE + cTmpString2 = cTmpString2 + cTmpChar + ENDCASE + + nTmpCount ++ + ENDDO +RETURN cTmpString2 + + + /*********************************** * Function ProcWwwBuf(cBuffer) -> cTemp * Parameter cBuffer -> Strip the "<" and ">" symbols from the imput String @@ -928,7 +1406,7 @@ RETURN nil *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION FormatHtmBuff( cBuffer, cStyle, oHtm ) +FUNCTION FormatHtmBuff( cBuffer, cStyle ) LOCAL creturn := '' LOCAL cline := '' @@ -937,9 +1415,6 @@ FUNCTION FormatHtmBuff( cBuffer, cStyle, oHtm ) LOCAL lEndBuffer := .f. LOCAL lArgBold := .f. LOCAL npos - - HB_SYMBOL_UNUSED( oHtm ) - creturn := cBuffer + ' ' IF AT( '', creturn ) > 0 .OR. EMPTY( cBuffer ) IF EMPTY( cbuffer ) @@ -1095,7 +1570,7 @@ RETURN cbuffer *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION ProchtmDesc( cBuffer, oHtm, cStyle ) +FUNCTION ProchtmDesc( cBuffer, oHtm, cStyle ,cFileName) LOCAL cOldLine := '' LOCAL npos @@ -1112,8 +1587,13 @@ FUNCTION ProchtmDesc( cBuffer, oHtm, cStyle ) LOCAL LFstTableItem := .T. LOCAL lEndTable := .F. LOCAL lEndBuffer := .f. - DEFAULT cStyle TO "Default" + DEFAULT cStyle TO "Default" + DEFAULT cFileName TO NIL + iF cStyle == "Syntax" +// tracelog('cBuffer',cBuffer) + clastBuffer += cBuffer + endif IF AT( '', cBuffer ) == 0 .AND. !EMPTY( cBuffer ) .AND. cstyle <> "Example" cBuffer := '' + cBuffer ENDIF @@ -1151,7 +1631,7 @@ FUNCTION ProchtmDesc( cBuffer, oHtm, cStyle ) cbuffer := cReturn ENDIF ELSE - cBuffer := FormathtmBuff( cBuffer, cStyle, oHtm ) + cBuffer := FormathtmBuff( cBuffer, cStyle ) ENDIF ENDIF ENDIF @@ -1201,6 +1681,13 @@ FUNCTION ProchtmDesc( cBuffer, oHtm, cStyle ) IF !EMPTY( cBuffer ) // cBuffer:=SUBSTR(cBuffer,2) cBuffeR := ALLTRIM( cBuffer ) + cLastText += cBuffer + if At("->" ,clastBuffer) >0 + aadd(aDocWwwInfo, { cLastText,cFileName}) + clastBuffer:="" + cLastText:="" + endif +// tracelog(cLastBuffer) oHtm:WritePar( cBuffer ) ENDIF @@ -1375,16 +1862,16 @@ FUNCTION GenhtmTable( oHtm ) LOCAL x /* oHtm:WriteText( "
" ) oHtm:WriteText( "
" )*/ - oHtm:WriteText( '' ) //-4 + oHtm:WriteText( '
' ) //-4 FOR x := 1 TO LEN( asitable ) IF !EMPTY( asitable[ x ] ) IF nNumTableItems == 2 - oHtm:WriteText( ' ' ) + oHtm:WriteText( ' ' ) ELSEIF nNumTableItems == 3 - oHtm:WriteText( ' ' ) + oHtm:WriteText( ' ' ) ELSEIF nNumTableItems == 4 - oHtm:WriteText( ' ' ) + oHtm:WriteText( ' ' ) ENDIF ELSE oHtm:WriteText( ' ' ) @@ -1435,12 +1922,9 @@ STATIC FUNCTION GetItem( cItem, nCurdoc ) LOCAL nPos LOCAL cCuritem - LOCAL lReturn:=.F. + LOCAL lReturn LOCAL xPos - - if nCurdoc <= len(aCurdoc) - xPos := aCurdoc[ nCurdoc ] - endif + xPos := aCurdoc[ nCurdoc ] nPos := ASCAN( xPos, { | x | UPPER( ALLTRIM( x ) ) == UPPER( ALLTRIM( cItem ) ) } ) IF nPos > 0 cCuritem := xPos[ nPos ] @@ -1452,8 +1936,9 @@ STATIC FUNCTION GetItem( cItem, nCurdoc ) ENDIF RETURN lReturn + #ifdef GAUGE function CountDocs(aCurDoc) return len(aCurdoc) #endif -*+ EOF: GENNG.PRG +*+ EOF: GENNG.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/genng.prg b/harbour/utils/hbdoc/genng.prg index ea4aaa410e..194b41e4a8 100644 --- a/harbour/utils/hbdoc/genng.prg +++ b/harbour/utils/hbdoc/genng.prg @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * GENNG support module for hbdoc document Extractor + * GENNG support module for hbdoc document Extractor * * Copyright 2000 Luiz Rafael Culik * www - http://www.harbour-project.org @@ -175,8 +175,8 @@ FUNCTION ProcessiNg() // Entry Point // // Put up information labels - @ INFILELINE, 20 SAY "Extracting: " - @ MODULELINE, 20 SAY "Documenting: " + @ INFILELINE, 20 SAY "Extracting: " + @ MODULELINE, 20 SAY "Documenting: " // loop through all of the files FOR i := 1 TO nFiles @@ -187,16 +187,16 @@ FUNCTION ProcessiNg() nCommentLen := IIF( AT( ".ASM", UPPER( aDirList[ i, F_NAME ] ) ) > 0, 2, 4 ) nReadHandle := FT_FUSE( aDirList[ i, F_NAME ] ) @ INFILELINE, 33 CLEAR TO INFILELINE, MAXCOL() - @ INFILELINE, 33 SAY PAD( aDirList[ i, F_NAME ], 47 ) + @ INFILELINE, 33 SAY PAD( aDirList[ i, F_NAME ], 47 ) @ MODULELINE, 33 CLEAR TO LINELINE, MAXCOL() - @ LINELINE, 27 SAY "Line:" + @ LINELINE, 27 SAY "Line:" nLineCnt := 0 IF nReadHandle < 0 WRITE_ERROR( "Can't open file: (Dos Error " + STR( FERROR() ) + ")",,,, aDirList[ i, F_NAME ] ) @ ERRORLINE, 0 CLEAR TO ERRORLINE, MAXCOL() - @ ERRORLINE, 20 SAY "Can't open file: (Dos Error " + STR( FERROR() ) + ") File=" + aDirList[ i, F_NAME ] + @ ERRORLINE, 20 SAY "Can't open file: (Dos Error " + STR( FERROR() ) + ") File=" + aDirList[ i, F_NAME ] LOOP ENDIF lEof := .F. @@ -211,7 +211,7 @@ FUNCTION ProcessiNg() cBuffer := STRTRAN( cBuffer, CHR( 10 ), "" ) nLineCnt ++ IF nLineCnt % 10 = 0 - @ LINELINE, 33 SAY STR( nLineCnt, 5, 0 ) + @ LINELINE, 33 SAY STR( nLineCnt, 5, 0 ) ENDIF // check to see if we are in doc mode or getting out of doc mode @@ -274,9 +274,9 @@ FUNCTION ProcessiNg() cBuffer := ReadLN( @lEof ) nLineCnt ++ // Save the function name - cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) + cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) @ MODULELINE, 33 CLEAR TO MODULELINE, MAXCOL() - @ MODULELINE, 33 SAY cFuncName + @ MODULELINE, 33 SAY cFuncName nMode := D_NORMAL @@ -342,9 +342,9 @@ FUNCTION ProcessiNg() cBuffer := ReadLN( @lEof ) nLineCnt ++ // Save the function name - cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) + cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) @ MODULELINE, 33 CLEAR TO MODULELINE, MAXCOL() - @ MODULELINE, 33 SAY cFuncName + @ MODULELINE, 33 SAY cFuncName nMode := D_NORMAL // endif @@ -352,7 +352,7 @@ FUNCTION ProcessiNg() cBuffer := ReadLN( @lEof ) nLineCnt ++ // get the category - cCategory := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) + cCategory := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) // 3) One line description @@ -730,12 +730,12 @@ FUNCTION ProcNgiInput() FT_FUSE() NEXT - @ INFILELINE, 21 SAY "Extracting: " + @ INFILELINE, 21 SAY "Extracting: " FOR x := 1 TO LEN( afuncsam ) cFile := afuncsam[ x ] - @ INFILELINE, 33 SAY PAD( cfile, 47 ) + @ INFILELINE, 33 SAY PAD( cfile, 47 ) FT_FUSE( "ngi\" + cFile ) aAlso := {} @@ -776,7 +776,7 @@ FUNCTION ProcNgiInput() FOR x := 1 TO LEN( AFUNCSN_ ) cFile := afuncsn_[ x ] - @ INFILELINE, 33 SAY PAD( cfile, 47 ) + @ INFILELINE, 33 SAY PAD( cfile, 47 ) FT_FUSE( "ngi\" + cFile ) aAlso := {} @@ -835,7 +835,7 @@ FUNCTION ProcNgiInput() .AND. UPPER( LEFT( cFile, AT( '.', cFile ) - 1 ) ) <> "STRONGTYPING"; .AND. UPPER( LEFT( cFile, AT( '.', cFile ) - 1 ) ) <> "THEGARBAGECOLLECTOR" ; .AND. UPPER( LEFT( cFile, AT( '.', cFile ) - 1 ) ) <> "THEIDLESTATES" - @ INFILELINE, 33 SAY PAD( cfile, 47 ) + @ INFILELINE, 33 SAY PAD( cfile, 47 ) FT_FUSE( "ngi\" + acfiles[ x ] ) aAlso := {} @@ -970,7 +970,6 @@ FUNCTION GenNgTable( oNgi ) LOCAL nSpace4 LOCAL aLensTItem := {} LOCAL aLensfoItem := {} - FOR X := 1 TO LEN( afitable ) IF !EMPTY( afiTable[ x ] ) AADD( aLensFItem, LEN( afiTable[ x ] ) ) @@ -1327,7 +1326,7 @@ FUNCTION ProcNGDesc( cBuffer, oNgi, cStyle ) cbuffer := cReturn ENDIF ELSE - cBuffer := FormatngBuff( cBuffer, cStyle, ongi ) + cBuffer := FormatngBuff( cBuffer, cStyle ) ENDIF ENDIF ENDIF @@ -1560,7 +1559,7 @@ RETURN nil *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNC checkngcolor( cbuffer, ncolorpos ) +FUNCTION checkngcolor( cbuffer, ncolorpos ) LOCAL ncolorend LOCAL nreturn @@ -1621,7 +1620,7 @@ RETURN max *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION FormatNgBuff( cBuffer, cStyle, ongi ) +FUNCTION FormatNgBuff( cBuffer, cStyle ) LOCAL cReturn := '' LOCAL cLine := '' @@ -1629,11 +1628,9 @@ FUNCTION FormatNgBuff( cBuffer, cStyle, ongi ) LOCAL cBuffEnd := '' LOCAL lEndBuffer := .f. LOCAL nPos + LOCAL lArgBold := .f. LOCAL LFstTableItem := .t. - - HB_SYMBOL_UNUSED( ongi ) - cReturn := cBuffer + ' ' IF AT( '', cReturn ) > 0 .OR. EMPTY( cBuffer ) IF EMPTY( cbuffer ) @@ -1731,7 +1728,6 @@ STATIC FUNCTION ReadFromTop( nh ) LOCAL cEnd := DELIM + "END" + DELIM // END keyword LOCAL cClassDoc := DELIM + "CLASSDOC" + DELIM LOCAL cBuffer := '' - LOCAL NPOS := 0 LOCAL aLocDoc := {} DO WHILE FREADline( nH, @cBuffer, 4096 ) cBuffer := TRIM( SUBSTR( cBuffer, nCommentLen ) ) @@ -1773,4 +1769,4 @@ STATIC FUNCTION GetItem( cItem, nCurdoc ) ENDIF RETURN lReturn -*+ EOF: GENNG.PRG +*+ EOF: GENNG.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/genos2.prg b/harbour/utils/hbdoc/genos2.prg index 4dac0913b6..f14cc76fe0 100644 --- a/harbour/utils/hbdoc/genos2.prg +++ b/harbour/utils/hbdoc/genos2.prg @@ -732,18 +732,17 @@ RETURN aAlso *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION Formatos2Buff( cBuffer, cStyle, ongi ) +FUNCTION Formatos2Buff( cBuffer, cStyle ) LOCAL cReturn := '' LOCAL cLine := '' + LOCAL cBuffend := '' LOCAL coline := '' LOCAL lEndBuff := .f. LOCAL nPos LOCAL lArgBold := .f. - HB_SYMBOL_UNUSED( ongi ) - cReturn := cBuffer + ' ' IF AT( '', cReturn ) > 0 .OR. EMPTY( cBuffer ) IF EMPTY( cbuffer ) @@ -834,7 +833,7 @@ RETURN cReturn *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNC checkos2color( cbuffer, ncolorpos ) +FUNCTION checkos2color( cbuffer, ncolorpos ) LOCAL ncolorend LOCAL nreturn @@ -967,6 +966,7 @@ RETURN max FUNCTION Genos2Table( oOs2 ) Local x Local cItem,cItem1 + //Local cItem2,cItem3 // Variables not used in function, it may be deleted? // oos2:WritePar( "" ) if nNumTableItems == 2 citem := str(maxos2elem(afitable),2) @@ -1080,7 +1080,7 @@ FUNCTION Procos2Desc( cBuffer, oOs2, cStyle ) ENDIF ELSE - cBuffer := Formatos2Buff( cBuffer, cStyle, oOs2 ) + cBuffer := Formatos2Buff( cBuffer, cStyle ) ENDIF ENDIF ENDIF @@ -1317,4 +1317,4 @@ STATIC FUNCTION GetItem( cItem, nCurdoc ) ENDIF RETURN lReturn -*+ EOF: GENOS2.PRG +*+ EOF: GENOS2.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/genpdf1.prg b/harbour/utils/hbdoc/genpdf1.prg index 3024d1cf38..b2e7b51c51 100644 --- a/harbour/utils/hbdoc/genpdf1.prg +++ b/harbour/utils/hbdoc/genpdf1.prg @@ -63,6 +63,9 @@ #define ERRORLINE 20 #define LONGLINE 600 #define LONGONELINE 66 +#define a4_width 595.0 +#define a4_height 842.0 + MEMVAR aDirlist MEMVAR aDocInfo,awww,aResult STATIC aAlso @@ -186,12 +189,13 @@ local hhh // loop through all of the files if lmemory // oPdf := tPdf():new( "pdf\temp.pdf" ) - HB_PDFNEW("pdf\temp.pdf") + + HB_PDFNEW("pdf\temp.pdf",,a4_height,a4_width) hb_pdfnewpage("Harbour Guide",'Harbour Guide') hb_pdfendpage() else // ? 'im here' - HB_PDFNEW("pdf\harbour.pdf") + HB_PDFNEW("pdf\harbour.pdf",,a4_height,a4_width) hb_pdfnewpage("Harbour Guide",'Harbour Guide') hb_pdfinitbook(aResult) hb_pdfendpage() @@ -832,7 +836,7 @@ FUNCTION ProcPdfTable( cBuffer, nNum ) cBuffer := STRTRAN( cbuffer, "", "" ) cBuffer := STRTRAN( cBuffer, ccolor, '' ) - nColorpos := ASCAN( aColorTable, { | x | UPPER( x[ 1 ] ) == UPPER( ccolor ) } ) + nColorpos := ASCAN( aColorTable, { | x, y | UPPER( x[ 1 ] ) == UPPER( ccolor ) } ) cColor := aColortable[ nColorPos, 2 ] ENDIF IF !EMPTY( cBuffer ) @@ -1208,7 +1212,7 @@ FUNC CheckPdfColor( cbuffer, ncolorpos ) cOldColorString := SUBSTR( cbuffer, ncolorpos ) nColorend := AT( ">", cOldColorString ) cOldColorString := SUBSTR( cOldColorString, 1, nColorEnd ) - nreturn := ASCAN( acolortable, { | x | UPPER( x[ 1 ] ) == UPPER( ccolor ) } ) + nreturn := ASCAN( acolortable, { | x, y | UPPER( x[ 1 ] ) == UPPER( ccolor ) } ) IF nreturn > 0 cReturn := "^a" + acolortable[ nreturn, 2 ] ENDIF diff --git a/harbour/utils/hbdoc/genrtf.prg b/harbour/utils/hbdoc/genrtf.prg index 25f7b96fd6..2d55e1a11a 100644 --- a/harbour/utils/hbdoc/genrtf.prg +++ b/harbour/utils/hbdoc/genrtf.prg @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * GENRTF support module for hbdoc document Extractor + * GENRTF support module for hbdoc document Extractor * * Copyright 2000 Luiz Rafael Culik * www - http://www.harbour-project.org @@ -113,7 +113,7 @@ FUNCTION ProcessRtf() LOCAL xAddBlank LOCAL nNumTopics := 0 LOCAL nCurTopics := 1 - LOCAL cBar := " " + Replicate( ')', 80 ) + LOCAL cBar := " " + replicate( ')', 80 ) LOCAL nMode LOCAL cFuncName LOCAL cOneLine @@ -179,10 +179,10 @@ FUNCTION ProcessRtf() // Entry Point // // Put up information labels - @ INFILELINE, 20 SAY "Extracting: " - @ MODULELINE, 20 SAY "Documenting: " + @ INFILELINE, 20 SAY "Extracting: " + @ MODULELINE, 20 SAY "Documenting: " // loop through all of the files - oRtf := tRtf():new( "rtf\Harbour.rtf" ):WriteHeader() + oRtf := tRtf():new( "rtf\harbour.rtf" ):WriteHeader() FOR i := 1 TO nFiles // Open file for input @@ -190,16 +190,16 @@ FUNCTION ProcessRtf() nCommentLen := IIF( AT( ".ASM", UPPER( aDirList[ i, F_NAME ] ) ) > 0, 2, 4 ) nReadHandle := FT_FUSE( aDirList[ i, F_NAME ] ) @ INFILELINE, 33 CLEAR TO INFILELINE, MAXCOL() - @ INFILELINE, 33 SAY PAD( aDirList[ i, F_NAME ], 47 ) + @ INFILELINE, 33 SAY PAD( aDirList[ i, F_NAME ], 47 ) @ MODULELINE, 33 CLEAR TO LINELINE, MAXCOL() - @ LINELINE, 27 SAY "Line:" + @ LINELINE, 27 SAY "Line:" nLineCnt := 0 IF nReadHandle < 0 WRITE_ERROR( "Can't open file: (Dos Error " + STR( FERROR() ) + ")",,,, aDirList[ i, F_NAME ] ) @ ERRORLINE, 0 CLEAR TO ERRORLINE, MAXCOL() - @ ERRORLINE, 20 SAY "Can't open file: (Dos Error " + STR( FERROR() ) + ") File=" + aDirList[ i, F_NAME ] + @ ERRORLINE, 20 SAY "Can't open file: (Dos Error " + STR( FERROR() ) + ") File=" + aDirList[ i, F_NAME ] LOOP ENDIF lEof := .F. @@ -216,7 +216,7 @@ FUNCTION ProcessRtf() cBuffer := TRIM( SUBSTR( ReadLN( @lEof ), nCommentLen ) ) nLineCnt ++ IF nLineCnt % 10 = 0 - @ LINELINE, 33 SAY STR( nLineCnt, 5, 0 ) + @ LINELINE, 33 SAY STR( nLineCnt, 5, 0 ) ENDIF // check to see if we are in doc mode or getting out of doc mode @@ -261,7 +261,7 @@ FUNCTION ProcessRtf() // oRtf:WriteKLink(aAlso,.f.) // else oRtf:WriteKLink(aAlso) -// endif +// endif ENDIF lDoc := .F. @@ -279,9 +279,9 @@ FUNCTION ProcessRtf() cBuffer := ReadLN( @lEof ) nLineCnt ++ // Save the function name - cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) + cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) @ MODULELINE, 33 CLEAR TO MODULELINE, MAXCOL() - @ MODULELINE, 33 SAY cFuncName + @ MODULELINE, 33 SAY cFuncName nMode := D_NORMAL @@ -345,9 +345,9 @@ FUNCTION ProcessRtf() cBuffer := ReadLN( @lEof ) nLineCnt ++ // Save the function name - cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) + cFuncName := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) @ MODULELINE, 33 CLEAR TO MODULELINE, MAXCOL() - @ MODULELINE, 33 SAY cFuncName + @ MODULELINE, 33 SAY cFuncName nMode := D_NORMAL @@ -358,7 +358,7 @@ FUNCTION ProcessRtf() cBuffer := ReadLN( @lEof ) nLineCnt ++ // get the category - cCategory := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) + cCategory := ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) // 3) One line description @@ -734,7 +734,7 @@ oRtf:WritePar( "" ) //:endpar() NEXT ortf:close() -RETURN NIL +RETURN oRtf:aIdh *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ @@ -876,6 +876,10 @@ FUNCTION ProcRTFDesc( cBuffer, oRtf, cStyle ) nPos := AT( " ", cReturn ) cOLine := LEFT( cReturn, nPos - 1 ) cReturn := STRTRAN( cReturn, coLine, "" ) + if "\" $ cReturn + cReturn := Strtran( cReturn, '\', '\\') +// tracelog( cReturn ) + endif IF AT( "@", cOLine ) > 0 .OR. AT( "()", cOLine ) > 0 .OR. AT( "<", cOLine ) > 0 .OR. AT( "_", cOLine ) > 0 lArgBold := .T. ELSE @@ -893,12 +897,17 @@ FUNCTION ProcRTFDesc( cBuffer, oRtf, cStyle ) ENDIF ELSE - cBuffer := FormatrtfBuff( cBuffer, cStyle, ortf ) + cBuffer := FormatrtfBuff( cBuffer, cStyle ) ENDIF ENDIF ENDIF IF AT( '', cBuffer ) > 0 .AND. AT( '', cBuffer ) > 0 + if "\" $ cBuffer + cBuffer := Strtran(cBuffer, '\', '\\') +// tracelog( cBuffer ) + endif + cBuffer := STRTRAN( cBuffer, '', '' ) cBuffer := STRTRAN( cBuffer, '', '\b ' ) cBuffer := STRTRAN( cBuffer, '', '\b0 ' ) @@ -1052,7 +1061,7 @@ FUNCTION GenRtfTable( oRtf ) LOCAL x LOCAL lCar := .f. LOCAL nMax2 - LOCAL nPos2 + LOCAL nPos2 LOCAL nPos LOCAL aLensFItem := {} LOCAL aLensSItem := {} @@ -1072,11 +1081,11 @@ FUNCTION GenRtfTable( oRtf ) nPos := maxrtfelem( afitable ) nPos2 := ASCAN( alensfitem, { | x | x == nPos } ) - oRtf:WriteParBox( " " + Replicate( CHR( 196 ), 80 ) ) + oRtf:WriteParBox( " " + replicate( CHR( 196 ), 80 ) ) FOR x := 1 TO LEN( afiTable ) ortf:WriteParFixed( IF( AT( "|", afiTable[ x ] ) > 0, STRTRAN( afiTable[ x ], "|", " " ), afiTable[ x ] ), '\fi-426\li426' ) NEXT - oRtf:WriteParBox( " " + Replicate( CHR( 196 ), 80 ) ) + oRtf:WriteParBox( " " + replicate( CHR( 196 ), 80 ) ) // oRtf:WritePar( "" ) afiTable := {} @@ -1152,7 +1161,7 @@ RETURN max *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION FormatrtfBuff( cBuffer, cStyle, ongi ) +FUNCTION FormatrtfBuff( cBuffer, cStyle ) LOCAL cReturn := '' LOCAL cLine := '' @@ -1161,9 +1170,6 @@ FUNCTION FormatrtfBuff( cBuffer, cStyle, ongi ) LOCAL lEndBuff := .f. LOCAL nPos LOCAL lArgBold := .f. - - HB_SYMBOL_UNUSED( ongi ) - creturn := cBuffer + ' ' IF AT( '', creturn ) > 0 .OR. EMPTY( cBuffer ) IF EMPTY( cbuffer ) @@ -1308,4 +1314,4 @@ RETURN lReturn // / -*+ EOF: GENRTF.PRG +*+ EOF: GENRTF.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/gentrf.prg b/harbour/utils/hbdoc/gentrf.prg index 1baf098d92..e6d9c69661 100644 --- a/harbour/utils/hbdoc/gentrf.prg +++ b/harbour/utils/hbdoc/gentrf.prg @@ -57,7 +57,6 @@ #include "directry.ch" #include "fileio.ch" #include "inkey.ch" -#include "common.ch" // output lines on the screen diff --git a/harbour/utils/hbdoc/hbdoc.prg b/harbour/utils/hbdoc/hbdoc.prg index 56460bbf39..93af48e231 100644 --- a/harbour/utils/hbdoc/hbdoc.prg +++ b/harbour/utils/hbdoc/hbdoc.prg @@ -1,13 +1,13 @@ /* - * $Id$ + * $Id$ */ /* - * Harbour Project source code: + * xHarbour Project source code: * HBDOC document Extractor * - * Copyright 1999-2001 Luiz Rafael Culik - * www - http://www.harbour-project.org + * Copyright 1999-2003 Luiz Rafael Culik + * www - http://www.xharbour.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -128,9 +128,12 @@ // The delimiter MEMVAR aDirList MEMVAR aDocInfo +MEMVAR aDocwwwInfo +MEMVAR aClassList MEMVAR aLinkInfo MEMVAR aAuthorList MEMVAR lAscii +MEMVAR lTee MEMVAR lContinuous MEMVAR lAuthor MEMVAR lRtf @@ -138,11 +141,15 @@ MEMVAR lNgi MEMVAR lOs2 MEMVAR lPdf MEMVAR lWww +MEMVAR lWww2 MEMVAR lChm +MEMVAR lChm2 MEMVAR lNorton MEMVAR aWWW MEMVAR lTroff MEMVAR aResult +MEMVAR theHandle + STATIC cTitle:='' /* @@ -160,23 +167,39 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) // NG/EH input LOCAL aExtensions := { "*.ch", "*.prg", "*.c", "*.asm", "*.txt" } - LOCAL i - Local cLast + LOCAL i, j + LOCAL cLast LOCAL nItem LOCAL nHpj LOCAL cItem:='' - + LOCAL cFName + LOCAL cLName + LOCAL aName + LOCAL nLen + LOCAL lDone + LOCAL cMI + LOCAL oHtmIndex + LOCAL cFileName + LOCAL cCompiler // Compiler type LOCAL oHtm LOCAL oHtm1 + LOCAL nPos LOCAL ppp LOCAL aMetaContents:={} Local aTemp:={} LOCAL lAdded:=.f. + Local aRtfid + + LOCAL nCount_1 := 1 + LOCAL nCount_2 := 1 + PUBLIC theHandle PUBLIC aDirList PUBLIC aDocInfo := {} + PUBLIC aDocWwwInfo := {} + PUBLIC aClassList := {} PUBLIC aLinkInfo := {} PUBLIC aAuthorList := {} PUBLIC lAscii := .F. // Create ascii output instead of NG/EH input @@ -187,10 +210,13 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) PUBLIC lOs2 := .F. PUBLIC lPdf := .F. PUBLIC lWww := .F. + PUBLIC lWww2 := .F. PUBLIC lChm := .F. + PUBLIC lChm2 := .F. PUBLIC lNorton := .F. + PUBLIC lTee := .F. PUBLIC aWWW := {} - PUBLIC aResult:={} + PUBLIC aResult := {} PUBLIC lTroff := .f. // The following variables are used to allow one to change the delimiter @@ -208,11 +234,13 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) // See if flag is there - IF .NOT. EMPTY( cFlags ) + IF .NOT. EMPTY( cFlags ) IF LEFT( cFlags, 1 ) == "-" .OR. LEFT( cFlags, 1 ) == "/" IF ( cFlags := UPPER( RIGHT( cFlags, 3 ) ) ) == "TXT" lAscii := .T. lContinuous := .F. + ELSEIF cFlags = "TEE" + lTee := .T. ELSEIF cFlags = "HPC" lNorton := .T. ELSEIF cFlags = "NGI" @@ -223,11 +251,14 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) lRtf := .T. ELSEIF cFlags = "HTM" lWww := .T. + ELSEIF cFlags = "HT2" + lWww2 := .T. ELSEIF cFlags = "PDF" lPdf := .T. - ELSEIF cFlags = "CHM" lChm := .T. + ELSEIF cFlags = "CH2" + lChm2 := .T. ELSEIF cFlags = "TRF" lTroff := .t. ELSEIF cFlags = "DOC" @@ -244,28 +275,31 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) // Get the linkfile name and get the info in it IF cLinkName = NIL - ?? "Harbour Doc Extractor" - ? "Copyright 1999-2001, http://www.harbour-project.org" - ? "" - ? "Syntax: hbdoc [options] []" - ? "" - ? "Options: /txt Create an ASCII file instead of a Norton Guide" - ? " /con Create an ASCII file without formfeeds" - ? " /hpc Helpc source file" - ? " /ngi Adds the -NG switch to EHC command for compile for" - ? " DOS/Windows/Linux." - ? " /rtf Winhelp source code for Windows" - ? " /os2 OS/2 help source code For OS/2" - ? " /htm Generate HTML output" - ? " /chm Generate HTML source files for Windows .CHM Help files" - ? " /pdf Generate an Adobe Portable Document (.PDF)" - ? " /trf Gerenate Linux TROFF code" - ? " /doc Create continuous ASCII file w/o author information" - ? " " - ? "Notes: - Only one option can be specified at a time." - ? " - is the name of the Norton Guide Link file." - ? " - is a file containing a list of files to process" - ? " otherwise *.prg, *.c, *.asm, *.ch and *.txt are used." + outstd( "Harbour Doc Extractor"+ hb_osnewline() ) + outstd( "Copyright 1999-2005, http://www.harbour-project.org"+ hb_osnewline() ) + outstd( ""+ hb_osnewline() ) + outstd( "Syntax: hbdoc [options] []"+ hb_osnewline() ) + outstd( ""+ hb_osnewline() ) + outstd( "Options: /txt Create an ASCII file instead of a Norton Guide"+ hb_osnewline() ) + outstd( " /con Create an ASCII file without formfeeds"+ hb_osnewline() ) + outstd( " /hpc Helpc source file"+ hb_osnewline() ) + outstd( " /ngi Adds the -NG switch to EHC command for compile for"+ hb_osnewline() ) + outstd( " DOS/Windows/Linux."+ hb_osnewline() ) + outstd( " /rtf Winhelp source code for Windows"+ hb_osnewline() ) + outstd( " /os2 OS/2 help source code For OS/2"+ hb_osnewline() ) + outstd( " /htm Generate HTML output"+ hb_osnewline() ) + outstd( " /ht2 Generate HTML output (new doc model)"+ hb_osnewline() ) + outstd( " /chm Generate HTML source files for Windows .chm Help files"+ hb_osnewline() ) + outstd( " /ch2 Generate HTML source files for Windows .chm Help files"+ hb_osnewline() ) + outstd( " (new doc model)"+ hb_osnewline() ) + outstd( " /pdf Generate an Adobe Portable Document (.PDF)"+ hb_osnewline() ) + outstd( " /trf Gerenate Linux TROFF code"+ hb_osnewline() ) + outstd( " /doc Create continuous ASCII file w/o author information"+ hb_osnewline() ) + outstd( " "+ hb_osnewline() ) + outstd( "Notes: - Only one option can be specified at a time."+ hb_osnewline() ) + outstd( " - is the name of the Norton Guide Link file."+ hb_osnewline() ) + outstd( " - is a file containing a list of files to process"+ hb_osnewline() ) + outstd( " otherwise *.prg, *.c, *.asm, *.ch and *.txt are used."+ hb_osnewline() ) RETURN NIL ENDIF @@ -297,16 +331,22 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) IF EMPTY( DIRECTORY( "htm.*", "D" ) ) FT_MKDIR( "htm" ) ENDIF + ELSEIF lWww2 + IF EMPTY( DIRECTORY( "htm.*", "D" ) ) + FT_MKDIR( "htm" ) + ENDIF ELSEIF lChm IF EMPTY( DIRECTORY( "chm.*", "D" ) ) FT_MKDIR( "chm" ) ENDIF - + ELSEIF lChm2 + IF EMPTY( DIRECTORY( "chm.*", "D" ) ) + FT_MKDIR( "chm" ) + ENDIF ELSEIF lPdf IF EMPTY( DIRECTORY( "pdf.*", "D" ) ) FT_MKDIR( "pdf" ) ENDIF - ELSEIF lNgi IF EMPTY( DIRECTORY( "ngi.*", "D" ) ) FT_MKDIR( "ngi" ) @@ -320,10 +360,21 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) IF EMPTY( DIRECTORY( "ipf.*", "D" ) ) FT_MKDIR( "ipf" ) ENDIF + ELSEIF lAscii + IF EMPTY( DIRECTORY( "txt.*", "D" ) ) + FT_MKDIR( "txt" ) + ENDIF + ELSEIF lTee + IF EMPTY( DIRECTORY( "teesrcs.*", "D" ) ) + FT_MKDIR( "teesrcs" ) + ENDIF + IF EMPTY( DIRECTORY( "teedocs.*", "D" ) ) + FT_MKDIR( "teedocs" ) + ENDIF ENDIF if lNgi .or. lRtf cCompiler := fill_Link_info( cLinkName ) - endif + endif IF cAtFile = NIL // use all files in directory @@ -342,10 +393,13 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) IF lAscii ASCIIFiles() + ELSEIF lTee + TeeFiles() ELSEIF lNorton ProcessFiles() ELSEIF lRtf - ProcessRtf() + aRtfid := ProcessRtf() +// tracelog(aRtfid,aRtfid[1]) ELSEIF lPdf #ifdef PDF ProcessPDF(.t.) @@ -353,8 +407,12 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) #endif ELSEIF lWww ProcessWww() + ELSEIF lWww2 + ProcessWww2() ELSEIF lChm ProcessChm() + ELSEIF lChm2 + ProcessChm2() ELSEIF lNgi ProcessiNg() ELSEIF lTroff @@ -383,11 +441,16 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) ProcessPDF(.f.) #endif ELSEIF lRtf - ProcessRtf() + aRtfid := ProcessRtf() +// tracelog(aRtfid,aRtfid[1]) ELSEIF lWww ProcessWww() + ELSEIF lWww2 + ProcessWww2() ELSEIF lChm ProcessChm() + ELSEIF lChm2 + ProcessChm2() ELSEIF lNgi ProcessiNg() ELSEIF lTroff @@ -402,34 +465,36 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) // Now build text files for norton compiler based upon link file // first sort based upon category and filename. Not Fast but easy. + @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() @ MODULELINE, 0 CLEAR TO MODULELINE, MAXCOL() @ LINELINE, 0 CLEAR TO LINELINE, MAXCOL() - @ INFILELINE, 30 SAY "Sorting input files" + @ INFILELINE, 30 SAY "Sorting input files" ASORT( aDocInfo,,, { | a, b | UPPER( a[ 1 ] + " " + a[ 2 ] ) < UPPER( b[ 1 ] + " " + b[ 2 ] ) } ) + // Now actually build the info @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() IF lnorton - @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "HelpC" ) ; + @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "HelpC" ) ; + " input files" ELSEIF lRTF - @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "WINHELP" ) ; + @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "WINHELP" ) ; + " input files" ELSEIF lPdf - @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "Adobe Portable Document Format" ) ; + @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "Adobe Portable Document Format" ) ; + " input files" ELSEIF lWww .or. lChm - @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "Html" ) ; + @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "Html" ) ; + " input files" ELSEIF lNgi - @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "NG" ) ; + @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "NG" ) ; + " input files" ELSEIF lTroff - @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "TROFF" ) ; + @ INFILELINE, 30 SAY "Assembling " + IIF( lAscii, "documentation", "TROFF" ) ; + " input files" ENDIF @@ -455,11 +520,11 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) IF i = 1 .OR. .NOT. ( ALLTRIM( aDocInfo[ i - 1, 1 ] ) == ALLTRIM( aDocInfo[ i, 1 ] ) ) // Make the first copy ? "ECHO Creating", aLinkinfo[ nItem, 2 ] - ? "COPY hdf/" + ALLTRIM( aDocInfo[ i, 4 ] ) + " HarDoc.hdf > NUL" + ? "COPY hdf\" + ALLTRIM( aDocInfo[ i, 4 ] ) + " HarDoc.hdf > NUL" ELSE // This may be slow but I don't have to worry about line length - ? "TYPE hdf/" + ALLTRIM( aDocInfo[ i, 4 ] ) + " >> HarDoc.hdf " + ? "TYPE hdf\" + ALLTRIM( aDocInfo[ i, 4 ] ) + " >> HarDoc.hdf " ENDIF aLinkInfo[ nItem, 3 ] = .T. ELSE @@ -469,7 +534,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) SET CONSOLE ON WRITE_ERROR( "Category not found: " + aDocInfo[ i, 1 ],,,, aDocInfo[ i, 4 ] ) @ ERRORLINE, 0 CLEAR TO ERRORLINE, MAXCOL() - @ ERRORLINE, 20 SAY "Category not found: " + aDocInfo[ i, 1 ] + " in " + aDocInfo[ i, 4 ] + @ ERRORLINE, 20 SAY "Category not found: " + aDocInfo[ i, 1 ] + " in " + aDocInfo[ i, 4 ] SET ALTERNATE TO "assembl.bat" ADDITIVE SET ALTERNATE ON SET CONSOLE OFF @@ -486,20 +551,32 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) FWRITE( nHpj, 'CONTENTS=IDH_OVERVIEW' + CRLF ) FWRITE( nHpj, 'TITLE='+cTitle + CRLF ) FWRITE( nHpj, 'COPYRIGHT=Harbour (C) http://www.harbour-project.org' + CRLF ) - FWRITE( nHpj, 'HLP=./'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hlp"+ CRLF ) - FWRITE( nHpj, 'ROOT=/' + CURDIR() + "/RTF" + CRLF ) - FWRITE( nHpj, 'CNT=./'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".cnt"+ CRLF ) + FWRITE( nHpj, 'HLP=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hlp"+ CRLF ) + FWRITE( nHpj, 'ROOT=\' + CURDIR() + "\RTF" + CRLF ) + FWRITE( nHpj, 'CNT=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".cnt"+ CRLF ) FWRITE( nHpj, '[FILES]' + CRLF ) FWRITE( nHpj, "harbour.rtf" + CRLF ) FWRITE( nHpj, '[CONFIG]' + CRLF + 'contents()' + CRLF + 'prev()' + CRLF + 'next()' + CRLF + 'BrowseButtons()' + CRLF ) - FWRITE( nHpj, '[WINDOWS]' + CRLF + 'Commands="Harbour Commands",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +'API="Harbour Commands",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF + 'Error="Harbour Run Time Errors",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF + 'Tools="Harbour Tools",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF + 'Class="Harbour OOP Commands",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF + 'Funca="Harbour Run Time Functions A-M",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF + 'Funcn="Harbour Run Time Functions N-_",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF + 'Main="HARBOUR",(117,100,894,873),60672,(r14876671),(r12632256),f2' + CRLF ) + FWRITE( nHpj, '[WINDOWS]' + CRLF + 'Commands="Harbour Commands",(653,102,360,600),20736,(r14876671),(r12632256),f2' +; + CRLF +'API="Harbour Commands",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +; + 'Error="Harbour Run Time Errors",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +; + 'Tools="Harbour Tools",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +; + 'Class="Harbour OOP Commands",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +; + 'Funca="Harbour Run Time Functions A-M",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +; + 'Funcn="Harbour Run Time Functions N-_",(653,102,360,600),20736,(r14876671),(r12632256),f2' + CRLF +; + 'Main="Harbour",(117,100,894,873),60672,(r14876671),(r12632256),f2' + CRLF ) + FWRITE( nHpj, '[MAP]'+CRLF) + for each ppp in aRtfid + fwrite(nHpj, "#define "+ppp[1] +" " + str(ppp[2])+CRLF) + next + FCLOSE( nHpj ) nHpj := FCREATE( lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".cnt" ) FWRITE( nHpj, ':Base '+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hlp"+ CRLF ) FWRITE( nHpj, ':Title '+cTitle+CRLF) FWRITE( nHpj, ':Index '+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +'='+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hlp"+ CRLF ) FWRITE( nHpj, '1 Harbour'+CRLF) - asort(aWww,,,{|x,y| x[3]+x[1]Main"+CRLF) @@ -528,7 +605,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) for ppp:=1 to nItem cLast:=GetNextContent(ppp) - if cLast<>'Run Time Errors' .and. cLast <>"Document" .and. cLast <>"The garbage collector" .and. cLast <>"OOP Command" .and. cLast <>"Command" .and. cLast <>"The idle states" + if cLast =='Statement' .or. cLast =="Command" WriteContentFile(aWww,cLast,nHpj) endif Next @@ -551,16 +628,18 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) fWrite( nHpj, '2 '+aWww[ppp,1]+"="+aWww[ppp,2]+">API"+CRLF) endif Next - fClose(nHpj) -set console off - ELSEIF lWWW + + fClose(nHpj) + set console off + ELSEIF lWWW + ASORT( aDocWWWInfo,,, { | a, b | UPPER( a[ 1 ] ) < UPPER( b[ 1 ]) } ) asort(adocinfo,,,{|x,y| x[1]+x[2]'+adocinfo[1,1]+'
') ohtm:WriteText("
' + afitable[ x ] + '' + asitable[ x ] + '
' + afitable[ x ] + '' + asitable[ x ] + '
' + afitable[ x ] + '' + asitable[ x ] + '' + atitable[ x ] + '
' + afitable[ x ] + '' + asitable[ x ] + '' + atitable[ x ] + '
' + afitable[ x ] + '' + asitable[ x ] + '' + atitable[ x ] + '' + afoitable[ x ] + '
' + afitable[ x ] + '' + asitable[ x ] + '' + atitable[ x ] + '' + afoitable[ x ] + '
") @@ -576,7 +655,7 @@ set console off AADD(aMetaContents,{"GENERATOR","HBDOC Harbour document Extractor"}) aadd(aMetaContents,{'Keywords',"Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin,"+cItem}) - ohtm:=THTML():new('htm/hb'+strtran(adocinfo[ppp,1]," ","")+'.htm',aMetaContents) + ohtm:=THTML():new('htm\hb'+strtran(adocinfo[ppp,1]," ","")+'.htm',aMetaContents) // oHtm:WriteMetaTag('Keywords',"Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin,"+cItem) ohtm:WriteText('

'+adocinfo[ppp,1]+'


') @@ -594,11 +673,11 @@ set console off AADD(aMetaContents,{"GENERATOR","HBDOC Harbour document Extractor"}) aadd(aMetaContents,{'Keywords',"Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin,"+cItem}) - oHtm1 := THTML():New( "htm/harbour.htm" ,aMetaContents) + oHtm1 := THTML():New( "htm\harbour.htm" ,aMetaContents) // oHtm:WriteMetaTag('Keywords',"Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin,Harbour Documentation") oHtm1:WriteTitle( "Harbour Reference Guide" ) oHtm1:WriteText( "

Harbour Reference Guide

" ) - oHtm1:WriteText( "

HARBOUR

" + hb_osnEwline() + '
    ' ) + oHtm1:WriteText( "

    Harbour

    " + hb_osnEwline() + '
      ' ) oHtm1:WriteLink( "overview", UpperLower( "Harbour Read me" ) ) oHtm1:WriteLink( "license", UpperLower( "Harbour License" ) ) oHtm1:WriteLink( "http://www.gnu.org/copyleft/gpl.html", "GNU License" ) @@ -606,6 +685,7 @@ set console off oHtm1:WriteLink( "harbourextensions.htm", "Harbour Extensions" ) oHtm1:WriteLink( "thegarbagecollector.htm", "The Garbage Collector" ) oHtm1:WriteLink( "theidlestates.htm", "The Idle States" ) + ohtm1:WriteLink( "http://www.harbour-project.org","Harbour.org Web page") oHtm1:WriteText( "
    " ) oHtm1:WriteText( "

    Alphabetical list of functions by Categorie

    " ) ohtm1:writetext('
      ') @@ -615,25 +695,110 @@ set console off for ppp:=1 to nItem cLast:=GetNextContent(ppp) - if cLast<>'Run Time Errors' .and. cLast <>"Document" .and. cLast <>"The garbage collector" .and. cLast <>"OOP Command" .and. cLast <>"Command" .and. cLast <>"The idle states" + if (cLast<>'Run Time Errors' .and. cLast <>"Document" .and. cLast <>"The garbage collector" .and. cLast <>"The idle states") .and. (cLast != "Command" .and. clast !="OOP Command" .and. cLast !="Statement") .and. (! "CLASS" $ UPPER(cLast) .and. !"METHOD" $ UPPER(cLast)) ohtm1:WriteLink('hb'+strtran(aResult[ppp]," ","")+'.htm',aResult[ppp]) endif Next - ohtm1:writetext('
    ') + ohtm1:writetext('
') + + oHtm1:WriteText( "

Commands and Statements

" ) + ohtm1:writetext('
    ') + + for ppp:=1 to nItem + + cLast:=GetNextContent(ppp) + if cLast == "Command" .or. clast =="OOP Command" .or. cLast =="Statement" + ohtm1:WriteLink('hb'+strtran(aResult[ppp]," ","")+'.htm',aResult[ppp]) + + endif + Next + ohtm1:writetext('
') + + + oHtm1:WriteText( "

Classes and method

" ) + ohtm1:writetext('
    ') + + for ppp:=1 to nItem + + cLast:=GetNextContent(ppp) + if "CLASS" $ UPPER(cLast) .or. "METHOD" $ UPPER(cLast) + ohtm1:WriteLink('hb'+strtran(aResult[ppp]," ","")+'.htm',aResult[ppp]) + + endif + Next + ohtm1:writetext('
') + ohtm1:close() + ohtm1:close() + + oHtm:Close() + + + ohtm:=THTML():new("htm\harbourfuntionwithsyntax.htm",aMetaContents) + For each ppp in aDocwwwInfo + ohtm:Writelink(ppp[2],ppp[1]) + next + ohtm:close() + + ELSEIF lWww2 + cFileName := "index.htm" + oHtmIndex := THTML():New('htm\' + cFileName) + + // Add title to HTML + oHtmIndex:WriteText("Harbour - Reference Guide") + + // Add CSS to the HTML + oHtmIndex:WriteText("") + + oHtmIndex:WriteText("
Harbour Reference Guide
") + + ASORT(aDocInfo,,, {|x, y| UPPER(x[1]) < UPPER(y[1])}) + + oHtmIndex:WriteText("
Alphabetical list of classes
") + oHtmIndex:WriteText("
") + FOR i := 1 TO LEN(aDocInfo) + IF aDocInfo[i][3] = "C1" + oHtmIndex:WriteText("» " + aDocInfo[i][1] + "
") + END IF + NEXT + oHtmIndex:WriteText("
") + + oHtmIndex:WriteText("
Alphabetical list of functions
") + oHtmIndex:WriteText("
") + FOR i := 1 TO LEN(aDocInfo) + IF aDocInfo[i][3] = "F1" + oHtmIndex:WriteText("» " + aDocInfo[i][1] + "
") + ENDIF + NEXT + oHtmIndex:WriteText("
") + + oHtmIndex:WriteText("
Alphabetical list of WinAPI functions
") + oHtmIndex:WriteText("
") + FOR i := 1 TO LEN(aDocInfo) + IF aDocInfo[i][3] = "F2" + oHtmIndex:WriteText("» " + aDocInfo[i][1] + "
") + END IF + NEXT + oHtmIndex:WriteText("
") + oHtmIndex:WriteText("") ELSEIF lChm - nHpj := FCREATE( 'chm/'+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhp" ) + + nHpj := FCREATE( 'chm\'+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhp" ) FWRITE( nHpj, '[OPTIONS]' + CRLF ) FWRITE( nHpj, 'Compatibility=1.1 or later'+CRLF) FWRITE( nHpj, 'Auto Index=Yes'+CRLF) FWRITE( nHpj,'Full-text search=Yes'+CRLF) FWRITE( nHpj, 'Language=0x416 Português (brasileiro)' + CRLF ) - FWRITE( nHpj, 'Contents file=./'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc"+ CRLF ) - FWRITE( nHpj, 'Compiled file=./'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".chm"+ CRLF ) + FWRITE( nHpj, 'Contents file=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc"+ CRLF ) + FWRITE( nHpj, 'Compiled file=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".chm"+ CRLF ) FWRITE( nHpj, 'Display compile progress=No'+CRLF) nPos:=aScan(awww,{|x| Upper(x[1])="OVERVIEW"}) if nPos > 0 @@ -649,7 +814,7 @@ set console off - ohtm:=THTML():NewContent('chm/'+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc") + ohtm:=THTML():NewContent('chm\'+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc") ohtm:WriteText('') ohtm:Addobject("text/site properties") oHtm:AddParam("FrameName","Ajuda") @@ -657,7 +822,7 @@ set console off ohtm:WriteText("
    ") oHtm:ListItem() oHtm:AddObject("text/sitemap") - oHTm:AddParam('Name','HARBOUR') + oHTm:AddParam('Name','Harbour') ohtm:EndObject() ohtm:WriteText("
      ") writeChmContentFile(aDocinfo,"Document",oHtm) @@ -710,7 +875,7 @@ set console off oHtm:AddObject("text/sitemap") oHTm:AddParam('Name',cLast) ohtm:EndObject() - ohtm:WriteText("
        ") + ohtm:WriteText("
          ") endif if cLast<>'Run Time Errors' .and. cLast <>"Document" .and. cLast <>"The garbage collector" .and. cLast <>"OOP Command" .and. cLast <>"Command" .and. cLast <>"The idle states" // oHtm:WriteText( "
            " ) @@ -753,7 +918,231 @@ set console off oHtm:WriteText( "
          " ) ohtm:WriteText("
        ") ohtm:close() + + ELSEIF lChm2 + cFileName := "index.htm" + oHtmIndex := THTML():New('chm\' + cFileName) + + // Add title to HTML + oHtmIndex:WriteText("Harbour - Reference Guide") + + // Add CSS to the HTML + oHtmIndex:WriteText("") + + oHtmIndex:WriteText("
        Harbour Reference Guide
        ") + + ASORT(aDocInfo,,, {|x, y| x[1] < y[1]}) + + oHtmIndex:WriteText("
        Alphabetical list of classes
        ") + oHtmIndex:WriteText("
        ") + FOR i := 1 TO LEN(aDocInfo) + IF aDocInfo[i][3] = "C1" + oHtmIndex:WriteText("» " + aDocInfo[i][1] + "
        ") + END IF + NEXT + oHtmIndex:WriteText("
        ") + oHtmIndex:WriteText("
        Alphabetical list of functions
        ") + oHtmIndex:WriteText("
        ") + FOR i := 1 TO LEN(aDocInfo) + IF aDocInfo[i][3] = "F1" + oHtmIndex:WriteText("» " + aDocInfo[i][1] + "
        ") + END IF + NEXT + oHtmIndex:WriteText("
        ") + + oHtmIndex:WriteText("
        Alphabetical list of WinAPI functions
        ") + oHtmIndex:WriteText("
        ") + FOR i := 1 TO LEN(aDocInfo) + IF aDocInfo[i][3] = "F2" + oHtmIndex:WriteText("» " + aDocInfo[i][1] + "
        ") + END IF + NEXT + oHtmIndex:WriteText("
        ") + oHtmIndex:WriteText("") + + nHpj := FCREATE('chm\' + LOWER(SUBSTR(cLinkName,1,AT(".",cLinkName)-1)) +".hhp" ) + FWRITE( nHpj, '[OPTIONS]' + CRLF ) + FWRITE( nHpj, 'Compatibility=1.1 or later'+CRLF) + FWRITE( nHpj, 'Auto Index=Yes'+CRLF) + FWRITE( nHpj, 'Full-text search=Yes'+CRLF) + FWRITE( nHpj, 'Language=0x416 Português (brasileiro)' + CRLF ) + FWRITE( nHpj, 'Contents file=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc"+ CRLF ) + FWRITE( nHpj, 'Compiled file=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".chm"+ CRLF ) + FWRITE( nHpj, 'Display compile progress=No'+CRLF) + //nPos := aScan(aDocInfo, {|x| Upper(x[2] + ".HTM") = "OVERVIEW"}) + //if nPos > 0 + FWRITE( nHpj,'Default topic=index.htm' + CRLF) + //Else + //FWRITE( nHpj,'Default topic=' + lower(aDocInfo[1,2]) + CRLF) + //Endif + FWRITE( nHpj, '[FILES]' + CRLF ) + For nPos:=1 to len(aDocInfo) + FWRITE( nHpj, lower(aDocInfo[npos,2]) + CRLF ) + Next + FCLOSE( nHpj ) + + + oHtm:=THTML():NewContent('chm\'+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc") + oHtm:WriteText('') + oHtm:Addobject("text/site properties") + oHtm:AddParam("FrameName","Ajuda") + oHtm:EndObject() + oHtm:WriteText("
          ") + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name','Harbour Reference Guide') + oHtm:EndObject() + oHtm:WriteText("
            ") + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', 'Alphabetical list of classes') + oHtm:AddParam('Local', 'index.htm') + oHtm:EndObject() + oHtm:WriteText("
              ") + + ASORT(aDocInfo,,, {|x, y| UPPER(x[1]) < UPPER(y[1])}) + nCount_1 := 1 + DO WHILE nCount_1 <= LEN(aDocInfo) + IF aDocInfo[nCount_1][3] = "C1" + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', aDocInfo[nCount_1][1]) + oHtm:AddParam('Local', aDocInfo[nCount_1][2]) + oHtm:EndObject() + oHtm:WriteText("
                ") + + + IF LEN(aDocInfo[nCount_1][4]) > 0 + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', "Methods") + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#methodlist") + oHtm:EndObject() + oHtm:WriteText("
                  ") + ASORT(aDocInfo[nCount_1][4],,, {|x, y| UPPER(x[1]) < UPPER(y[1]) .AND. UPPER(x[2]) < UPPER(y[2]) }) + nCount_2 := 1 + DO WHILE nCount_2 <= LEN(aDocInfo[nCount_1][4]) + IF aDocInfo[nCount_1][4][nCount_2, 1] = "Method" + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#" + aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:EndObject() + ENDIF + + nCount_2 ++ + ENDDO + oHtm:WriteText("
                ") + ENDIF + + IF LEN(aDocInfo[nCount_1][4]) > 0 + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', "Properties") + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#methodlist") + oHtm:EndObject() + oHtm:WriteText("
                  ") + ASORT(aDocInfo[nCount_1][4],,, {|x, y| UPPER(x[1]) < UPPER(y[1]) .AND. UPPER(x[2]) < UPPER(y[2]) }) + nCount_2 := 1 + DO WHILE nCount_2 <= LEN(aDocInfo[nCount_1][4]) + IF aDocInfo[nCount_1][4][nCount_2, 1] = "Data" + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#" + aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:EndObject() + ENDIF + + nCount_2 ++ + ENDDO + oHtm:WriteText("
                ") + ENDIF + oHtm:WriteText("
              ") + ENDIF + nCount_1 ++ + ENDDO + oHtm:WriteText("
            ") + + // WinAPI functions + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', 'Alphabetical list of WinAPI functions') + oHtm:AddParam('Local', 'index.htm') + oHtm:EndObject() + oHtm:WriteText("
              ") + + ASORT(aDocInfo,,, {|x, y| UPPER(x[1]) < UPPER(y[1])}) + nCount_1 := 1 + DO WHILE nCount_1 <= LEN(aDocInfo) + IF aDocInfo[nCount_1][3] = "F2" + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', aDocInfo[nCount_1][1]) + oHtm:AddParam('Local', aDocInfo[nCount_1][2]) + oHtm:EndObject() + //oHtm:WriteText("
                ") + + /* + IF LEN(aDocInfo[nCount_1][4]) > 0 + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', "Methods") + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#methodlist") + oHtm:EndObject() + oHtm:WriteText("
                  ") + ASORT(aDocInfo[nCount_1][4],,, {|x, y| UPPER(x[1]) < UPPER(y[1]) .AND. UPPER(x[2]) < UPPER(y[2]) }) + nCount_2 := 1 + DO WHILE nCount_2 <= LEN(aDocInfo[nCount_1][4]) + IF aDocInfo[nCount_1][4][nCount_2, 1] = "Method" + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#" + aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:EndObject() + ENDIF + + nCount_2 ++ + ENDDO + oHtm:WriteText("
                ") + ENDIF + + IF LEN(aDocInfo[nCount_1][4]) > 0 + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', "Properties") + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#methodlist") + oHtm:EndObject() + oHtm:WriteText("
                  ") + ASORT(aDocInfo[nCount_1][4],,, {|x, y| UPPER(x[1]) < UPPER(y[1]) .AND. UPPER(x[2]) < UPPER(y[2]) }) + nCount_2 := 1 + DO WHILE nCount_2 <= LEN(aDocInfo[nCount_1][4]) + IF aDocInfo[nCount_1][4][nCount_2, 1] = "Data" + oHtm:ListItem() + oHtm:AddObject("text/sitemap") + oHtm:AddParam('Name', aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:AddParam('Local', LEFT(aDocInfo[nCount_1][2], LEN(aDocInfo[nCount_1][2]) - 4) + "_content.htm#" + aDocInfo[nCount_1][4][nCount_2, 2]) + oHtm:EndObject() + ENDIF + + nCount_2 ++ + ENDDO + oHtm:WriteText("
                ") + ENDIF + */ + //oHtm:WriteText("
              ") + ENDIF + nCount_1 ++ + ENDDO + oHtm:WriteText("
            ") + + oHtm:WriteText("
          ") + oHtm:WriteText("
        ") + oHtm:Close() ELSEIF lNgi SET ALTERNATE TO "assembl.bat" ADDITIVE @@ -789,11 +1178,11 @@ set console off SET ALTERNATE TO "assembl.bat" ADDITIVE SET ALTERNATE ON SET CONSOLE OFF - ? 'Copy ngi/overview.ngi .' - ? 'Copy ngi/License.ngi .' - ? 'Copy ngi/Funcam.txt .' - ? 'Copy ngi/funcn_.txt .' - ? 'copy ngi/comm.txt .' + ? 'Copy ngi\overview.ngi .' + ? 'Copy ngi\License.ngi .' + ? 'Copy ngi\Funcam.txt .' + ? 'Copy ngi\funcn_.txt .' + ? 'copy ngi\comm.txt .' ? 'Compiling Sources' ? 'ngxc overview.ngi' ? 'ngxc license.ngi' @@ -802,12 +1191,12 @@ set console off ? 'ngxc comm.txt' ? 'Linking the Guide' ? 'ngxl '+cLinkName - ? 'del ngi/*.*' + ? 'del ngi\*.*' ? 'del *.ngo' ENDIF @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() - @ INFILELINE, 30 SAY "Writing summary file" + @ INFILELINE, 30 SAY "Writing summary file" ENDIF @@ -815,13 +1204,13 @@ set console off SET ALTERNATE ON SET CONSOLE OFF FOR i := 1 TO LEN( aDocInfo ) - ? PAD( aDocInfo[ i, 1 ], 15 ), PAD( aDocInfo[ i, 2 ], 15 ), PAD( aDocInfo[ i, 4 ], 15 ) + ? PAD( aDocInfo[ i, 1 ], 15 ), PAD( aDocInfo[ i, 2 ], 15 ), PAD( aDocInfo[ i, 3 ], 15 ) // 4 NEXT // Send out list of authors -/* @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() - @ INFILELINE, 30 SAY "Sorting Author file" + @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() + @ INFILELINE, 30 SAY "Sorting Author file" FOR i := 1 TO LEN( aAuthorList ) @@ -859,7 +1248,7 @@ set console off UPPER( a[ 3 ] ) < UPPER( b[ 3 ] ) ) } ) @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() - @ INFILELINE, 30 SAY "Writing Author file" + @ INFILELINE, 30 SAY "Writing Author file" IF LEN( aAuthorList ) > 1 i := 2 @@ -898,12 +1287,15 @@ set console off SET ALTERNATE OFF SET ALTERNATE TO -*/ - @ MAXROW(), 0 SAY "Execute ASSEMBL.BAT to compile and link Guides" + + + @ MAXROW(), 0 SAY "Execute ASSEMBL.BAT to compile and link Guides" + + WAIT // Return to caller - +SET CURSOR ON RETURN NIL // End of MAIN() @@ -1415,7 +1807,7 @@ for nCount:=1 to Len(aWww) aadd(aTemp,{aTop[nCount,1],aTop[nCount,2],aTop[nCount,3]}) endif Next -asort(aTemp,,,{|x,y| x[1]Funca"+CRLF) @@ -1425,10 +1817,13 @@ return nil function GetNextContent(nPos) Local cReturn +//tracelog( nPos) if nPos <=Len(aResult) cReturn := aResult[nPos] endif +//tracelog(cReturn) return cReturn + Function WriteChmContentFile(aTop,cCat,oHtm) Local nCount:=0 @@ -1439,7 +1834,7 @@ for nCount:=1 to Len(aWww) aadd(aTemp,{aTop[nCount,1],aTop[nCount,2],aTop[nCount,4]}) endif Next -asort(aTemp,,,{|x,y| x[1]" + cLink + "
        " + CRLF ) Return Self -*+ EOF: HTML.PRG +*+ EOF: HTML.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/ng.prg b/harbour/utils/hbdoc/ng.prg index a4c1e31bf5..bf0ca08430 100644 --- a/harbour/utils/hbdoc/ng.prg +++ b/harbour/utils/hbdoc/ng.prg @@ -107,6 +107,7 @@ RETURN Self METHOD WriteTitle( cTopic, cTitle ) CLASS TNortonGuide + cTopic := HB_OEMTOANSI( cTopic ) FWRITE( Self:nHandle, "!Short: " + cTopic + CRLF ) @@ -127,4 +128,4 @@ METHOD WriteLink( cLink ) CLASS TNortonGuide RETURN Self -*+ EOF: NG.PRG +*+ EOF: NG.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/os2.prg b/harbour/utils/hbdoc/os2.prg index b43b631685..c7b43e3278 100644 --- a/harbour/utils/hbdoc/os2.prg +++ b/harbour/utils/hbdoc/os2.prg @@ -423,6 +423,4 @@ IF nLen<=230 aadd(aLine,ALLTRIM(cBuffer)) ENDIF RETURN aLine -*+ EOF: OS2.PRG - - +*+ EOF: OS2.PRG \ No newline at end of file diff --git a/harbour/utils/hbdoc/rtf.prg b/harbour/utils/hbdoc/rtf.prg index 736053d708..6a1ca45c6f 100644 --- a/harbour/utils/hbdoc/rtf.prg +++ b/harbour/utils/hbdoc/rtf.prg @@ -6,7 +6,7 @@ * Harbour Project source code: * RTF Documentation Support Code For HBDOC * - * Copyright 2000 Luiz Rafael Culik + * Copyright 2000-2003 Luiz Rafael Culik * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -65,6 +65,8 @@ CLASS TRTF DATA cFile DATA nHandle + DATA aIdh init {} + DATA lastId init 100 METHOD WriteHeader() METHOD New( cFile ) METHOD WritePar( cPar, cIden ) @@ -218,15 +220,25 @@ METHOD WriteTitle( cTitle, cTopic, cOne ,cCat) CLASS TRTF cTemp := HB_OEMTOANSI( ALLTRIM( cTitle ) ) cTemp := STRTRAN( cTemp, "@", "x" ) ENDIF + nPos := AT( "#", cTitle ) + IF nPos > 0 + cTemp := ALLTRIM( HB_OEMTOANSI( STRTRAN( cTemp, "#", "\#" ) ) ) + ENDIF cTopic := ALLTRIM( HB_OEMTOANSI( cTopic ) ) + cTemp := StrTran( cTemp, " ","_") - cWrite := '{\f6' + CRLF + ; - ' #{\footnote \pard\fs20 # ' + "IDH_" + cTemp + ' }' + CRLF + ; - ' ${\footnote \pard\fs20 $ ' + ALLTRIM( cTopic ) + ' }' + CRLF + ; - ' K{\footnote \pard\fs20 K ' + UPPERLOWER(ALLTRIM( cTopic ))+";" + UPPERLOWER(ALLTRIM( cCat ))+ ' }' + CRLF + ; - ' A{\footnote \pard\fs20 A ' + UPPERLOWER(ALLTRIM( cTopic )) +' }' + CRLF + ; - '}' + CRLF + Aadd( ::aIdh, {"IDH_" + cTemp,::lastid++}) + cWrite := CRLF + ; + ' {#{\footnote \pard\fs20 {' + "IDH_" + cTemp + ' }}}' + CRLF + ; + ' {${\footnote \pard\fs20 {' + ALLTRIM( cTopic ) + ' }}}' + CRLF + ; + ' {K{\footnote \pard\fs20 {' + UPPERLOWER(ALLTRIM( cTopic ))+";" + UPPERLOWER(ALLTRIM( cCat ))+ ' }}}' + CRLF + ; + ' {A{\footnote{A} ' + UPPERLOWER(ALLTRIM( cTopic )) +' }}' + CRLF + ; + CRLF + + + + /*'{\f6' + CRLF + ;*/ /*" ; " + UPPERLOWER(cCat) +" , " +UPPERLOWER(ALLTRIM( strtran(cTopic,"()","" )))+ */ aadd(aWww,{cTopic,"IDH_"+cTemp,cCat}) nPos := ascan(aResult,{|a| UPPER(a) == UPPER(cCat)}) @@ -257,10 +269,10 @@ METHOD WriteJumpTitle( cTitle, cTopic ) CLASS TRTF cTopic := ALLTRIM( HB_OEMTOANSI( cTopic ) ) - cWrite := '{\f6' + CRLF + ; - ' #{\footnote \pard\fs20 # ' + "IDH_" + cTemp + ' }' + CRLF + ; - ' ${\footnote \pard\fs20 $ ' + ALLTRIM( cTopic ) + ' }' + CRLF + ; - '}' + CRLF + cWrite := CRLF + ; + ' #{\footnote \pard\fs20 ' + "IDH_" + cTemp + ' }' + CRLF + ; + ' ${\footnote \pard\fs20 ' + ALLTRIM( cTopic ) + ' }' + CRLF + ; + CRLF FWRITE( Self:nHandle, cWrite ) @@ -306,19 +318,17 @@ Local cItem:=' ' Local nPos:=0 Local nSize:=Len(aLink) -HB_SYMBOL_UNUSED( lAlink ) - if nSize >2 For nPos:=1 to nSize if nPos==nSize - cItem+= aLink[nPos] + cItem+= UPPERLOWER(aLink[nPos]) else - cItem+= aLink[nPos] + cItem+= UPPERLOWER(aLink[nPos]) cItem+=";" endif next cItem:=Alltrim(cItem) - FWRITE( Self:nHandle, '\par \pard\cf1\fs20 \{button , ALink('+cItem + ', 2) \}{\f6\uldb Related Topic }'+'{\v\f6 %!ALink(" '+cItem + '", 2) }'+ CRLF ) + FWRITE( Self:nHandle, '\par \pard\cf1\fs20 \{button , ALink('+UPPER(cItem) + ', 2) \}{\f6\uldb Related Topic }'+'{\v\f6 %!ALink(" '+cItem + '", 2) }'+ CRLF ) else For nPos:=1 to nSize FWRITE( Self:nHandle, '\par \pard\cf1\fs20 {\f6\uldb '+aLink[nPos] +' }{\v\f6 !KLink(" '+UPPERLOWER(aLink[nPos]) + '", 2) }'+ CRLF ) diff --git a/harbour/utils/hbdoc/teeasc.prg b/harbour/utils/hbdoc/teeasc.prg new file mode 100644 index 0000000000..2636381fe9 --- /dev/null +++ b/harbour/utils/hbdoc/teeasc.prg @@ -0,0 +1,117 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * TEEASC support module for hbdoc document Extractor + * To separate the doc from the source + * + * Copyright 2004 Lorenzo Fiorini + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + + * + */ + +#include "directry.ch" +#include "fileio.ch" +#include "inkey.ch" + +#define CRLF HB_OSNewLine() + +#define DELIM "$" // keyword delimiter + +MEMVAR aDirList + +FUNCTION TeeFiles() + + LOCAL i + LOCAL nFiles := LEN( aDirList ) + LOCAL cFileName + LOCAL lDoc + LOCAL cBuffer + LOCAL nReadHandle + LOCAL nSourceHandle + LOCAL nDocHandle + LOCAL cDoc := DELIM + "DOC" + DELIM // DOC keyword + LOCAL cEnd := DELIM + "END" + DELIM // END keyword + + FOR i := 1 TO nFiles + + cFileName := aDirList[ i, F_NAME ] + nReadHandle := fopen( cFileName ) + nSourceHandle := fcreate( "teesrcs\" + cFileName ) + nDocHandle := fcreate( "teedocs\" + cFileName ) + + lDoc := .F. + + DO WHILE freadline( nReadHandle, @cBuffer, 256 ) + + IF AT( cDoc, cBuffer ) > 0 + lDoc := .T. + ELSEIF AT( cEnd, cBuffer ) > 0 + lDoc := .F. + cBuffer += CRLF + FWRITE( nDocHandle, cBuffer, len( cBuffer ) ) + freadline( nReadHandle, @cBuffer, 256 ) + cBuffer += CRLF + FWRITE( nDocHandle, cBuffer, len( cBuffer ) ) + LOOP + ENDIF + + cBuffer += CRLF + + IF lDoc + FWRITE( nDocHandle, cBuffer, len( cBuffer ) ) + ELSE + FWRITE( nSourceHandle, cBuffer, len( cBuffer ) ) + ENDIF + + ENDDO + + fclose( nReadHandle ) + fclose( nSourceHandle ) + fclose( nDocHandle ) + + NEXT + +RETURN NIL diff --git a/harbour/utils/hbmake/Makefile b/harbour/utils/hbmake/Makefile index 44ae6848c2..e21d9a66db 100644 --- a/harbour/utils/hbmake/Makefile +++ b/harbour/utils/hbmake/Makefile @@ -10,18 +10,20 @@ ROOT = ../../ PRG_SOURCES=\ hbmake.prg \ + tmake.prg \ hbmutils.prg \ fclass1.prg \ ffile1.prg \ ft_funcs.prg \ radios.prg \ - checks.prg \ + checks.prg \ pickarry.prg \ pickfile.prg \ prb_stak.prg \ C_SOURCES=\ - hbmlang.c \ + hbmlang.c \ + readline.c \ PRG_MAIN=hbmake.prg diff --git a/harbour/utils/hbmake/ft_funcs.prg b/harbour/utils/hbmake/ft_funcs.prg index 127de4fb82..3a27fb4182 100644 --- a/harbour/utils/hbmake/ft_funcs.prg +++ b/harbour/utils/hbmake/ft_funcs.prg @@ -109,11 +109,9 @@ FUNCTION FT_FUSE( cFile AS STRING, nMode AS NUMERIC) theHandle:closefile() ENDIF IF cFile <> Nil - IF nMode <> 0 - theHandle := HBMake_FileBase():new( cFile ):open() - ELSE - theHandle := HBMake_FileBase():new( cFile ):open() - ENDIF + theHandle := HBMake_FileBase():new( cFile ) + theHandle:nOpenMode := nMode + theHandle:open() ENDIF nHandle:= theHandle:nHan RETURN nHandle diff --git a/harbour/utils/hbmake/hbmake.prg b/harbour/utils/hbmake/hbmake.prg index 877720d7a9..f5fc0182cf 100644 --- a/harbour/utils/hbmake/hbmake.prg +++ b/harbour/utils/hbmake/hbmake.prg @@ -1,12 +1,13 @@ /* * $Id$ */ + /* - * Harbour Project source code: - * hbmake.Prg Harbour make utility main file + * xHarbour Project source code: + * hbmake.prg xHarbour make utility main file * - * Copyright 2000,2001 Luiz Rafael Culik - * www - http://www.harbour-project.org + * Copyright 2000-2007 Luiz Rafael Culik + * www - http://www.xharbour.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,3763 +49,5893 @@ * If you do not wish that, delete this exception notice. * */ + /* + * Modified By Sandro Freire sandrorrfreire at yahoo.com.br + * added suport to OS Unix + * + */ #include "fileio.ch" #include "common.ch" #include "radios.ch" +#include "inkey.ch" -#ifdef __HARBOUR__ -#include "hbgetcmt.ch" -#define EOL hb_osnewline() -#define CRLF hb_osnewline() -#else -#define EOL chr(13)+chr(10) -#define hb_osnewline() chr(13)+chr(10) -#define CRLF hb_osnewline() -#include "hbclip.ch" -#endif -#xtranslate timetosec() => ((val(substr(,1,2))*3600)+(val(substr(,4,2))*60)+(val(substr(,7,2)))) +#pragma -w1 + +//#include "wvtgui.ch" + +#define EOL Hb_OsNewLine() +#define CRLF Hb_OsNewLine() +#xtranslate TimeToSec() => ( ( Val( Substr( , 1, 2 ) ) * 3600 ) +( Val( Substr( , 4, 2 ) ) * 60 ) + ( Val( Substr( , 7, 2 ) ) ) ) + +//REQUEST HB_NOMOUSE + +#translate DateDiff(,) => (-) + +#Define HBM_USE_DEPENDS // Set this to have section #DEPENDS parsed like RMake, Ath 2004-06 + // An extra parameter is added to FileIsNewer() to have it check the INCLUDE paths also + // Interactive mode asks whether sources should be scanned for dependencies (#include, set procedure to, set proc to -#ifdef __HARBOUR__ -#define datediff(x,y) (x-y) -#else -#translate datediff(,) => (-) -#endif /* - Beginning Static Variables Table - - Default Values for core variables are set here - New Core vars should only be added on this section - */ - -STATIC lPrint := .f. -STATIC nHandle -STATIC aDefines := {} -STATIC aBuildOrder := {} -STATIC aCommands := {} -STATIC aMacros := {} -STATIC aPrgs := {} -STATIC aCs := {} -STATIC aObjs := {} -STATIC aObjsc := {} -STATIC lEof := .F. -STATIC aRes := {} -STATIC nLinkHandle -STATIC cLinker := "makefile.tmp" -STATIC cLinkcomm := '' -STATIC lBcc := .T. -STATIC lGcc := .F. -STATIC lVcc := .F. -STATIC lForce := .F. -STATIC lLinux := .F. -STATIC szProject := "" -STATIC lLibrary := .f. -STATIC lIgnoreErrors := .F. -STATIC lExtended := .F. -STATIC lOs2 := .F. -STATIC lRecurse := .F. -STATIC lEditMode := .F. -STATIC aDir -Static aLangMessages := {} -Static cDefLang - - -FUNCTION main( cFile, p1, p2, p3, p4, p5, p6 ) - - LOCAL aFile := {} - LOCAL aDef := {} - LOCAL cOs := Os() - LOCAL allParam - LOCAL nLang := GETUSERLANG() - - IF Pcount() == 0 - - cDefLang := IF( nLang == 1 , "PT" , IF( nLang == 2 ,"EN" , "ES" )) - aLangMessages := BuildLangArray( cDefLang ) - ShowHelp() - RETURN NIL - - ENDIF - - SET DATE Ansi - SET SCORE Off - SET CENTURY ON - - DEFAULT p1 TO "" - DEFAULT p2 TO "" - DEFAULT p3 TO "" - DEFAULT p4 TO "" - DEFAULT p5 TO "" - DEFAULT p6 TO "" - - /* Assing Default C Compiler upon The OS */ - - IF At( "OS/2", cOs ) > 0 - - lGcc := .t. - lLinux := .f. - lBcc := .f. - - ENDIF - - IF At( "LINUX", Upper( cOs ) ) > 0 - - lGcc := .t. - lLinux := .t. - lBcc := .f. - - ENDIF - - Allparam := ConvertParams( @cFile, aFile, p1, p2, p3, p4, p5, p6 ) - - if cDefLang == NIL - - cDefLang := IF( nLang == 1 , "PT" , IF( nLang == 2 ,"EN" , "ES" )) - - endif - - aLangMessages := BuildLangArray( cDefLang ) - - IF Len( aFile ) > 1 - - ? "File defined more than once" - RETURN NIL - - ENDIF - - IF Len( aFile ) > 0 - - cFile := aFile[ 1 ] - - ELSE - - cFile := "" - - ENDIF - - IF ( Empty( cFile ) .and. !lEditMode ) - - ? "File not Found" - RETURN Nil - - ENDIF - - /* We have at least one parameter . check if is an valid file name */ - - IF Pcount() >= 1 - - IF File( cFile ) - - ProcessParameters( AllParam ) - - ELSE - - IF !lEditMode - - ? "File not Found" - RETURN Nil - - ENDIF - - ENDIF - - ENDIF - - IF lEditMode - - IF lLibrary - - crtlibmakfile( cFile ) - - ELSE - - crtmakfile( cFile ) - - ENDIF - - RETURN nil - - ENDIF - - CLS - - /* Make file are parsed here */ - - ParseMakfi( cFile ) - - IF lPrint - - PrintMacros() - - ENDIF - - IF lForce - - Compfiles() - - ELSE - - CompUpdatedfiles() - - ENDIF - - Outstd( cLinkComm ) - ! ( cLinkcomm ) - -RETURN nil - -FUNCTION ParseMakfi( cFile ) - - LOCAL cBuffer := {} - LOCAL cMacro := "#BCC" - LOCAL cDep := "#DEPENDS" - LOCAL cOpt := "#OPTS" - LOCAL cCom := "#COMMANDS" - LOCAL cBuild := "#BUILD" - LOCAL cTemp := "" - LOCAL cTemp1 := '' - LOCAL aTemp := {} - LOCAL lMacrosec := .f. - LOCAL lBuildSec := .f. - LOCAL lComSec := .f. - LOCAL aTemp1 := {} - LOCAL cCfg := "" - LOCAL lCfgFound := .F. - LOCAL aTempCFiles := {} - LOCAL lLinux := At( 'linux', Lower( Os() ) ) > 0 - - nHandle := FT_FUSE( cFile ) - IF nHandle < 0 - RETURN nil - ENDIF - - cBuffer := Trim( Substr( ReadLN( @lEof ), 1 ) ) - - Aadd( aDefines, { "HMAKEDIR", GetMakeDir() } ) - - IF lBcc - - Aadd( aDefines, { "MAKEDIR", GetBccDir() } ) - - ELSEIF lGcc - - Aadd( aDefines, { "MAKEDIR", GetGccDir() } ) - - ELSEIF lVcc - - Aadd( aDefines, { "MAKEDIR", GetVccDir() } ) - - ENDIF - - WHILE !leof - - IF At( cMacro, cBuffer ) > 0 - - lMacroSec := .T. - lBuildSec := .f. - lComSec := .f. - - ELSEIF At( cBuild, cBuffer ) > 0 - - lMacroSec := .f. - lBuildSec := .T. - lComSec := .f. - - ELSEIF At( cCom, cBuffer ) > 0 - - lBuildSec := .f. - lComSec := .t. - lMacroSec := .f. - - ELSE - - ? "Invalid Make File" - Fclose( nHandle ) - RETURN Nil - - ENDIF - - cTemp := Trim( Substr( ReadLN( @lEof ), 1 ) ) - - IF At( "//", ctemp ) > 0 - - WHILE At( "//", ctemp ) > 0 - - ctemp := Strtran( ctemp, " //", "" ) - cTemp += Trim( Substr( ReadLN( @lEof ), 1 ) ) - - ENDDO - - ctemp := Strtran( ctemp, " //", "" ) - - ENDIF - - aTemp := Listasarray2( Alltrim( cTemp ), "=" ) - - IF lmacrosec - - IF Alltrim( Left( ctemp, 7 ) ) <> '!ifndef' .and. Alltrim( Left( ctemp, 6 ) ) <> "!endif" .and. Alltrim( Left( ctemp, 7 ) ) <> '!iffile' .and. Alltrim( Left( ctemp, 7 ) ) <> '!stdout' .and. Alltrim( Left( ctemp, 6 ) ) <> '!ifdef' - - IF Len( atemp ) > 1 - - IF At( "$", atemp[ 2 ] ) > 0 - - IF lgcc .and. aTemp[ 1 ] = "CFLAG1" .or. lGcc .and. aTemp[ 1 ] = "CFLAG2" - - Aadd( amacros, { aTemp[ 1 ], Strtran( Replacemacros( atemp[ 2 ] ), "\", "/" ) } ) - - ELSE - - Aadd( amacros, { aTemp[ 1 ], Replacemacros( atemp[ 2 ] ) } ) - - ENDIF - - ELSE - - IF lgcc .and. aTemp[ 1 ] = "CFLAG1" .or. lGcc .and. aTemp[ 1 ] = "CFLAG2" - - Aadd( aMacros, { aTemp[ 1 ], Strtran( atemp[ 2 ], "\", "/" ) } ) - - ELSE - - Aadd( aMacros, { aTemp[ 1 ], atemp[ 2 ] } ) - - ENDIF - - ENDIF - - ENDIF - - IF aTemp[ 1 ] == "PROJECT" - - IF At( '.lib', atemp[ 2 ] ) > 0 .or. At( '.a', atemp[ 2 ] ) > 0 - - lLibrary := .t. - - ENDIF - - ENDIF - - IF aTemp[ 1 ] == "OBJFILES" - - aObjs := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - IF aTemp[ 1 ] == "OBJCFILES" - - aTemp1 := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - IF Len( atemp1 ) == 1 - - IF !Empty( atemp[ 1 ] ) - - aObjsC := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - ELSE - aObjsC := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - ENDIF - - IF aTemp[ 1 ] == "PRGFILES" - - aPrgs := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - lExtended := .T. - lCfgFound := findHarbourcfg( @cCfg ) - - ENDIF - - IF aTemp[ 1 ] == "PRGFILE" - - aPrgs := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - IF atemp[ 1 ] == "CFILES" - - IF lExtended - - aTempCFiles := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - IF ( Len( aTempCFiles ) == 1 ) - - IF !Empty( aTempCFiles[ 1 ] ) - - aCs := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - ELSE - - aCs := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - ELSE - - aCs := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - ENDIF - - IF atemp[ 1 ] == "RESFILES" - - aRes := Listasarray2( replacemacros( atemp[ 2 ] ), " " ) - - ENDIF - - ELSE - - IF At( '!ifndef', cTemp ) > 0 - - Checkdefine( cTemp ) - - ELSEIF At( '!ifdef', ctemp ) > 0 - - CheckifDef( cTemp ) - - ELSEIF At( '!iffile', cTemp ) > 0 - - checkiffile( cTemp ) - - ELSEIF At( '!stdout', cTemp ) > 0 - - checkstdout( cTemp ) - - ENDIF - - ENDIF - - ENDIF - - IF lbuildSec - - szProject := cTemp - aBuildOrder := Listasarray2( ctemp, ":" ) - - IF !llibrary - - SetBuild() - - ELSE - - SetLibBuild() - - ENDIF - - ENDIF - - IF lComSec - - IF !Empty( ctemp ) - - Setcommands( cTemp ) - - ENDIF - - ENDIF - IF cTemp = "#BUILD" - - cBuffer := cTEmp - - ELSEIF cTemp == "#COMMANDS" - - cbuffer := ctemp - - ENDIF - - ENDDO - - IF lExtended .and. !lCfgFound - - IF lBcc - - BuildBorCfgFile() - - ELSEIF lVcc - - BuildMSCCfgFile() - - ELSEIF lGcc .and. !lLinux - - BuildGccCfgFile() - - ELSEIF lGcc .and. lLinux - - BuildGccCfgFilel() - - ENDIF - - ENDIF - -RETURN nil - -FUNCTION Checkdefine( cTemp ) - - LOCAL nPos - LOCAL cRead - LOCAL aSet := {} - LOCAL nMakePos - - IF cTemp == "!endif" - RETURN nil - ENDIF - - cTemp := Trim( Substr( ReadLN( @lEof ), 1 ) ) - cTemp := Strtran( cTemp, "!ifndef ", "" ) - cTemp := Strtran( cTemp, "\..", "" ) - cTemp := Strtran( cTemp, "/..", "" ) - - IF At( "\..", cTemp ) > 0 - - cTemp := Substr( cTemp, 1, At( "\..", cTemp ) - 1 ) - - ELSEIF At( "/..", cTemp ) > 0 - - cTemp := Substr( cTemp, 1, At( "/..", cTemp ) - 1 ) - - ENDIF - - aSet := Listasarray2( ctemp, "=" ) - nPos := Ascan( adefines, { | x | x[ 1 ] == aset[ 1 ] } ) - - IF nPos = 0 - - cRead := Alltrim( Strtran( aset[ 2 ], "$(", "" ) ) - cRead := Strtran( cRead, ")", "" ) - nMakePos := Ascan( aDefines, { | x | x[ 1 ] == cRead } ) - - IF nMakePos > 0 - - Aadd( aDefines, { aset[ 1 ], aDefines[ nMakePos, 2 ] } ) - Aadd( amacros, { aset[ 1 ], aDefines[ nMakePos, 2 ] } ) - - ENDIF - - ENDIF - -RETURN nil - -FUNCTION Setcommands( cTemP ) - - LOCAL cRead := Alltrim( readln( @leof ) ) - LOCAL nCount := 0 - LOCAL aTempMacros := {} - LOCAL aLocalMacros := {} - - aTempMacros := Listasarray2( cREad, " " ) - - Aeval( aTempMacros, { | xMacro | If( At( "$", xMacro ) > 0, ; - IF( At( ";", xMacro ) > 0, ( aLocalMacros := Listasarray2( xMacro, ";" ), ; - Aeval( aLocalMacros, { | x | Findmacro( x, @cRead ) } ) ), ; - Findmacro( xMacro, @cRead ) ), ) } ) - Aadd( aCommands, { cTemp, cRead } ) - -RETURN nil - -FUNCTION Findmacro( cMacro, cRead ) - - LOCAL nPos - LOCAL cTemp - LOCAL aLocalMacros := {} - - cMacro := Substr( cMacro, 1, At( ")", cMacro ) ) - - IF At( "-", cMacro ) > 0 - - cMacro := Substr( cMacro, 3 ) - - ENDIF - - IF At( ";", cMacro ) > 0 - - cMacro := Substr( cMacro, At( ";", cMacro ) + 1 ) - - ENDIF - - nPos := Ascan( aMacros, { | x | "$(" + Alltrim( x[ 1 ] ) + ")" == cMacro } ) - - IF nPos = 0 - - cTemp := Strtran( cmacro, "$(", "" ) - cTemp := Strtran( ctemp, ")", "" ) - - IF !Empty( cTemp ) - - cRead := Alltrim( Strtran( cRead, cmacro, Gete( cTemp ) ) ) - - ENDIF - - ELSE - - cRead := Alltrim( Strtran( cRead, cmacro, amacros[ npos, 2 ] ) ) - - ENDIF - -RETURN cRead - -FUNCTION Replacemacros( cMacros ) - - LOCAL nCount := 0 - LOCAL aTempMacros := {} - LOCAL aLocalMacros := {} - - aTempMacros := Listasarray2( cMacros, " " ) - Aeval( aTempMacros, { | xMacro | If( At( "$", xMacro ) > 0, ; - IF( At( ";", xMacro ) > 0, ( aLocalMacros := Listasarray2( xMacro, ";" ), ; - Aeval( aLocalMacros, { | x | Findmacro( x, @cMacros ) } ) ), ; - Findmacro( xMacro, @cMacros ) ), ) } ) - -RETURN cmacros - -FUNCTION setBuild() - - LOCAL cRead - LOCAL nPos - LOCAL aMacro - LOCAL aTemp - LOCAL nCount - LOCAL cCurrentRead := '' - - cRead := Alltrim( readln( @leof ) ) - szProject := cRead - amacro := Listasarray2( cRead, ":" ) - - IF Len( amacro ) > 1 - - aTemp := Listasarray2( amacro[ 2 ], " " ) - Aeval( atemp, { | xItem | Aadd( aBuildOrder, xItem ) } ) - - ENDIF - - Aadd( aBuildOrder, amacro[ 1 ] ) - cRead := Strtran( cRead, "@&&!", "" ) - - amacro := Listasarray2( cRead, '\' ) - Aeval( amacro, { | xMacro | If( At( "$", xmacro ) > 0, Findmacro( xMacro, @cRead ), ) } ) - - IF !lLinux - - cLinkcomm := cRead + " @" + cLinker - nLinkHandle := Fcreate( clinker ) - - ELSE - - cLinkComm := cRead + " " - - ENDIF - - FOR nPos := 1 TO 7 - - cRead := Alltrim( readln( @leof ) ) - cCurrentRead := cRead - amacro := Listasarray2( cRead, " " ) - - FOR ncount := 1 TO Len( amacro ) - - IF At( "$", amacro[ nCount ] ) > 0 - - Findmacro( amacro[ nCount ], @cRead ) - - IF At( '$(PROJECT)', cCurrentRead ) > 0 - - IF !lGcc - - IF !lLinux - - Fwrite( nLinkhandle, cRead + CRLF ) - - ENDIF - - ELSEIF lGcc .and. lLinux - - cLinkComm += "-o " + cRead + " " - - ELSEIF lGcc .and. !lLinux .and. At( '.exe', cread ) > 0 - - Fwrite( nLinkhandle, "-o " + cRead + CRLF ) - - ENDIF - - ELSE - - IF !lLinux - - Fwrite( nLinkhandle, cRead + CRLF ) - - ELSE - - cLinkComm += cRead + " " - - ENDIF - - ENDIF - - ENDIF - - NEXT - - NEXT - - IF !lLinux - - Fclose( nLinkhandle ) - - ENDIF - -RETURN nil - -FUNCTION Compfiles() - - LOCAL cComm - LOCAL cOld - LOCAL nPos - LOCAL nCount - LOCAL nFiles - LOCAL cErrText := "" - LOCAL aOrder := Listasarray2( aBuildOrder[ 2 ], " " ) - LOCAL lEnd := .f. - LOCAL xItem - LOCAL lLinux := At( 'linux', Lower( Os() ) ) > 0 - Local nFile := 1 - Local aGauge := GaugeNew( 5, 5, 7,40 , "W/B", "W+/B" ,'²') - - @ 4, 5 Say "Compiling :" - FOR nCount := 1 TO Len( aOrder ) - - IF !lExtended - - IF aOrder[ nCount ] == "$(CFILES)" - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".prg.c:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".PRG.C:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ENDIF - - ENDIF - - FOR nFiles := 1 TO Len( aPrgs ) - - xItem := Substr( aPrgs[ nFiles ], Rat( If( lgcc, '/', '\' ), ; - aPrgs[ nFiles ] ) + 1 ) - nPos := Ascan( aCs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), ; - Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) - - IF nPos > 0 - - cComm := Strtran( cComm, "o$*", "o" + aCs[ nPos ] ) - cComm := Strtran( cComm, "$**", aPrgs[ nFiles ] ) - - cComm += " > Test.out" - Outstd( cComm ) - Outstd( hb_osnewline() ) - ! ( cComm ) - cErrText := Memoread( 'Test.out' ) - lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText - - IF !lIgnoreErrors .and. lEnd - - QUIT - - ELSE - - Ferase( 'Test.out' ) - - ENDIF - - cComm := cold - - ENDIF - - NEXT - - ENDIF - - IF aOrder[ nCount ] == "$(OBJFILES)" - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.o:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.obj:" } ) - - ENDIF - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := ccomm - - ELSE - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".C.O:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ENDIF - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".C.OBJ:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ENDIF - - ENDIF - - ENDIF - - FOR nFiles := 1 TO Len( aCs ) - - xItem := Substr( aCs[ nFiles ], Rat( If( lgcc, '/', '\' ), ; - aCs[ nFiles ] ) + 1 ) - nPos := Ascan( aObjs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), ; - Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) - - IF nPos > 0 - - IF llinux - - cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) - - ELSE - - cComm := Strtran( cComm, "o$*", "o" + Strtran( aObjs[ nPos ], '/', '\' ) ) - - ENDIF - - cComm := Strtran( cComm, "$**", acs[ nFiles ] ) - Outstd( " " ) - - Outstd( cComm ) - Outstd( hb_osnewline() ) - ! ( cComm ) - ccomm := cold - - ENDIF - - NEXT - - ENDIF - - ELSE /****** Extended mode *****/ - - IF aOrder[ nCount ] == "$(CFILES)" - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.o:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.obj:" } ) - - ENDIF - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ELSE - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".C.OBJ:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ENDIF - - ENDIF - - IF Len( acs ) > 0 - GaugeDisplay( aGauge ) - nFile:=1 - - - FOR nFiles := 1 TO Len( acs ) - @ 4,16 Say space(50) - - xItem := Substr( acs[ nFiles ], Rat( If( lgcc, '/', '\' ), ; - acs[ nFiles ] ) + 1 ) - nPos := Ascan( aObjsc, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), ; - Left( x, At( ".", x ) ) == Left( xitem, At( ".", xitem ) ) } ) - - IF nPos > 0 - - IF llinux - - cComm := Strtran( cComm, "o$*", "o" + aobjsc[ nPos ] ) - - ELSE - - cComm := Strtran( cComm, "o$*", "o" + Strtran( aobjsc[ nPos ], '/', '\' ) ) - - ENDIF - - cComm := Strtran( cComm, "$**", acs[ nFiles ] ) - cComm += " > Test.out" - @ 4,16 Say acs[nFiles] - GaugeUpdate(aGauge,nFile/Len( aprgs )) - -// Outstd( cComm ) -// Outstd( hb_osnewline() ) - ! ( cComm ) - nFile++ - cErrText := Memoread( 'Test.out' ) - lEnd := 'Error' $ cErrText - - IF !lIgnoreErrors .and. lEnd - if(at("LINUX",upper(OS()))>0,__run("mcedit Test.out"),__run("Notepad Test.out")) - - QUIT - - ELSE - - Ferase( 'Test.out' ) - - ENDIF - - cComm := cold - - ENDIF - - NEXT - - ENDIF - - ENDIF - - IF aOrder[ nCount ] == "$(OBJFILES)" - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".prg.o:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".prg.obj:" } ) - - ENDIF - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := ccomm - - ELSE - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".PRG.O:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".PRG.OBJ:" } ) - - ENDIF - - ENDIF - GaugeDisplay( aGauge ) - nFile:=1 - - FOR nFiles := 1 TO Len( aprgs ) - - xItem := Substr( aprgs[ nFiles ], Rat( If( lgcc, '/', '\' ), ; - aprgs[ nFiles ] ) + 1 ) - nPos := Ascan( aobjs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), ; - Left( x, At( ".", x ) ) == Left( xItem, At( ".", xitem ) ) } ) - - IF nPos > 0 - - IF llinux - - cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) - - ELSE - - cComm := Strtran( cComm, "o$*", "o" + Strtran( aObjs[ nPos ], '/', '\' ) ) - - ENDIF - - cComm := Strtran( cComm, "$**", aprgs[ nFiles ] ) - cComm += " > Test.out" -// Outstd( " " ) - -// Outstd( cComm ) -// Outstd( hb_osnewline() ) - @ 4,16 Say aprgs[ nFiles ] - GaugeUpdate(aGauge,nFile/Len( aprgs )) -// Outstd( hb_osnewline() ) - nFile++ - - ! ( cComm ) - cErrText := Memoread( 'Test.out' ) - lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText - - IF !lIgnoreErrors .and. lEnd - if(at("LINUX",upper(OS()))>0,__run("mcedit Test.out"),__run("Notepad Test.out")) - QUIT - - ELSE - - Ferase( 'Test.out' ) - - ENDIF - - ccomm := cold - - ENDIF - - NEXT - - ENDIF - - ENDIF - IF aOrder[ nCount ] == "$(RESDEPEN)" - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".rc.res:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cold := ccomm - ENDIF - - FOR nFiles := 1 TO Len( aRes ) - - IF !Empty( ares[ nFiles ] ) - - cComm := Strtran( cComm, "$<", aRes[ nFiles ] ) - Outstd( " " ) - ! ( cComm ) - - ENDIF - - ccomm := cold - - NEXT - - ENDIF - - NEXT - -RETURN nil - -FUNCTION GetParaDefines( cTemp ) - - LOCAL nPos - LOCAL cRead - LOCAL aSet := {} - LOCAL nMakePos - - IF At( "\..", cTemp ) > 0 - - cTemp := Substr( cTemp, 1, At( "\..", cTemp ) - 1 ) - - ELSEIF At( "/..", cTemp ) > 0 - - cTemp := Substr( cTemp, 1, At( "/..", cTemp ) - 1 ) - - ENDIF - - aSet := Listasarray2( ctemp, "=" ) - nPos := Ascan( adefines, { | x | x[ 1 ] == aset[ 1 ] } ) - - IF nPos == 0 - - cRead := Alltrim( Strtran( aset[ 2 ], "$(", "" ) ) - cRead := Strtran( cRead, ")", "" ) - nMakePos := Ascan( aDefines, { | x | x[ 1 ] == cRead } ) - - IF nMakePos = 0 - - aset[ 2 ] := Strtran( aset[ 2 ], ",", " " ) - Aadd( aDefines, { aset[ 1 ], aset[ 2 ] } ) - Aadd( amacros, { aset[ 1 ], aset[ 2 ] } ) - - ENDIF - - ENDIF - -RETURN NIL - -FUNCTION PrintMacros() - - Outstd( "HBMAKE Version ", Version(), "CopyRight (c) 2000-2002 The Harbour Project" + CRLF ) - Outstd( "" + CRLF ) - Outstd( "Macros:" + CRLF ) - Aeval( aMacros, { | xItem | Outstd( " " + xItem[ 1 ] + " = " + xItem[ 2 ] + CRLF ) } ) - Outstd( "Implicit Rules:" + CRLF ) - Aeval( aCommands, { | xItem | Outstd( " " + xItem[ 1 ] + hb_osnewline() + " " + xItem[ 2 ] + CRLF ) } ) - Outstd( "" + CRLF ) - Outstd( "Targets:" ) - Outstd( " " + szProject + ":" + CRLF ) - Outstd( " " + "Flags :" + CRLF ) - Outstd( " " + "Dependents :" ) - Aeval( acs, { | xItem | Outstd( xitem + " " ) } ) - Aeval( aobjs, { | xItem | Outstd( xitem + " " ) } ) - Outstd( " " + CRLF ) - Outstd( " commands:" + aBuildOrder[ Len( aBuildOrder ) ] ) - Outstd( " " + CRLF ) - Outstd( " " + CRLF ) - Outstd( " " + CRLF ) - -RETURN Nil - -FUNC crtmakfile( cFile ) - - LOCAL ain := {} - LOCAL aOut := {} - LOCAL aOutc := {} - LOCAL aSrc := Directory( "*.prg" ) - LOCAL nLenaSrc := Len( asrc ) - LOCAL nLenaOut - LOCAL lFwh := .f. - LOCAL lCw := .f. - LOCAL lMiniGui := .f. - LOCAL lRddAds := .f. - LOCAL cOs := "Win32" - LOCAL cCompiler := "BCC" - LOCAL cfwhpath := Space( 40 ) - LOCAL ccwpath := Space( 40 ) - LOCAL cMiniPath := Space( 40 ) - LOCAL cObjDir := "obj" + Space( 20 ) - LOCAL lAutomemvar := .f. - LOCAL lvarismemvar := .f. - LOCAL ldebug := .f. - LOCAL lSupressline := .f. - LOCAL nPos - LOCAL cDefHarOpts := "" - - LOCAL lCompMod := .f. - LOCAL x - LOCAL lGenppo := .f. - LOCAL getlist := {} - LOCAL cTopFile := "" - LOCAL cDefBccLibs := "lang.lib vm.lib rtl.lib rdd.lib macro.lib pp.lib dbfntx.lib dbfcdx.lib common.lib gtwin.lib" - LOCAL cDefGccLibs := "-lvm -lrtl -lgtdos -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -lcommon" - LOCAL cgcclibsos2 := "-lvm -lrtl -lgtos2 -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -lcommon" - LOCAL cDeflibGccLibs := "-lvm -lrtl -lgtsln -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -lcommon -lslang -lm" - LOCAL cLibs := "" - LOCAL citem := "" - LOCAL cExt := "" - LOCAL cDrive := "" - LOCAL cPath := "" - LOCAL cTest := "" - LOCAL cUserdef := Space( 40 ) - LOCAL cUserInclude := Space( 40 ) - LOCAL aLibs - LOCAL aLibsin := {} - LOCAL aLibsout := {} - LOCAL lExternalLib := .f. - LOCAL cOldLib := "" - LOCAL cHtmlLib := "" - LOCAL lLinux := At( 'linux', Lower( Os() ) ) > 0 - LOCAL nWriteFiles := 0 - Local cResName := Space(50) - - nLinkHandle := Fcreate( cFile ) - WriteMakeFileHeader() - CLS - Setcolor( 'w/b+,b+/w,w+/b,w/b+,w/b,w+/b' ) - @ 0, 0, Maxrow(), Maxcol() BOX( Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 ) + Space( 1 ) ) - ATTENTION( aLangMessages[ 27 ] , 0 ) - @ 1, 1 SAY aLangMessages[ 28 ] - @ 1, 12 GET cos radio { "Win32", "OS/2", "Linux" } VALID !Empty( cos ) - @ 1, 23 SAY aLangMessages[ 29 ] - @ 1, 40 GET cCompiler radio { "BCC", "MSVC", "GCC" } VALID !Empty( cCompiler ) - @ 1, 48 SAY aLangMessages[ 30 ] -#ifdef HB_COMPAT_C53 - @ 1, 64 GET lFwh checkbox caption "Use FWH" WHEN Cos == "Win32" - @ 2, 64 GET lcw checkbox caption "Use C4W" WHEN Cos == "Win32" - @ 3, 64 GET lRddads checkbox caption "Use RddAds" WHEN Cos == "Win32" .OR. Cos == "Linux" - @ 4, 64 Get lMiniGui checkbox caption "Use Minigui" WHEN Cos == "Win32" -#endif - - READ - - IF lFwh - - @ 5, 1 SAY "FWH path" GET cfwhpath Pict "@s20" - - ELSEIF lCw - - @ 5, 1 SAY "C4H path" GET ccwpath Pict "@s20" - - ELSEIF lMiniGui - - @ 5, 1 SAY "MinuGui path" GET cMiniPath Pict "@s20" - - - ENDIF - - @ 5, 40 SAY "Obj Files Dir" GET cObjDir PICT "@s15" - ATTENTION( aLangMessages[ 31 ] , 6 ) - -#ifdef HB_COMPAT_C53 - @ 7, 1 GET lautomemvar checkbox caption aLangMessages[ 32 ] - @ 7, 40 GET lvarismemvar checkbox caption aLangMessages[ 33 ] - @ 8, 1 GET lDebug checkbox caption aLangMessages[ 34 ] - @ 8, 40 GET lSupressline checkbox caption aLangMessages[ 35 ] - @ 9, 1 GET lGenppo checkbox caption aLangMessages[ 36 ] - @ 9, 40 GET lCompMod checkbox caption aLangMessages[ 37 ] -#endif - @ 10, 1 SAY aLangMessages[ 38 ] GET cUserDef PICT "@s15" - @ 10, 40 SAY aLangMessages[ 39 ] GET cUserInclude PICT "@s15" -#ifdef HB_COMPAT_C53 - @ 11, 1 GET lExternalLib checkbox caption aLangMessages[ 40 ] -#endif - @ 12, 1 Say "Resource file Name" Get CResName - READ - - IF !Empty( cUserDef ) - - cDefHarOpts += " -D" + Alltrim( cUserDef ) + " " - - ENDIF - - IF !Empty( cUserInclude ) - - cDefHarOpts += " -I" + Alltrim( cUserInclude ) + " " - - ENDIF - - lBcc := IF( At( "BCC", cCompiler ) > 0, .t., .f. ) - lVcc := IF( At( "MSVC", cCompiler ) > 0, .t., .f. ) - lGcc := IF( At( "GCC", cCompiler ) > 0, .t., .f. ) - cObjDir := Alltrim( cObjDir ) - - IF !Empty( cobjDir ) - -#ifdef HB_COMPAT_C53 - IF Dirchange( cobjDir ) != 0 - Makedir( cobjDir ) - ELSE - Dirchange( '..' ) - ENDIF -#endif - - ENDIF - - amacros := GetSourceDirMacros( lGcc, cos ) - - IF lLinux - - cObjDir := Alltrim( cObjDir ) - - IF !Empty( cObjDir ) - - cObjDir += '/' - - ENDIF - - cTest := cObjDir - - ELSE - cObjDir := Alltrim( cObjDir ) - - IF !Empty( cObjDir ) - - cObjDir += '\' - - ENDIF - - cTest := Upper( cObjDir ) + '\' - - ENDIF - - Aeval( amacros, { | x, y | cItem := Substr( x[ 2 ], 1, Len( x[ 2 ] ) ), If( At( citem, cTest ) > 0, ( amacros[ y, 1 ] := 'OBJ', amacros[ y, 2 ] := cObjDir ), ) } ) - - IF lAutomemvar - - cDefHarOpts += " -a " - - ENDIF - - IF lvarismemvar - - cDefHarOpts += " -v " - - ENDIF - - IF ldebug - - cDefHarOpts += " -b " - cDefBccLibs += " debug.lib " - cDefGccLibs += " -ldebug " - cgcclibsos2 += " -ldebug " - cDeflibGccLibs += " -ldebug " - - ENDIF - - IF lSupressline - - cDefHarOpts += " -l " - - ENDIF - - IF lGenppo - - cDefHarOpts += " -p " - - ENDIF - - IF lCompmod - - cDefHarOpts += " -m " - - ENDIF - - IF lBcc - - Aadd( aCommands, { ".cpp.obj:", "$(BCB)\BIN\bcc32 $(CFLAG1) $(CFLAG2) -o$* $*" } ) - Aadd( aCommands, { ".c.obj:", "$(BCB)\BIN\bcc32 -I$(BHC)\include $(CFLAG1) $(CFLAG2) -o$* $**" } ) - - IF lExtended - - Aadd( aCommands, { ".prg.obj:", "$(BHC)\bin\harbour -n -go -I$(BHC)\include $(HARBOURFLAGS)" + if(lFwh," -I$(FWH)\include" ,if(lMinigui," -I$(MINIGUI)" , "" )) +" -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "$(BHC)\bin\harbour -n -I$(BHC)\include $(HARBOURFLAGS)" + if(lFwh," -I$(FWH)\include" ,if(lMinigui," -I$(MINIGUI)" , "" )) +" -o$* $**" } ) - - ENDIF - - Aadd( aCommands, { ".rc.res:", "$(BCB)\BIN\brcc32 $(RFLAGS) $<" } ) - - ELSEIF lGcc - - IF At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0 .or. cOs == "Linux" - - Aadd( aCommands, { ".cpp.o:", "gcc $(CFLAG1) $(CFLAG2) -o$* $*" } ) - Aadd( aCommands, { ".c.o:", "gcc -I$(HB_INC_INSTALL) $(CFLAG1) $(CFLAG2) -I. -g -o$* $**" } ) - - IF lExtended - - Aadd( aCommands, { ".prg.o:", "harbour -n -go -I$(HB_INC_INSTALL) -I. -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "harbour -n -I$(HB_INC_INSTALL) -I. -o$* $**" } ) - - ENDIF - - ELSE - - Aadd( aCommands, { ".cpp.o:", "$(BCB)\bin\gcc $(CFLAG1) $(CFLAG2) -o$* $*" } ) - Aadd( aCommands, { ".c.o:", "$(BCB)\bin\gcc -I$(BHC)/include $(CFLAG1) $(CFLAG2) -I. -o$* $**" } ) - - IF lExtended - - Aadd( aCommands, { ".prg.o:", "$(BHC)\bin\harbour -n -go -I$(BHC)/include $(HARBOURFLAGS) -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "$(BHC)\bin\harbour -n -I$(BHC)/include $(HARBOURFLAGS) -o$* $**" } ) - - ENDIF - - ENDIF - - ELSEIF lVcc - - Aadd( aCommands, { ".cpp.obj:", "$(BCB)\bin\cl $(CFLAG1) $(CFLAG2) -Fo$* $*" } ) - Aadd( aCommands, { ".c.obj:", "$(BCB)\bin\cl -I$(BHC)\include $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) - - IF lExtended - - Aadd( aCommands, { ".prg.obj:", "$(BHC)\bin\harbour -n -I$(BHC)\include $(HARBOURFLAGS) -go -I$(C4W)\include -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "$(BHC)\bin\harbour -n -I$(BHC)\include $(HARBOURFLAGS) -I$(C4W)\include -o$* $**" } ) - - ENDIF - - Aadd( aCommands, { ".rc.res:", "$(BCB)\rc $(RFLAGS) $<" } ) - - ENDIF - - attention( aLangMessages[ 41 ] , 22 ) - - IF !lRecurse - - ain := GetSourceFiles( .f., lGcc, cOs ) - nLenaSrc := Len( ain ) - - ELSE - - ain := GetSourceFiles(, lGcc, cOs ) - nLenaSrc := Len( asrc ) - - ENDIF - - aOut := Aclone( aIn ) - pickarry( 11, 15, 20, 64, aIn, aOut ) - nLenaOut := Len( aOut ) - Aeval( aout, { | x, y | HB_SYMBOL_UNUSED( x ), aout[ y ] := Trim( Substr( aOut[ y ], 1, At( ' ', aout[ y ] ) ) ) } ) - aOut := Asort( aOut ) - - IF Len( aOut ) == 1 - - cTopFile := aOut[ 1 ] - - ELSE - - attention( 'Select the TOP MODULE of your executable', 22 ) - - IF !lrecurse - - cTopFile := pickfile( "*.prg" ) - - ELSE - - cTopFile := pickafile( ain ) - - ENDIF - - ENDIF - - IF lExternalLib - - aLibs := Getlibs( lgcc, GetMakeDir() + '\lib' ) - attention( 'Spacebar to select, Enter to continue process', 22 ) - Aeval( aLibs, { | x | Aadd( aLibsin, x[ 1 ] ) } ) - Aeval( aLibs, { | x | Aadd( aLibsout, x[ 2 ] ) } ) - pickarry( 11, 15, 20, 64, aLibsIn, aLibsOut ) - - ENDIF - - Aeval( aout, { | xItem | If( At( '.c', xItem ) > 0 .or. At( '.C', xItem ) > 0, Aadd( aoutc, xitem ), ) } ) - Aeval( aoutc, { | x, z | citem := x, z := Ascan( aout, { | t | t = citem } ), If( z > 0, Asize( Adel( aout, z ), Len( aout ) - 1 ), ) } ) - - aOut := Asort( aOut ) - aPrgs := Aclone( aout ) - - aObjs := Aclone( aout ) - x := Ascan( aobjs, { | x | Lower( x ) == Lower( cTopFile ) } ) - - IF x > 0 - - Adel( aobjs, x ) - Asize( aobjs, Len( aobjs ) - 1 ) - Asize( aobjs, Len( aobjs ) + 1 ) - Ains( aobjs, 1 ) - aobjs[ 1 ] := cTopFile - - ENDIF - - x := Ascan( aPrgs, { | x | Lower( x ) == Lower( cTopFile ) } ) - - IF x > 0 - - Adel( aPrgs, x ) - Asize( aPrgs, Len( aPrgs ) - 1 ) - Asize( aPrgs, Len( aPrgs ) + 1 ) - Ains( aPrgs, 1 ) - aPrgs[ 1 ] := cTopFile - - ENDIF - - Aeval( aobjs, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), If( !lGcc, aObjs[ x ] := cObjDir + cTest + "." + exte( cExt, 2 ), aObjs[ x ] := cObjDir + cTest + "." + exte( cExt, 3 ) ) } ) - aCs := Aclone( aoutc ) - - IF !lextended - - Aeval( aOutc, { | xItem | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), If( !lGcc, Aadd( aObjs, cObjDir + cTest + "." + exten( cExt, 2 ) ), Aadd( aObjs, cObjDir + cTest + "." + exten( cExt, 1 ) ) ) } ) - Aeval( aout, { | xItem | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cExt := Substr( cExt, 2 ), Aadd( aCs, cObjDir + cTest + "." + exte( cExt, 1 ) ) } ) - - ELSE - aObjsc := Aclone( aoutc ) - Aeval( aoutc, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), If( !lGcc, aObjsc[ x ] := If( !Empty( cObjDir ), cObjDir, '' ) + cTest + "." + exten( cExt, 2 ), aObjsc[ x ] := If( !Empty( cObjDir ), cObjDir, '' ) + cTest + "." + exten( cExt, 1 ) ) } ) - - ENDIF - - IF lFwh - - Fwrite( nLinkHandle, "FWH = " + cfwhpath + CRLF ) - - ELSEIF lCw - - Fwrite( nLinkHandle, "C4W =" + ccwpath + CRLF ) - - ELSEIF lMiniGui - - Fwrite( nLinkHandle, "MINIGUI =" + cMiniPath + CRLF ) - - - ENDIF - - FOR x := 1 TO Len( amacros ) - - IF !Empty( amacros[ x, 2 ] ) - - cItem := amacros[ x, 2 ] - nPos := Ascan( aprgs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - Aeval( aprgs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, aprgs[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + ')\' ), ) } ) - - IF !amacros[ x, 3 ] - - Fwrite( nLinkHandle, amacros[ x, 1 ] + ' = ' + Left( amacros[ x, 2 ], Len( amacros[ x, 2 ] ) - 1 ) + " " + CRLF ) - amacros[ x, 3 ] := .t. - - ENDIF - - ENDIF - - nPos := Ascan( acs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - IF !amacros[ x, 3 ] - - Aeval( acs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, acs[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + If( lgcc, ")/", ')\' ) ), ) } ) - Fwrite( nLinkHandle, amacros[ x, 1 ] + ' = ' + Left( amacros[ x, 2 ], Len( amacros[ x, 2 ] ) - 1 ) + " " + CRLF ) - amacros[ x, 3 ] := .t. - - ENDIF - - ENDIF - - nPos := Ascan( aObjs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - IF !Empty( cObjDir ) - - Aeval( aObjs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, aObjs[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + If( lgcc, ")/", ')\' ) ), ) } ) - Fwrite( nLinkHandle, amacros[ x, 1 ] + ' = ' + Left( amacros[ x, 2 ], Len( amacros[ x, 2 ] ) - 1 ) + " " + CRLF ) - - ENDIF - - ENDIF - - IF lExtended - - nPos := Ascan( aObjsc, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - IF !Empty( cObjDir ) - - Aeval( aObjsc, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, aObjsc[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + If( lgcc, ")/", ')\' ) ), ) } ) - - ENDIF - - ENDIF - - ENDIF - - ENDIF - - NEXT - - IF lGcc - - IF At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0 .or. cOs == "Linux" - - hb_FNAMESPLIT( cTopfile, @cPath, @cTest, @cExt, @cDrive ) - cExt := Substr( cExt, 2 ) - Fwrite( nLinkHandle, "PROJECT = " + If( Isupper( cExt ), Strtran( cTopfile, ".PRG", "" ), Strtran( cTopfile, ".prg", "" ) ) + " $(PR) " + CRLF ) - - ELSE - - hb_FNAMESPLIT( cTopfile, @cPath, @cTest, @cExt, @cDrive ) - cExt := Substr( cExt, 2 ) - Fwrite( nLinkHandle, "PROJECT = " + If( Isupper( cExt ), cTest + "." + Strtran( cExt, "PRG", "EXE" ), cTest + "." + Strtran( cExt, "prg", "exe" ) ) + " $(PR) " + CRLF ) - - ENDIF - - ELSE - - hb_FNAMESPLIT( cTopfile, @cPath, @cTest, @cExt, @cDrive ) - cExt := Substr( cExt, 2 ) - Fwrite( nLinkHandle, "PROJECT = " + If( Isupper( cExt ), cTest + "." + Strtran( cExt, "PRG", "exe" ), cTest + "." + Strtran( cExt, "prg", "exe" ) ) + " $(PR) " + CRLF ) - - ENDIF - - hb_FNAMESPLIT( cTopfile, @cPath, @cTest, @cExt, @cDrive ) - cExt := Substr( cExt, 2 ) - - IF !lextended - - Fwrite( nLinkHandle, "OBJFILES = " ) - - IF Len( aObjs ) < 1 - - Fwrite( nLinkHandle, + " $(OB) " + CRLF ) - - ELSE - - Aeval( aObjs, { | x, i | If( ( i <> Len( aObjs ) .and. x <> cTopfile ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) ), Fwrite( nLinkHandle, " " + " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - hb_FNAMESPLIT( cTopfile, @cPath, @cTest, @cExt, @cDrive ) - cExt := Substr( cExt, 2 ) - Fwrite( nLinkHandle, "CFILES =" ) - - IF Len( aCs ) < 1 - - Fwrite( nLinkHandle, + " $(CF)" + CRLF ) - - ELSE - - Aeval( aCs, { | x, i | If( ( i <> Len( aCs ) .and. x <> cTopfile ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(CF) " + CRLF ) ) } ) - - ENDIF - - Fwrite( nLinkHandle, "PRGFILE =" ) - - IF Len( aPrgs ) < 1 - - Fwrite( nLinkHandle, + " $(PS)" + CRLF ) - - ELSE - - Aeval( aPrgs, { | x, i | If( i <> Len( aPrgs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) - - ENDIF - - ELSE - - Fwrite( nLinkHandle, "OBJFILES =" ) - - IF Len( aObjs ) < 1 - - Fwrite( nLinkHandle, + " $(OB) " + CRLF ) - - ELSE - - Aeval( aobjs, { | x, i | nWriteFiles ++, If( ( i <> Len( aobjs ) .and. x <> cTopfile ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - nWriteFiles := 0 - Fwrite( nLinkHandle, "PRGFILES =" ) - - IF Len( aPrgs ) < 1 - - Fwrite( nLinkHandle, + " $(PS)" + CRLF ) - - ELSE - - Aeval( aPrgs, { | x, i | nWriteFiles ++, If( i <> Len( aPrgs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) - - ENDIF - - nWriteFiles := 0 - Fwrite( nLinkHandle, "OBJCFILES =" ) - - IF Len( aObjsc ) < 1 - - Fwrite( nLinkHandle, + " $(OB) " + CRLF ) - - ELSE - - Aeval( aObjsc, { | x, i | nWriteFiles ++, If( i <> Len( aobjsc ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - nWriteFiles := 0 - Fwrite( nLinkHandle, "CFILES =" ) - - IF Len( aCs ) < 1 - - Fwrite( nLinkHandle, + " $(CF)" + CRLF ) - - ELSE - - Aeval( aCs, { | x, i | nWriteFiles ++, If( i <> Len( aCs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - ENDIF - - CResName :=lower(CResName ) - Fwrite( nLinkHandle, "RESFILES = "+ CResName + CRLF ) - Fwrite( nLinkHandle, "RESDEPEN = "+ strtran(CResName,".rc",".res") + CRLF ) - - IF lRddads - - cDefBccLibs += " rddads.lib ace32.lib" - cDeflibGccLibs += " -lrddads -ladsloc" - ENDIF - - IF Len( alibsout ) > 0 .and. lExternalLib - - IF lvcc .or. lbcc - - cOldLib := cDefBccLibs - nPos := Ascan( aLibsout, { | z | At( "html", Lower( z ) ) > 0 } ) - - IF npos > 0 - - cHtmlLib += aLibsout[ npos ] - Adel( alibsout, nPos ) - Asize( alibsout, Len( alibsout ) - 1 ) - - ENDIF - - Aeval( alibsout, { | cLib | cLibs += " " + cLib } ) - - cDefBccLibs := cHtmlLib + " " + cOldLib + " " + cLibs - - ENDIF - - IF lGcc - - nPos := Ascan( aLibsout, { | z | At( "html", Lower( z ) ) > 0 } ) - - IF npos > 0 - - cHtmlLib += "-l" + Strtran( aLibsout[ npos ], '.a', "" ) - Adel( alibsout, nPos ) - Asize( alibsout, Len( alibsout ) - 1 ) - - ENDIF - - Aeval( alibsout, { | cLib | cLibs += " -l" + Strtran( cLib, '.a', "" ) } ) - - IF cOs == "Linux" - - cOldLib := " " + cDeflibGccLibs - cDeflibGccLibs := cHtmlLib + " " + cOldLib + " " + cLibs - - ELSEIF cOs == "OS/2" - - cOldLib := " " + cgcclibsos2 - cgcclibsos2 := cHtmlLib + " " + cOldLib + " " + cLibs - - ELSE - - cOldLib := " " + cDefGccLibs - cDefGccLibs := cHtmlLib + " " + cOldLib + " " + cLibs - - ENDIF - - ENDIF - - ENDIF - - IF lBcc .or. lVcc - - IF lFwh - - Fwrite( nLinkHandle, "LIBFILES = $(FWH)\lib\fiveh.lib $(FWH)\lib\fivehc.lib " + cDefBccLibs + CRLF ) - - ELSEIF lMiniGui - - Fwrite( nLinkHandle, "LIBFILES = Minigui.lib " + cDefBccLibs + CRLF ) - - ELSEIF lCw - - Fwrite( nLinkHandle, "LIBFILES = $(C4W)\c4wclass.lib $(C4W)\wbrowset.lib $(C4W)\otabt.lib $(C4W)\clip4win.lib" + cDefBccLibs + CRLF ) - - ELSE - - Fwrite( nLinkHandle, "LIBFILES = " + cDefBccLibs + CRLF ) - - ENDIF - - ELSEIF lGcc - - IF cOs == "Linux" - - Fwrite( nLinkHandle, "LIBFILES = -Wl,--start-group " + cDeflibGccLibs + " -Wl,--end-group " + CRLF ) - - ELSEIF cOs == "OS/2" - - Fwrite( nLinkHandle, "LIBFILES = " + cgcclibsos2 + CRLF ) - - ELSE - - Fwrite( nLinkHandle, "LIBFILES = " + cDefgccLibs + CRLF ) - - ENDIF - - ENDIF - - Fwrite( nLinkHandle, "DEFFILE = " + CRLF ) - Fwrite( nLinkHandle, "HARBOURFLAGS = " + cDefHarOpts + CRLF ) - - IF lBcc - - Fwrite( nLinkHandle, "CFLAG1 = -OS $(CFLAGS) -d -L$(BHC)\lib;$(FWH)\lib -c" + CRLF ) - Fwrite( nLinkHandle, "CFLAG2 = -I$(BHC)\include;$(BCB)\include" + CRLF ) - - Fwrite( nLinkHandle, "RFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(BHC)\lib;$(FWH)\lib -Gn -M -m -s -Tpe" + If( lFWH, " -aa", IF( lMiniGui , " -aa" , " -ap" )) + CRLF ) - Fwrite( nLinkHandle, "IFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LINKER = ilink32" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "ALLOBJ = " + If( lFwh, "c0w32.obj", "c0x32.obj" ) + " $(OBJFILES)" + If( lextended, " $(OBJCFILES)", " " ) + CRLF ) - Fwrite( nLinkHandle, "ALLRES = $(RESFILES)" + CRLF ) - Fwrite( nLinkHandle, "ALLLIB = $(LIBFILES) import32.lib cw32.lib" + CRLF ) - Fwrite( nLinkHandle, ".autodepend" + CRLF ) - - ELSEIF lVcc - - Fwrite( nLinkHandle, "CFLAG1 = -I$(INCLUDE_DIR) -TP -W3 -nologo $(C_USR) $(CFLAGS)" + CRLF ) - Fwrite( nLinkHandle, "CFLAG2 = -c" + CRLF ) - Fwrite( nLinkHandle, "RFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LFLAGS = /LIBPATH:$(BCB)\lib;$(BHC)\lib;$(C4W)\lib /SUBSYSTEM:CONSOLE" + CRLF ) - Fwrite( nLinkHandle, "IFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LINKER = link" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "ALLOBJ = " + If( lCw, "$(C4W)\initc.obj", "" ) + "$(OBJFILES)" + If( lextended, " $(OBJCFILES)", " " ) + CRLF ) - Fwrite( nLinkHandle, "ALLRES = $(RESFILES)" + CRLF ) - Fwrite( nLinkHandle, "ALLLIB = $(LIBFILES) comdlg32.lib shell32.lib user32.lib gdi32.lib" + CRLF ) - - ELSEIF lGcc - - Fwrite( nLinkHandle, "CFLAG1 = " + If( At( "Linux", cOs ) > 0, "-I$(HB_INC_INSTALL)", " -I$(BHC)/include" ) + " -c -Wall" + CRLF ) - Fwrite( nLinkHandle, "CFLAG2 = " + If( At( "Linux", cOs ) > 0, "-L $(HB_LIB_INSTALL)", " -L $(BHC)/lib" ) + CRLF ) - Fwrite( nLinkHandle, "RFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LFLAGS = $(CFLAG2)" + CRLF ) - Fwrite( nLinkHandle, "IFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LINKER = gcc" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "ALLOBJ = $(OBJFILES) " + If( lextended, " $(OBJCFILES)", " " ) + CRLF ) - Fwrite( nLinkHandle, "ALLRES = $(RESFILES) " + CRLF ) - Fwrite( nLinkHandle, "ALLLIB = $(LIBFILES) " + CRLF ) - Fwrite( nLinkHandle, ".autodepend" + CRLF ) - - ENDIF - - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "#COMMANDS" + CRLF ) - - Aeval( aCommands, { | xItem | Fwrite( nLinkHandle, xitem[ 1 ] + CRLF ), Fwrite( nLinkHandle, xitem[ 2 ] + CRLF ), Fwrite( nLinkHandle, " " + CRLF ) } ) - - IF lBcc - - Fwrite( nLinkHandle, "#BUILD" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "$(PROJECT): $(CFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)" + CRLF ) - Fwrite( nLinkHandle, " $(BCB)\BIN\$(LINKER) @&&!" + CRLF ) - Fwrite( nLinkHandle, " $(LFLAGS) +" + CRLF ) - Fwrite( nLinkHandle, " $(ALLOBJ), +" + CRLF ) - Fwrite( nLinkHandle, " $(PROJECT),, +" + CRLF ) - Fwrite( nLinkHandle, " $(ALLLIB), +" + CRLF ) - Fwrite( nLinkHandle, " $(DEFFILE), +" + CRLF ) - Fwrite( nLinkHandle, " $(ALLRES) " + CRLF ) - Fwrite( nLinkHandle, "!" + CRLF ) - - ELSEIF lVcc - - Fwrite( nLinkHandle, "#BUILD" + CRLF ) - Fwrite( nLinkHandle, "" + CRLF ) - Fwrite( nLinkHandle, "$(PROJECT): $(CFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)" + CRLF ) - Fwrite( nLinkHandle, " $(BCB)\BIN\$(LINKER) @&&!" + CRLF ) - Fwrite( nLinkHandle, " $(LFLAGS)" + CRLF ) - Fwrite( nLinkHandle, " $(ALLOBJ) " + CRLF ) - Fwrite( nLinkHandle, " $(PROJECT)" + CRLF ) - Fwrite( nLinkHandle, " $(PROJECTMAP)" + CRLF ) - Fwrite( nLinkHandle, " $(ALLLIB) " + CRLF ) - Fwrite( nLinkHandle, " $(DEFFILE) " + CRLF ) - Fwrite( nLinkHandle, " $(ALLRES) " + CRLF ) - Fwrite( nLinkHandle, "!" + CRLF ) - - ELSEIF lGcc - - Fwrite( nLinkHandle, "#BUILD" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "$(PROJECT): $(CFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)" + CRLF ) - - IF At( 'Linux', cOs ) > 0 - - Fwrite( nLinkHandle, " $(LINKER) @&&!" + CRLF ) - - ELSE - - Fwrite( nLinkHandle, " $(BCB)\bin\$(LINKER) @&&!" + CRLF ) - - ENDIF - - Fwrite( nLinkHandle, " $(PROJECT) " + CRLF ) - Fwrite( nLinkHandle, " $(ALLOBJ) " + CRLF ) - Fwrite( nLinkHandle, " $(LFLAGS) " + CRLF ) - Fwrite( nLinkHandle, " $(ALLLIB) " + CRLF ) - Fwrite( nLinkHandle, "!" + CRLF ) - - ENDIF - -RETURN nil - -FUNCTION CompUpdatedfiles() - - LOCAL cComm - LOCAL cOld - LOCAL nPos - LOCAL nCount - LOCAL nFiles - LOCAL aCtocompile := {} - LOCAL aOrder := Listasarray2( aBuildOrder[ 2 ], " " ) - LOCAL lEnd - LOCAL cErrText := "" - LOCAL xItem - LOCAL nObjPos - FOR nCount := 1 TO Len( aOrder ) - - IF !lextended - - IF aOrder[ nCount ] == "$(CFILES)" - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".prg.c:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ENDIF - - FOR nFiles := 1 TO Len( aPrgs ) - - xItem := Substr( aPrgs[ nFiles ], Rat( If( lgcc, '/', '\' ), aPrgs[ nFiles ] ) + 1 ) - nPos := Ascan( aCs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) - nObjPos := Ascan( aobjs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) - - IF fileisnewer( aprgs[ nFiles ], aobjs[ nObjPos ] ) - - IF nPos > 0 - - Aadd( aCtocompile, acs[ nPos ] ) - cComm := Strtran( cComm, "o$*", "o" + aCs[ nPos ] ) - cComm := Strtran( cComm, "$**", aPrgs[ nFiles ] ) - Outstd( cComm ) - Outstd( hb_osnewline() ) - ! ( cComm ) - cErrText := Memoread( 'Test.out' ) - lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText - - IF !lIgnoreErrors .and. lEnd - - QUIT - - ELSE - - Ferase( 'Test.out' ) - - ENDIF - - cComm := cold - - ENDIF - - ENDIF - - NEXT - - ENDIF - - IF aOrder[ nCount ] == "$(OBJFILES)" - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.o:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.obj:" } ) - - ENDIF - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := ccomm - - ENDIF - - IF Len( aCtoCompile ) >= 1 - - FOR nFiles := 1 TO Len( aCs ) - - nPos := Ascan( aCs, { | x | Left( x, At( ".", x ) ) == Left( aCtoCompile[ nfiles ], At( ".", aCtoCompile[ nfiles ] ) ) } ) - - IF nPos == 0 - - Aadd( aCtoCompile, acs[ nFiles ] ) - - ENDIF - - NEXT - - ENDIF - - FOR nFiles := 1 TO Len( aCtocompile ) - - xItem := Substr( aCtocompile[ nFiles ], Rat( If( lgcc, '/', '\' ), aCtocompile[ nFiles ] ) + 1 ) - nPos := Ascan( aObjs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( aCtocompile[ nFiles ], At( ".", xItem ) ) } ) - - IF nPos > 0 - - cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) - cComm := Strtran( cComm, "$**", aCtocompile[ nFiles ] ) - Outstd( " " ) - - Outstd( cComm ) - Outstd( hb_osnewline() ) - ! ( cComm ) - ccomm := cold - - ENDIF - - NEXT - - ENDIF - - ELSE /**************Extended mode ******/ //// - - IF aOrder[ nCount ] == "$(CFILES)" - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".c.obj:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".C.OBJ:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := cComm - - ENDIF - - ENDIF - - FOR nFiles := 1 TO Len( acs ) - - xItem := Substr( acs[ nFiles ], Rat( If( lgcc, '/', '\' ), acs[ nFiles ] ) + 1 ) - nPos := Ascan( aObjsc, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xitem, At( ".", xitem ) ) } ) - - IF fileisnewer( aCs[ nFiles ], aobjsc[ nPos ] ) - - IF nPos > 0 - - cComm := Strtran( cComm, "o$*", "o" + aobjsc[ nPos ] ) - cComm := Strtran( cComm, "$**", acs[ nFiles ] ) - cComm += " > Test.out" - Outstd( cComm ) - Outstd( hb_osnewline() ) - ! ( cComm ) - cErrText := Memoread( 'Test.out' ) - lEnd := 'Error' $ cErrText - - IF !lIgnoreErrors .and. lEnd - - QUIT - - ELSE - - Ferase( 'Test.out' ) - - ENDIF - - cComm := cold - - ENDIF - - ENDIF - - NEXT - - ENDIF - - IF aOrder[ nCount ] == "$(OBJFILES)" - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".prg.o:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".prg.obj:" } ) - - ENDIF - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cOld := ccomm - - ELSE - - IF lGcc - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".PRG.O:" } ) - - ELSE - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".PRG.OBJ:" } ) - - ENDIF - - ENDIF - - FOR nFiles := 1 TO Len( aprgs ) - - xItem := Substr( aprgs[ nFiles ], Rat( If( lgcc, '/', '\' ), aprgs[ nFiles ] ) + 1 ) - nPos := Ascan( aobjs, { | x | x := Substr( x, Rat( If( lgcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xItem, At( ".", xitem ) ) } ) - - IF fileisnewer( aprgs[ nFiles ], aobjs[ npos ] ) - - IF nPos > 0 - - cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) - cComm := Strtran( cComm, "$**", aprgs[ nFiles ] ) - cComm += " > Test.out" - Outstd( " " ) - Outstd( cComm ) - Outstd( hb_osnewline() ) - ! ( cComm ) - cErrText := Memoread( 'Test.out' ) - lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText - - IF !lIgnoreErrors .and. lEnd - - QUIT - - ELSE - - Ferase( 'Test.out' ) - - ENDIF - - ccomm := cold - - ENDIF - - ENDIF - - NEXT - - ENDIF - - ENDIF - - IF aOrder[ nCount ] == "$(RESDEPEN)" - - nPos := Ascan( aCommands, { | x | x[ 1 ] == ".rc.res:" } ) - - IF nPos > 0 - - cComm := aCommands[ nPos, 2 ] - cold := ccomm - - ENDIF - - FOR nFiles := 1 TO Len( aRes ) - - IF !Empty( ares[ nFiles ] ) - - cComm := Strtran( cComm, "$<", aRes[ nFiles ] ) - Outstd( " " ) - ! ( cComm ) - - ENDIF - ccomm := cold - NEXT - - ENDIF - - NEXT - -RETURN nil - -FUNCTION fileisnewer( cFile, as ) - - LOCAL nCount := 0 - - IF !lextended - - FOR nCount := 1 TO Len( aPrgs ) - - adir := { cFile,, hbmake_filedate( cFile ), hbmake_filetime( cFile ), ; - as[ nCount ], hbmake_filedate( as[ nCount ] ), hbmake_filetime( as[ nCount ] ) } - - IF Empty( adir[ 7 ] ) - - adir[ 2 ] := .t. - - ELSE - - adir[ 2 ] := td2jul( adir[ 4 ], adir[ 3 ] ) > td2jul( adir[ 7 ], adir[ 6 ] ) - - ENDIF - - NEXT - - ELSE - - adir := { cFile,, hbmake_filedate( cFile ), hbmake_filetime( cFile ), ; - as, hbmake_filedate( as ), hbmake_filetime( as ) } - - IF Empty( adir[ 7 ] ) - - adir[ 2 ] := .t. - - ELSE - - adir[ 2 ] := td2jul( adir[ 4 ], adir[ 3 ] ) > td2jul( adir[ 7 ], adir[ 6 ] ) - - ENDIF - - ENDIF - -RETURN aDir[ 2 ] - -FUNC crtlibmakfile( cFile ) - - LOCAL ain := {} - LOCAL aOut := {} - LOCAL aSrc := Directory( "*.prg" ) - LOCAL nLenaSrc := Len( asrc ) - LOCAL nLenaOut - - LOCAL aOutC := {} - LOCAL aSrcC := Directory( "*.c" ) - LOCAL cOs := "Win32" - LOCAL cCompiler := "BCC" - LOCAL cfwhpath := Left( cfile, At( '.', cfile ) - 1 ) + Space( 40 ) - - LOCAL lAutomemvar := .f. - LOCAL lvarismemvar := .f. - LOCAL ldebug := .f. - LOCAL lSupressline := .f. - LOCAL cDefHarOpts := "" - LOCAL cObjDir := 'obj' + Space( 20 ) - LOCAL lCompMod := .f. - LOCAL x - LOCAL nPos as numeric - LOCAL lGenppo := .f. - LOCAL getlist := {} - LOCAL citem := "" - LOCAL cExt := "" - LOCAL cDrive := "" - LOCAL cPath := "" - LOCAL cTest := "" - LOCAL cLast := '' - LOCAL cUserdef := Space( 40 ) - LOCAL cUserInclude := Space( 40 ) - LOCAL nWriteFiles := 0 - - nLinkHandle := Fcreate( cFile ) - WriteMakeFileHeader() - CLS - Setcolor( 'w/b+,b+/w,w+/b,w/b+,w/b,w+/b' ) - @ 0, 0, Maxrow(), Maxcol() BOX( Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 ) + Space( 1 ) ) - ATTENTION( aLangMessages[ 27 ], 0 ) - - @ 1, 1 SAY "Select Os" - @ 1, 12 GET cos radio { "Win32", "OS/2", "Linux" } - @ 1, 23 SAY "Select C Compiler" - @ 1, 40 GET cCompiler radio { "BCC", "MSVC", "GCC" } - - READ - - SET CURSOR ON - - @ 4, 1 SAY "Library name with our extention" GET cfwhpath PICT "@s15" - @ 4, 40 SAY "Obj Files Dir" GET cObjDir PICT "@s15" - - ATTENTION( "Harbour Options", 5 ) - -#ifdef HB_COMPAT_C53 - @ 6, 1 GET lautomemvar checkbox caption "Automatic memvar declaration" - @ 6, 40 GET lvarismemvar checkbox caption "Variables are assumed M->" - @ 7, 1 GET lDebug checkbox caption "Debug info" - @ 7, 40 GET lSupressline checkbox caption "Suppress line number information" - @ 8, 1 GET lGenppo checkbox caption "Generate pre-processed output" - @ 8, 40 GET lCompMod checkbox caption "compile module only" -#endif - @ 9, 1 SAY "User Defines " GET cUserDef PICT "@s15" - @ 9, 40 SAY "User include Path" GET cUserInclude PICT "@s15" - - READ - - IF !Empty( cUserDef ) - - cDefHarOpts += " -D" + Alltrim( cUserDef ) + " " - - ENDIF - - IF !Empty( cUserInclude ) - - cDefHarOpts += " -I" + Alltrim( cUserInclude ) + " " - - ENDIF - - lBcc := IF( At( "BCC", cCompiler ) > 0, .t., .f. ) - lVcc := IF( At( "MSVC", cCompiler ) > 0, .t., .f. ) - lGcc := IF( At( "GCC", cCompiler ) > 0, .t., .f. ) - cObjDir := Alltrim( cObjDir ) - - IF !Empty( cobjDir ) - -#ifdef HB_COMPAT_C53 - IF Dirchange( cobjDir ) != 0 - Makedir( cobjDir ) - ELSE - Dirchange( '..' ) - ENDIF -#endif - - ENDIF - - amacros := GetSourceDirMacros( lgcc, cos ) - - IF lGcc - - cObjDir := Alltrim( cObjDir ) - - IF !Empty( cObjDir ) - - cObjDir += '/' - - ENDIF - - cTest := cObjDir + '/' - - ELSE - cObjDir := Alltrim( cObjDir ) - - IF !Empty( cObjDir ) - - cObjDir += '\' - - ENDIF - - cTest := cObjDir + '\' - - ENDIF - - Aeval( amacros, { | x, y | cItem := Substr( x[ 2 ], 1, Len( x[ 2 ] ) ), If( At( citem, cTest ) > 0, ( amacros[ y, 1 ] := 'OBJ', amacros[ y, 2 ] := cObjDir ), ) } ) - - IF lAutomemvar - - cDefHarOpts += " -a " - - ENDIF - - IF lvarismemvar - - cDefHarOpts += " -v " - - ENDIF - - IF ldebug - - cDefHarOpts += " -b " - - ENDIF - - IF lSupressline - - cDefHarOpts += " -l " - - ENDIF - - IF lGenppo - - cDefHarOpts += " -p " - - ENDIF - - IF lCompmod - - cDefHarOpts += " -m " - - ENDIF - - IF lBcc - - Aadd( aCommands, { ".cpp.obj:", "$(BCB)\BIN\bcc32 $(CFLAG1) $(CFLAG2) -o$* $*" } ) - Aadd( aCommands, { ".c.obj:", "$(BCB)\BIN\bcc32 -I$(BHC)\include $(CFLAG1) $(CFLAG2) -o$* $**" } ) - - IF lextended - - Aadd( aCommands, { ".prg.obj:", "$(BHC)\bin\harbour -n -go -I$(BHC)\include $(HARBOURFLAGS) -I$(FWH)\include -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "$(BHC)\bin\harbour -n -I$(BHC)\include $(HARBOURFLAGS) -I$(FWH)\include -o$* $**" } ) - - ENDIF - - Aadd( aCommands, { ".rc.res:", "$(BCB)\BIN\brcc32 $(RFLAGS) $<" } ) - - ELSEIF lGcc - - IF At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0 .or. cOs == "Linux" - - Aadd( aCommands, { ".cpp.o:", "gcc $(CFLAG1) $(CFLAG2) -o$* $*" } ) - Aadd( aCommands, { ".c.o:", "gcc -I$(HB_INC_INSTALL) $(CFLAG1) $(CFLAG2) -I. -o$* $**" } ) - - IF lextended - - Aadd( aCommands, { ".prg.o:", "harbour -n $(HARBOURFLAGS) -I$(HB_INC_INSTALL) -I. -go -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "harbour -n $(HARBOURFLAGS) -I$(HB_INC_INSTALL) -I. -o$* $**" } ) - - ENDIF - - ELSE - - Aadd( aCommands, { ".cpp.o:", "$(BCB)\bin\gcc $(CFLAG1) $(CFLAG2) -o$* $*" } ) - Aadd( aCommands, { ".c.o:", "$(BCB)\bin\gcc -I$(BHC)/include $(CFLAG1) $(CFLAG2) -I. -o$* $**" } ) - - IF lextended - - Aadd( aCommands, { ".prg.o:", "$(BHC)\bin\harbour -n -go -I$(BHC)/include $(HARBOURFLAGS) -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "$(BHC)\bin\harbour -n -I$(BHC)/include $(HARBOURFLAGS) -o$* $**" } ) - - ENDIF - - ENDIF - - ELSEIF lVcc - - Aadd( aCommands, { ".cpp.obj:", "$(BCB)\bin\cl $(CFLAG1) $(CFLAG2) -Fo$* $*" } ) - Aadd( aCommands, { ".c.obj:", "$(BCB)\bin\cl -I$(BHC)\include $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) - - IF lextended - - Aadd( aCommands, { ".prg.obj:", "$(BHC)\bin\harbour -go -n -I$(BHC)\include $(HARBOURFLAGS) -I$(C4W)\include -o$* $**" } ) - - ELSE - - Aadd( aCommands, { ".prg.c:", "$(BHC)\bin\harbour -n -I$(BHC)\include $(HARBOURFLAGS) -I$(C4W)\include -o$* $**" } ) - - ENDIF - - Aadd( aCommands, { ".rc.res:", "$(BCB)\BIN\rc $(RFLAGS) $<" } ) - - ENDIF - - attention( 'Spacebar to select, Enter to continue process', 22 ) - - IF !lRecurse - - ain := GetSourceFiles( .f., lGcc, cOs ) - nLenaSrc := Len( ain ) - - ELSE - - ain := GetSourceFiles(, lGcc, cOs ) - nLenaSrc := Len( ain ) - - ENDIF - - aOut := Aclone( aIn ) - pickarry( 10, 15, 19, 64, aIn, aOut ) - nLenaOut := Len( aOut ) - - Aeval( aout, { | x, y | HB_SYMBOL_UNUSED( x ), aout[ y ] := Trim( Substr( aOut[ y ], 1, At( ' ', aout[ y ] ) ) ) } ) - Aeval( aout, { | xItem | If( At( '.c', xItem ) > 0 .or. At( '.C', xItem ) > 0, Aadd( aoutc, xitem ), ) } ) - Aeval( aoutc, { | x, z | citem := x, z := Ascan( aout, { | t | t = citem } ), If( z > 0, Asize( Adel( aout, z ), Len( aout ) - 1 ), ) } ) - - aOut := Asort( aOut ) - aPrgs := Aclone( aout ) - - aObjs := Aclone( aout ) - Aeval( aobjs, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), If( !lGcc, aObjs[ x ] := cObjDir + cTest + "." + exte( cExt, 2 ), aObjs[ x ] := cObjDir + cTest + "." + exte( cExt, 3 ) ) } ) - aCs := Aclone( aoutc ) - - IF !lextended - - Aeval( aOutc, { | xItem | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), If( !lGcc, Aadd( aObjs, cObjDir + cTest + "." + exten( cExt, 2 ) ), Aadd( aObjs, cObjDir + cTest + "." + exten( cExt, 1 ) ) ) } ) - Aeval( aout, { | xItem | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cExt := Substr( cExt, 2 ), Aadd( aCs, cObjDir + cTest + "." + exte( cExt, 1 ) ) } ) - - ELSE - - aObjsc := Aclone( aoutc ) - Aeval( aoutc, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), If( !lGcc, aObjsc[ x ] := cObjDir + cTest + "." + exten( cExt, 2 ), aObjsc[ x ] := cObjDir + cTest + "." + exten( cExt, 1 ) ) } ) - - ENDIF - - FOR x := 1 TO Len( amacros ) - - IF !Empty( amacros[ x, 2 ] ) - - cItem := amacros[ x, 2 ] - nPos := Ascan( aprgs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - Aeval( aprgs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, aprgs[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + ')\' ), ) } ) - - IF !amacros[ x, 3 ] - - Fwrite( nLinkHandle, amacros[ x, 1 ] + ' = ' + Left( amacros[ x, 2 ], Len( amacros[ x, 2 ] ) - 1 ) + " " + CRLF ) - amacros[ x, 3 ] := .t. - - ENDIF - - ENDIF - - nPos := Ascan( acs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - Aeval( acs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, acs[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + If( lgcc, ")/", ')\' ) ), ) } ) - - IF !amacros[ x, 3 ] - - Fwrite( nLinkHandle, amacros[ x, 1 ] + ' = ' + Left( amacros[ x, 2 ], Len( amacros[ x, 2 ] ) - 1 ) + " " + CRLF ) - amacros[ x, 3 ] := .t. - - ENDIF - - ENDIF - - nPos := Ascan( aObjs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - IF !Empty( cObjDir ) - - Aeval( aObjs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, aObjs[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + If( lgcc, ")/", ')\' ) ), ) } ) - Fwrite( nLinkHandle, amacros[ x, 1 ] + ' = ' + Left( amacros[ x, 2 ], Len( amacros[ x, 2 ] ) - 1 ) + " " + CRLF ) - - ENDIF - - ENDIF - - IF lExtended - - nPos := Ascan( aObjsc, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cpath == citem } ) - - IF nPos > 0 - - IF !Empty( cObjDir ) - - Aeval( aObjsc, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), If( cPath == citem, aObjsc[ b ] := Strtran( a, cpath, "$(" + amacros[ x, 1 ] + If( lgcc, ")/", ')\' ) ), ) } ) - - ENDIF - - ENDIF - - ENDIF - - ENDIF - - NEXT - - IF lGcc - - IF At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0 .or. cOs == "Linux" - - Fwrite( nLinkHandle, "PROJECT = " + Alltrim( cfwhpath ) + ".a " + CRLF ) - - ELSE - - Fwrite( nLinkHandle, "PROJECT = " + Alltrim( Lower( cfwhpath ) ) + ".a " + CRLF ) - - ENDIF - ELSE - - Fwrite( nLinkHandle, "PROJECT = " + Alltrim( Lower( cfwhpath ) ) + ".lib " + CRLF ) - - ENDIF - - IF !lextended - - nWriteFiles := 0 - Fwrite( nLinkHandle, "OBJFILES =" ) - - IF Len( aObjs ) < 1 - - Fwrite( nLinkHandle, + " $(OB) " + CRLF ) - - ELSE - - nWriteFiles := 0 - Aeval( aObjs, { | x, i | nWriteFiles ++, If( i <> Len( aobjs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - nWriteFiles := 0 - Fwrite( nLinkHandle, "CFILES =" ) - - IF Len( aCs ) < 1 - - Fwrite( nLinkHandle, + " $(CF)" + CRLF ) - - ELSE - - Aeval( aCs, { | x, i | nWriteFiles ++, If( i <> Len( aCs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(CF) " + CRLF ) ) } ) - - ENDIF - - Fwrite( nLinkHandle, "PRGFILE =" ) - nWriteFiles := 0 - - IF Len( aPrgs ) < 1 - - Fwrite( nLinkHandle, + " $(PS)" + CRLF ) - - ELSE - - Aeval( aPrgs, { | x, i | nWriteFiles ++, If( i <> Len( aPrgs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) - - ENDIF - - ELSE /****extended moded ****/ - - Fwrite( nLinkHandle, "OBJFILES =" ) - nWriteFiles := 0 - - IF Len( aObjs ) < 1 - - Fwrite( nLinkHandle, + " $(OB) " + CRLF ) - - ELSE - - Aeval( aObjs, { | x, i | nWriteFiles ++, If( i <> Len( aobjs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - Fwrite( nLinkHandle, "PRGFILES =" ) - nWriteFiles := 0 - - IF Len( aPrgs ) < 1 - - Fwrite( nLinkHandle, + " $(PS)" + CRLF ) - - ELSE - - Aeval( aPrgs, { | x, i | nWriteFiles ++, If( i <> Len( aPrgs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) - - ENDIF - - nWriteFiles := 0 - - IF Len( aObjsc ) > 0 - - Fwrite( nLinkHandle, "OBJCFILES =" ) - - IF Len( aObjsc ) < 1 - - Fwrite( nLinkHandle, + " $(OB) " + CRLF ) - - ELSE - - Aeval( aObjsc, { | x, i | nWriteFiles ++, If( i <> Len( aobjsc ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - ENDIF - - nWriteFiles := 0 - - IF Len( acs ) > 0 - - Fwrite( nLinkHandle, "CFILES =" ) - - IF Len( aCs ) < 1 - - Fwrite( nLinkHandle, + " $(CF)" + CRLF ) - - ELSE - - Aeval( aCs, { | x, i | nWriteFiles ++, If( i <> Len( aCs ), Fwrite( nLinkHandle, ' ' + Alltrim( x ) + If( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), Fwrite( nLinkHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) - - ENDIF - - ENDIF - - ENDIF - - Fwrite( nLinkHandle, "RESFILES =" + CRLF ) - Fwrite( nLinkHandle, "RESDEPEN = $(RESFILES)" + CRLF ) - Fwrite( nLinkHandle, "DEFFILE = " + CRLF ) - Fwrite( nLinkHandle, "HARBOURFLAGS = " + cDefHarOpts + CRLF ) - - IF lBcc - - Fwrite( nLinkHandle, "CFLAG1 = -OS $(CFLAGS) -d -L$(BHC)\lib;$(FWH)\lib -c" + CRLF ) - Fwrite( nLinkHandle, "CFLAG2 = -I$(BHC)\include;$(BCB)\include" + CRLF ) - Fwrite( nLinkHandle, "RFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LFLAGS = /P32 /0" + CRLF ) - Fwrite( nLinkHandle, "IFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LINKER = tlib $(LFLAGS) $(PROJECT)" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES)" + CRLF ) - Fwrite( nLinkHandle, "ALLRES = $(RESFILES)" + CRLF ) - Fwrite( nLinkHandle, "ALLLIB = " + CRLF ) - Fwrite( nLinkHandle, ".autodepend" + CRLF ) - - ELSEIF lVcc - - Fwrite( nLinkHandle, "CFLAG1 = -I$(INCLUDE_DIR) -TP -W3 -nologo $(C_USR) $(CFLAGS)" + CRLF ) - Fwrite( nLinkHandle, "CFLAG2 = -c" + CRLF ) - Fwrite( nLinkHandle, "RFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "IFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LINKER = lib $(PROJECT)" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES) " + CRLF ) - Fwrite( nLinkHandle, "ALLRES = $(RESFILES)" + CRLF ) - Fwrite( nLinkHandle, "ALLLIB = " + CRLF ) - - ELSEIF lGcc - - Fwrite( nLinkHandle, "CFLAG1 = " + If( At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0, "-I$(HB_INC_INSTALL)", " -I$(BHC)/include" ) + " -c -Wall" + CRLF ) - Fwrite( nLinkHandle, "CFLAG2 = " + If( At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0, "-L $(HB_LIB_INSTALL)", " -L $(BHC)/lib" ) + CRLF ) - Fwrite( nLinkHandle, "RFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "LFLAGS = " + CRLF ) - Fwrite( nLinkHandle, "IFLAGS = " + CRLF ) - - IF At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0 .or. cOs == "Linux" .or. At( "linux", Lower( Os() ) ) > 0 - - Fwrite( nLinkHandle, "LINKER = ar -M " + CRLF ) - - ELSE - - Fwrite( nLinkHandle, "LINKER = $(BCB)\ar -M " + CRLF ) - - ENDIF - - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES) " + CRLF ) - Fwrite( nLinkHandle, "ALLRES = $(RESFILES) " + CRLF ) - Fwrite( nLinkHandle, "ALLLIB = $(LIBFILES) " + CRLF ) - Fwrite( nLinkHandle, ".autodepend" + CRLF ) - - ENDIF - - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "#COMMANDS" + CRLF ) - Aeval( aCommands, { | xItem | Fwrite( nLinkHandle, xitem[ 1 ] + CRLF ), Fwrite( nLinkHandle, xitem[ 2 ] + CRLF ), Fwrite( nLinkHandle, " " + CRLF ) } ) - - IF lBcc - - Fwrite( nLinkHandle, "#BUILD" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "$(PROJECT): $(CFILES) $(OBJFILES)" + CRLF ) - Fwrite( nLinkHandle, " $(BCB)\BIN\$(LINKER) @&&!" + CRLF ) - Fwrite( nLinkHandle, " $(ALLOBJ)" + CRLF ) - Fwrite( nLinkHandle, "!" + CRLF ) - - ELSEIF lVcc - - Fwrite( nLinkHandle, "#BUILD" + CRLF ) - Fwrite( nLinkHandle, "" + CRLF ) - Fwrite( nLinkHandle, "$(PROJECT): $(CFILES) $(OBJFILES)" + CRLF ) - Fwrite( nLinkHandle, " $(BCB)\BIN\$(LINKER) @&&!" + CRLF ) - Fwrite( nLinkHandle, " $(ALLOBJ) " + CRLF ) - Fwrite( nLinkHandle, "!" + CRLF ) - - ELSEIF lGcc - - Fwrite( nLinkHandle, "#BUILD" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "$(PROJECT): $(CFILES) $(OBJFILES) " + CRLF ) - - IF At( "linux", Getenv( "HB_ARCHITECTURE" ) ) > 0 .or. cOs == "Linux" - - Fwrite( nLinkHandle, " $(LINKER) @&&!" + CRLF ) - - ELSE - - Fwrite( nLinkHandle, " $(BCB)\$(LINKER) @&&!" + CRLF ) - - ENDIF - - Fwrite( nLinkHandle, " $(PROJECT) " + CRLF ) - Fwrite( nLinkHandle, " $(ALLOBJ) " + CRLF ) - Fwrite( nLinkHandle, "!" + CRLF ) - - ENDIF - -RETURN nil - -FUNCTION setlibBuild() - - LOCAL cRead as String - LOCAL nPos as Numeric - LOCAL aMacro as Array - LOCAL aTemp as Array - LOCAL nCount as Numeric - LOCAL aCurobjs as Array - LOCAL nObjPos as Numeric - LOCAL cLib - - cRead := Alltrim( readln( @leof ) ) - nLinkHandle := Fcreate( clinker ) - szProject := cRead - amacro := Listasarray2( cRead, ":" ) - - IF Len( amacro ) > 1 - - aTemp := Listasarray2( amacro[ 2 ], " " ) - Aeval( aTemp, { | xItem | Aadd( aBuildOrder, xItem ) } ) - - ENDIF - - Aadd( aBuildOrder, amacro[ 1 ] ) - cRead := Strtran( cRead, "@&&!", "" ) - amacro := Listasarray2( cRead, '\' ) - Aeval( amacro, { | xMacro | Findmacro( xMacro, @cRead ) } ) - - IF lbcc .or. lVcc - - cLinkcomm := cRead + " @" + cLinker - - ELSE - - cLinkcomm := cRead + " < " + cLinker - - ENDIF - - FOR nPos := 1 TO 7 - - cRead := Alltrim( readln( @leof ) ) - amacro := Listasarray2( cRead, " " ) - - FOR ncount := 1 TO Len( amacro ) - - IF At( "$", amacro[ nCount ] ) > 0 - - IF ( amacro[ nCount ] = "$(PROJECT)" ) .and. lGcc - - Findmacro( amacro[ nCount ], @cRead ) - Fwrite( nLinkHandle, "CREATE " + " lib" + cRead + CRLF ) - cLib := "lib" + cRead - - ELSEIF ( amacro[ nCount ] == "$(ALLOBJ)" ) - - Findmacro( amacro[ nCount ], @cRead ) - aCurObjs := Listasarray2( cRead, " " ) - - FOR nObjPos := 1 TO Len( aCurObjs ) - - IF lGcc - - Fwrite( nLinkhandle, "ADDMOD " + aCurObjs[ nObjPos ] + CRLF ) - - ENDIF - - IF lBcc .or. lVcc - - IF nObjPos < Len( aCurObjs ) - - Fwrite( nLinkhandle, "+-" + aCurObjs[ nObjPos ] + " &" + CRLF ) - - ELSE - - Fwrite( nLinkhandle, "+-" + aCurObjs[ nObjPos ] + CRLF ) - - ENDIF - - ENDIF - - NEXT - - ENDIF - - ENDIF - - NEXT - - NEXT - - IF lGcc - - Fwrite( nLinkHandle, "SAVE" + CRLF ) - Fwrite( nLinkHandle, "END " + CRLF ) - - ENDIF - - Fclose( nLinkhandle ) - - IF lLinux - - cLinkComm += " || rm -f " + cLib - - ENDIF - -RETURN nil - -FUNC FindCfile( citem, aSrcc ) - - LOCAL nReturnPos := 0 - - nReturnPos := Ascan( aSrcc, { | x | Lower( x[ 1 ] ) == cItem } ) - -RETURN nReturnPos - -#ifndef __HARBOUR__ -FUNCTION HB_OSNEWLINE() - - RETURN Chr( 13 ) + Chr( 10 ) -#endif - -FUNCTION checkiffile( cFile ) - - LOCAL cNextLine := '' - LOCAL cCommand := '' - LOCAL cTemp - - cTemp := Substr( cFile, At( " ", cFile ) + 1 ) - - IF File( cTemp ) - - cNextLine := Trim( Substr( ReadLN( @lEof ), 1 ) ) - - IF At( "! ", cNextLine ) > 0 - - cCommand := Substr( cNextLine, At( ' ', cNextLine ) + 1 ) - RUN( ccommand ) - - ENDIF - - RETURN .T. - - ENDIF - -RETURN .F. - -FUNCTION checkstdout( cText ) - - cText := Strtran( cText, "!stdout", "" ) - Outstd( cText ) - -RETURN nil - -FUNCTION CheckifDef( cTemp ) - - LOCAL nPos - LOCAL cRead := "" - LOCAL aSet := {} - LOCAL nMakePos - - IF cTemp == "!endif" - - RETURN nil - - ENDIF - - WHILE At( "!endif", cRead ) == 0 - - cRead := Trim( Substr( ReadLN( @lEof ), 1 ) ) - - IF At( "!endif", cRead ) > 0 - - FT_FSKIP( - 1 ) - EXIT - - ENDIF - - cTemp := Strtran( cTemp, "!ifdef ", "" ) - - IF At( '=', cRead ) > 0 - - IF At( "\..", cRead ) > 0 - - cRead := Substr( cRead, 1, At( "\..", cRead ) - 1 ) - - ELSEIF At( "/..", cRead ) > 0 - - cRead := Substr( cRead, 1, At( "/..", cRead ) - 1 ) - - ENDIF - - aSet := Listasarray2( cRead, "=" ) - nPos := Ascan( adefines, { | x | x[ 1 ] == cTemp } ) - - IF nPos > 0 - - cRead := Alltrim( Strtran( aset[ 1 ], "$(", "" ) ) - cRead := Strtran( cRead, ")", "" ) - nMakePos := Ascan( amaCros, { | x | x[ 1 ] == cRead } ) - - IF nMakePos == 0 - - Aadd( amacros, { aset[ 1 ], aset[ 2 ] } ) - - ENDIF - - ELSE /* Locate For !Else */ - - WHILE At( "!endif", cRead ) == 0 - - cRead := Trim( Substr( ReadLN( @lEof ), 1 ) ) - - IF At( "!else", cRead ) > 0 - - WHILE At( "!endif", cRead ) == 0 - - cRead := Trim( Substr( ReadLN( @lEof ), 1 ) ) - - IF At( "!endif", cRead ) > 0 - - FT_FSKIP( - 1 ) - EXIT - - ENDIF - - aSet := Listasarray2( cRead, "=" ) - Aadd( amacros, { aset[ 1 ], aset[ 2 ] } ) - - ENDDO - - ENDIF - - ENDDO - - ENDIF - - ELSEIF At( '!stdout', cRead ) > 0 - - checkstdout( cRead ) - - ENDIF - - ENDDO - -RETURN nil - - - -FUNCTION BuildBorCfgFile() - - LOCAL nCfg - - IF !File( GetMakeDir() + '\bin\harbour.cfg' ) - - nCfg := Fcreate( GetMakeDir() + '\bin\harbour.cfg' ) - Fwrite( nCfg, "CC=BCC32" + CRLF ) - Fwrite( nCfg, "CFLAGS= -c " + Replacemacros( "-I$(BHC)\include -OS $(CFLAGS) -d -L$(BHC)\lib" ) + CRLF ) - Fwrite( nCfg, "VERBOSE=NO" + CRLF ) - Fwrite( nCfg, "DELTMP=YES" + CRLF ) - Fclose( nCfg ) - - ENDIF - -RETURN Nil - -FUNCTION BuildMSCCfgFile() - - LOCAL nCfg - - IF !File( GetMakeDir() + '\bin\harbour.cfg' ) - - nCfg := Fcreate( GetMakeDir() + '\bin\harbour.cfg' ) - Fwrite( nCfg, "CC=cl" + CRLF ) - Fwrite( nCfg, "CFLAGS= -c " + Replacemacros( "-I$(INCLUDE_DIR) -TP -W3 -nologo $(C_USR) $(CFLAGS)" ) + CRLF ) - Fwrite( nCfg, "VERBOSE=NO" + CRLF ) - Fwrite( nCfg, "DELTMP=YES" + CRLF ) - Fclose( nCfg ) - - ENDIF - -RETURN Nil - -FUNCTION BuildGccCfgFile() - - LOCAL nCfg - LOCAL cDir := GetMakeDir() - LOCAL cBhc := Alltrim( Strtran( replacemacros( '$(BHC)' ), '\', '/' ) ) - - cDir := Strtran( cDir, '/', '\' ) - - IF !File( cdir + '\bin\harbour.cfg' ) - - nCfg := Fcreate( cdir + '\bin\harbour.cfg' ) - Fwrite( nCfg, "CC=gcc" + CRLF ) - Fwrite( nCfg, "CFLAGS= -c " + Replacemacros( "-I" + cBhc + "/include $(C_USR) -L" + cBhc + "/lib" ) + CRLF ) - Fwrite( nCfg, "VERBOSE=NO" + CRLF ) - Fwrite( nCfg, "DELTMP=YES" + CRLF ) - Fclose( nCfg ) - - ENDIF - -RETURN Nil - -FUNCTION BuildGccCfgFileL() - - LOCAL nCfg - - IF !File( '/etc/harbour.cfg' ) - - nCfg := Fcreate( '/etc/harbour.cfg' ) - Fwrite( nCfg, "CC=gcc" + CRLF ) - Fwrite( nCfg, "CFLAGS= -c -I/usr/include/harbour" + CRLF ) - Fwrite( nCfg, "VERBOSE=YES" + CRLF ) - Fwrite( nCfg, "DELTMP=YES" + CRLF ) - Fclose( nCfg ) - - ENDIF - -RETURN Nil - -FUNCTION findHarbourcfg( cCfg ) - - LOCAL cPath AS STRING := '' - LOCAL lFound AS LOGICAL := .f. - LOCAL cEnv AS STRING - LOCAL aEnv as Array of String - LOCAL lLinux := At( 'linux', Lower( Os() ) ) > 0 - LOCAL nPos - - IF !lLinux .or. lOs2 - - cEnv := Gete( "PATH" ) + ";" + Curdir() - aEnv := Listasarray2( cEnv, ";" ) - - FOR nPos := 1 TO Len( aEnv ) - - IF File( aenv[ nPos ] + '\harbour.cfg' ) - - cPath := aenv[ nPos ] - lFound := .T. - EXIT - - ENDIF - - NEXT - - ELSE - - IF File( '/etc/harbour.cfg' ) - - lFound := .t. - cPath := '/etc/harbour.cfg' - - ENDIF - - IF !lfound - - IF File( '/usr/local/etc/harbour.cfg' ) - - lFound := .t. - cPath := '/usr/local/etc/harbour.cfg' - - ENDIF - - ENDIF - - ENDIF - - cCfg := cPath - -RETURN lFound - -FUNCTION TestforPrg( cFile ) - - LOCAL aFiles AS ARRAY := {} - LOCAL cPath AS STRING := '' - LOCAL cTest AS STRING := "" - LOCAL cDrive AS STRING := "" - LOCAL cExt AS STRING := "" - LOCAL cItem AS STRING := "" - LOCAL aDir AS ARRAY - LOCAL nPos AS NUMERIC - LOCAL nFiles AS NUMERIC - - hb_FNAMESPLIT( cFile, @cPath, @cTest, @cExt, @cDrive ) - cExt := Substr( cExt, 2 ) - aDir := Directory( cTest + '.*' ) - - FOR nPos := 1 TO 7 - - cItem := cTest + "." + extenprg( cExt, nPos ) - Aadd( aFiles, cItem ) - - NEXT - - FOR nFiles := 1 TO Len( aFiles ) - - nPos := Ascan( aDir, { | a | a[ 1 ] == aFiles[ nFiles ] } ) - - IF nPos > 0 - - Aadd( aPrgs, aFiles[ nFiles ] ) - - ENDIF - - NEXT - -RETURN nil - -FUNCTION GetGccDir() - - LOCAL cPath AS STRING := '' - LOCAL cEnv AS STRING - LOCAL aEnv AS Array of string - LOCAL nPos as Numeric - - IF lLinux - - cpath := "." - - ELSE - - cEnv := Gete( "PATH" ) - aEnv := Listasarray2( cEnv, ";" ) - - FOR nPos := 1 TO Len( aEnv ) - - IF File( aenv[ nPos ] + '\gcc.exe' ) .or. File( Upper( aenv[ nPos ] ) + '\GCC.EXE' ) - - cPath := aenv[ nPos ] - cPath := Left( cPath, Rat( '\', cPath ) - 1 ) - EXIT - - ENDIF - - NEXT - - ENDIF - -RETURN cPath - -FUNCTION ConvertParams( cFile, aFile, p1, p2, p3, p4, p5, p6 ) - - LOCAL cParam := "" - - IF !Empty( cFile ) - - IF Left( cFile, 1 ) $ "- /" - - cParam += cFile - - ELSE - - cFile := cFile - - Aadd( aFile, cFile ) - - ENDIF - ENDIF - - IF !Empty( p1 ) - - IF Left( p1, 1 ) $ "- /" - - cParam += p1 - - ELSE - - cFile := p1 - - Aadd( aFile, cFile ) - - ENDIF - - ENDIF - - IF !Empty( p2 ) - - IF Left( p2, 1 ) $ "- /" - - cParam += p2 - - ELSE - - cFile := p2 - Aadd( aFile, cFile ) - - ENDIF - - ENDIF - - IF !Empty( p3 ) - - IF Left( p3, 1 ) $ "- /" - - cParam += p3 - - ELSE - - cFile := p3 - Aadd( aFile, cFile ) - - ENDIF - - ENDIF - - IF !Empty( p4 ) - - IF Left( p4, 1 ) $ "- /" - - cParam += p4 - - ELSE - - cFile := p4 - Aadd( aFile, cFile ) - - ENDIF - - ENDIF - - IF !Empty( p5 ) - - IF Left( p5, 1 ) $ "- /" - - cParam += p5 - - ELSE - - cFile := p5 - Aadd( aFile, cFile ) - - ENDIF - - ENDIF - - IF !Empty( p6 ) - - IF Left( p6, 1 ) $ "- /" - - cParam += p6 - - ELSE - - cFile := p6 - Aadd( aFile, cFile ) - - ENDIF - - ENDIF - - cParam := Strtran( cParam, "/", "-" ) - cParam := Strtran( cParam, "-elx", "-ELX" ) - cParam := Strtran( cParam, "-el", "-ELX" ) - cParam := Strtran( cParam, "-ex", "-EX" ) - cParam := Strtran( cParam, "-e", "-EX" ) - cParam := Strtran( cParam, "-i", "-I" ) - cParam := Strtran( cParam, "-p", "-P" ) - cParam := Strtran( cParam, "-b", "-B" ) - cParam := Strtran( cParam, "-gl", "-GL" ) - cParam := Strtran( cParam, "-g", "-G" ) - cParam := Strtran( cParam, "-v", "-V" ) - cParam := Strtran( cParam, "-f", "-F" ) - cParam := Strtran( cParam, "-r", "-R" ) - cParam := Strtran( cParam, "-l", "-L" ) - - If AT( "-EX" , cParam ) >0 .or. AT( "-ELX" , cParam ) >0 - - lEditMode:=.T. +Beginning Static Variables Table +Default Values for core variables are set here +New Core vars should only be added on this section +*/ + +STATIC s_cHbMakeVersion := "1.20" +STATIC s_lPrint := .F. +STATIC s_lEdit := .F. +STATIC s_aDefines := {} +STATIC s_aBuildOrder := {} +STATIC s_aCommands := {} +STATIC s_aMacros := {} +STATIC s_aPrgs := {} +STATIC s_aExtLibs := {} +#IfDef HBM_USE_DEPENDS +STATIC s_aDepends := {} +#Endif +STATIC s_aCFiles := {} // array of C source files +STATIC s_aObjs := {} +STATIC s_aObjsc := {} +STATIC s_aSrcPaths := {} +STATIC s_lEof := .F. +STATIC s_aResources := {} +STATIC s_nMakeFileHandle +STATIC s_cMakeFileName := "makefile.lnk" +STATIC s_cLinkCommands := "" +STATIC s_lLinux := .F. +STATIC s_lUnix := .F. +STATIC s_lOS2 := .F. +STATIC s_lWin32 := .F. +STATIC s_lBcc := .F. // Borland C compiler +STATIC s_lPocc := .F. // Pelles C compiler +STATIC s_lMSVcc := .F. // MS-Visual C compiler +STATIC s_lGcc := .F. // GNU C compiler +STATIC s_lMinGW := .F. // MinGW C compiler +STATIC s_lForce := .F. // "-f" flag +STATIC s_szProject := "" +STATIC s_lLibrary := .F. +STATIC s_lIgnoreErrors := .F. +STATIC s_lExtended := .T. +STATIC s_lRecursive := .F. +STATIC s_lCancelRecursive:= .F. +STATIC s_lEditMake := .F. +STATIC s_lCompress := .F. +STATIC s_lExternalLib := .F. +STATIC s_aDir +STATIC s_aLangMessages := {} +STATIC s_cAppName := "" +STATIC s_cDefLang +STATIC s_cLog := "" // log file name. +STATIC s_cMap := "" // map file name. For borland c +STATIC s_cTds := "" // state file name. For borland c +STATIC s_lGenPpo := .F. +STATIC s_nLang := 2 // default language is english +STATIC s_lMt := .F. +STATIC s_cUserDefine := "" +STATIC s_cUserInclude := "" +STATIC s_cUserLibs := "" // for user libs located other than "harbour\lib" folder. +STATIC s_lxFwh := .F. +STATIC s_nFilesToAdd := 5 +STATIC s_nWarningLevel := 0 +STATIC s_lAsDll := .F. +STATIC s_cAlertMsg := "" +STATIC s_cHarbourCfg := "harbour.cfg" // don't change this file name. +STATIC s_cObjDir := "obj" +STATIC s_lGui := .F. +STATIC s_cEditor := "" +STATIC s_cHarbourDir := "" +STATIC s_lGenCsource := .F. // Generate PCode by default // Ath added 31-05-2006 +STATIC s_cInvalidExt := {".prg",".c",".cpp",".ch",".h",".ppo",".bat",".doc",".txt",".dbf",".ntx",".cdx",".dbt",".fpt",".mem"} + +*--------------------------------------------- +FUNCTION MAIN( cFile, p1, p2, p3, p4, p5, p6 ) +*--------------------------------------------- + + LOCAL aFile := {} + LOCAL aDef := {} + LOCAL cMakeParams := "" + LOCAL nLang := GETUSERLANG() + LOCAL nPos + LOCAL aPpo + LOCAL cExt := "" + LOCAL cExp,cLib + LOCAL lCreateAndCompile := .F. // for "-c" param only. + + IF Empty( cFile ) + ShowHelp() + Return .F. + endif + + cExt := SubStr( cFile, At(".",cFile) ) + + IF ! Empty(cExt) .AND. lower(cExt) $ s_cInvalidExt + Alert("Invalid extension for hbmake script file <"+cFile+">.") + Return .F. + ENDIF + + CLS + + FErase( s_cMakeFileName ) + + SET(39,159) + + cMakeParams := ConvertParams( @cFile, aFile, p1, p2, p3, p4, p5, p6 ) + + IF ! empty( cMakeParams ) + + cMakeParams := upper( cMakeParams ) + + IF "-LPT" $ cMakeParams + nLang := 1 + ELSEIF "-LEN" $ cMakeParams + nLang := 2 + ELSEIF "-LES" $ cMakeParams + nLang := 3 + ENDIF ENDIF - IF AT( "-L" , cParam ) > 0 + MHIDE() + + s_nLang := nLang + s_cDefLang := IIF( s_nLang == 1, "PT", IIF( s_nLang == 2, "EN", "ES" ) ) + s_aLangMessages := BuildLangArray( s_cDefLang ) - cDefLang := substr( cParam , AT( "-L" , cParam ) + 2 , 2 ) + // What S.O. ? + // + s_lOS2 := ( "OS/2" $ OS() ) + s_lLinux := ( "LINUX" $ Upper( OS() ) ) + s_lWin32 := ( "WINDOWS" $ Upper( OS() ) ) + s_lUnix := IF( ( "UNIX" $ Upper( OS() ) ) .OR. ( "HP-UX" $ Upper( OS() ) ) , .T., .F. ) + s_lLinux := ( "LINUX" $ Upper( OS() ) ) + + IF PCount() == 0 .or.; + "?" $ cMakeParams .or. ; + "/?" $ cMakeParams .or. ; + "-?" $ cMakeParams .or. ; + "/h" $ cMakeParams .or. ; + "-h" $ cMakeParams + ShowHelp() + RETURN NIL + ENDIF + + IF "credits" $ lower(cMakeParams) + ShowCredits() + RETURN NIL + ENDIF + + s_cHarbourDir := GetHarbourDir() + + IF Empty( s_cHarbourDir ) + IF s_nLang=1 + s_cAlertMsg := "Hbmake necessita do harbour bin no path." + ELSEIF s_nLang=3 + s_cAlertMsg := "Hbmake necessita de lo harbour bin en lo path." + ELSE + s_cAlertMsg := "Hbmake need of the harbour bin in the path." + ENDIF + alert( s_cAlertMsg ) + RUN( "PATH" ) + RETURN NIL + ENDIF + + //IF Upper( OS() ) == "WINDOWS XP" + // s_cMakeFileName := "makefile.tmp" + //ENDIF + + IF s_nLang=1 + SET DATE BRITISH + ELSE + SET DATE ANSI + ENDIF + + SET SCORE OFF + SET CENTURY ON +// SET TRACE ON + + DEFAULT p1 TO "" + DEFAULT p2 TO "" + DEFAULT p3 TO "" + DEFAULT p4 TO "" + DEFAULT p5 TO "" + DEFAULT p6 TO "" + + + IF s_lOS2 .OR. s_lLinux + + s_cEditor := "mcedit" + + s_lGcc := .T. + s_lBcc := .F. + s_lPocc := .F. + s_lMSVcc := .F. + s_lMinGW := .F. + + ELSEIF s_lWin32 + + s_cEditor := "edit" + + s_lGcc := .F. + + if ".bc" $ lower(cFile) + s_lBcc := .T. // Borland C compiler + elseif ".pc" $ lower(cFile) + s_lPocc := .T. // Pelles C compiler + elseif ".vc" $ lower(cFile) + s_lMSVcc := .T. // MS-VC Compiler + elseif ".mg" $ lower(cFile) .OR. ".mgw" $ lower(cFile) .OR. ".mingw" $ lower(cFile) + s_lMinGW := s_lGcc := .T. + else + s_lBcc := .T. // default + s_lPocc := .F. + s_lMSVcc := .F. + s_lMinGW := .F. + s_lGcc := .F. + endif + + ENDIF + + + IF Len( aFile ) > 1 + IF s_nLang=1 + s_cAlertMsg :="Arquivo definido mais que uma vez." + ELSEIF s_nLang=3 + s_cAlertMsg:="Fichero definido m s que una vez." + ELSE + s_cAlertMsg:="File defined more than once." + ENDIF + alert( s_cAlertMsg ) + RETURN NIL + ENDIF + + IF Len( aFile ) > 0 + cFile := aFile[ 1 ] + ELSE + cFile := "" + ENDIF + + IF Empty(cFile) + IF s_nLang=1 + s_cAlertMsg := "Nome de arquivo inv lido." + ELSEIF s_nLang=3 + s_cAlertMsg := "Nombre de fichero invalido." + ELSE + s_cAlertMsg := "Invalid file name." + ENDIF + alert( s_cAlertMsg ) + RETURN NIL + ENDIF + + if PCount() > 1 + ProcessParameters( cMakeParams ) + endif + + IF s_lForce .and. !File( cFile ) + IF s_nLang=1 + s_cAlertMsg := "Arquivo <"+cFile+"> nÆo encontrado." + ELSEIF s_nLang=3 + s_cAlertMsg := "Fichero <"+cFile+"> no encontrado." + ELSE + s_cAlertMsg := "File <"+cFile+"> not found." + ENDIF + alert( s_cAlertMsg ) + RETURN NIL + ENDIF + + + s_cAppName := Substr( cFile,1 , AT(".",cFile) -1) + s_cLog := s_cAppName + ".log" + + cExp := s_cAppName + ".exp" + cLib := s_cAppName + ".lib" + + FErase( (s_cAppName+".out") ) // erase old *.out log filename + FErase( s_cLog ) + + if s_lBcc + /* if you need of these files, comment the lines below. */ + s_cMap := s_cAppName + ".map" + s_cTds := s_cAppName + ".tds" + FErase( s_cMap ) + FErase( s_cTds ) + endif + + // Edit/Create MakeFile... + + if !s_lForce .and. s_lEdit // PCount() > 1 + + if ! File( cFile ) + lCreateAndCompile := ( "-C" $ cMakeParams ) + else + lCreateAndCompile := .f. + cMakeParams := StrTran( cMakeParams, "-C","" ) + endif + + if Hb_IsNil(s_lGenppo) .OR. s_lGenppo == .F. + Delete_ppo() + endif + + IF s_lLibrary + CreateLibMakeFile( cFile ) + ELSE + CreateMakeFile( cFile, lCreateAndCompile ) + ENDIF + + RETURN NIL + + endif + + + // Compile MakeFile... + + CLS + + // Make file is parsed here + + IF ! ParseMakeFile( cFile ) + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile+ "> nÆo pode ser aberto. FERROR("+Ltrim(Str(FError()))+"). O HbMake ser  fechado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser abierto. FERROR("+Ltrim(Str(FError()))+"). Lo HbMake ser  cerrado." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be openned. FERROR("+Ltrim(Str(FError()))+"). The HbMake will be closed." + ENDIF + + Alert( s_cAlertMsg ) + + RETURN NIL + + ENDIF + + IF s_lPrint + PrintMacros() + ENDIF + + set cursor off + + IF !hb_DirExists( s_cObjDir ) +#ifdef HB_COMPAT_C53 + MakeDir( s_cObjDir ) +#endif + ENDIF + + if Hb_IsNil(s_lGenppo) .OR. s_lGenppo == .F. + Delete_ppo() + endif + + IF s_lForce + CompileFiles() + ELSE + CompileUpdatedFiles() + ENDIF + + SET CURSOR ON + setpos(9,0) + Outstd( s_cLinkCommands + CRLF ) + SET CURSOR OFF + __RUN( (s_cLinkCommands) ) + + IF s_lCompress .AND. !s_lLibrary + SET CURSOR ON + setpos(9,0) + __Run( " upx -9 "+ (s_cAppName) ) + SET CURSOR OFF + ENDIF + + + IF s_lasdll .or. lower(right(s_cAppName,3)) == 'dll' + __Run( ReplaceMacros("implib $(HB_DIR)\lib\" + left(s_cAppName,at(".",s_cAppName)-1)+".lib " +s_cAppName )) + ENDIF + + + if s_lBcc + /* + NOTE: The TDS file is always created by borland linker. + If you need of this file, comment the lines below and + remove "-x" flag that is created by hbmake in the + LFLAGS statment for Borland compiler. + */ + FErase( s_cMap ) + FErase( s_cTds ) + endif + + IF s_lPocc + FErase( cExp ) + IF !s_lLibrary + FErase( cLib ) + ENDIF + ENDIF + + SET CURSOR ON + +RETURN NIL + +*------------------------------ +FUNCTION ParseMakeFile( cFile ) +*------------------------------ + + LOCAL nPos + LOCAL cBuffer := {} + LOCAL cMacro := iif(s_lMSVcc,"#MSVC",iif(s_lPocc,"#POCC",iif(s_lGcc,"#GCC","#BCC"))) + LOCAL cDep := "#DEPENDS" + LOCAL cOpt := "#OPTS" + LOCAL cCom := "#COMMANDS" + LOCAL cBuild := "#BUILD" + LOCAL cTemp := "" + LOCAL cTemp1 := "" + LOCAL aTemp := {} + LOCAL lMacrosec := .T. + LOCAL lBuildSec := .F. + LOCAL lComSec := .F. +#IFDEF HBM_USE_DEPENDS + LOCAL lDepSec := .F. +#ENDIF + LOCAL aTemp1 := {} + LOCAL cCfg := "" + LOCAL lCfgFound := .F. + LOCAL aTempCFiles := {} + LOCAL lLinux := s_lLinux + LOCAL lUnix := s_lUnix + LOCAL aLib + LOCAL aLibx + LOCAL lDjgpp := "GNU C" $ HB_COMPILER() + LOCAL x := 1 + LOCAL ct + LOCAL nFHandle + LOCAL cTrash :="" + + + nFHandle := FT_FUSE( cFile, FO_READ ) + + IF nFHandle < 0 + RETURN .F. + ENDIF + + #IFndef __PLATFORM__Windows + IF !FILE("hbtemp.c") + CreateLink() + ENDIF + #ENDIF + + cBuffer := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + AAdd( s_aDefines, { "HARBOUR_DIR", s_cHarbourDir } ) + + IF s_lBcc + AAdd( s_aDefines, { "MAKE_DIR", GetBccDir() } ) + ELSEIF s_lGcc + AAdd( s_aDefines, { "MAKE_DIR", GetGccDir() } ) + ELSEIF s_lMSVcc + AAdd( s_aDefines, { "MAKE_DIR", GetVccDir() } ) + ELSEIF s_lPocc + AAdd( s_aDefines, { "MAKE_DIR", GetPoccDir() } ) + ENDIF + + WHILE ! s_lEof + + IF cMacro $ cBuffer + lMacroSec := .T. + lBuildSec := .F. + lComSec := .F. +#IFDEF HBM_USE_DEPENDS + lDepSec := .F. +#Endif + ELSEIF cBuild $ cBuffer + lMacroSec := .F. + lBuildSec := .T. + lComSec := .F. +#IfDef HBM_USE_DEPENDS + lDepSec := .F. +#Endif + ELSEIF cCom $ cBuffer + lBuildSec := .F. + lComSec := .T. + lMacroSec := .F. +#IfDef HBM_USE_DEPENDS + lDepSec := .F. + ELSEIF cDep $ cBuffer + lBuildSec := .F. + lComSec := .F. + lMacroSec := .F. + lDepSec := .T. +#Endif + ELSE + ? "Invalid Make File" + FClose( nFHandle ) + RETURN .F. + ENDIF + + cTemp := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + IF "//" $ cTemp + + WHILE At( "//", cTemp ) > 0 + + cTemp := Strtran( cTemp, " //", "" ) + cTemp += Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + ENDDO + + cTemp := Strtran( cTemp, " //", "" ) + + ENDIF + + aTemp := ListAsArray2( Alltrim( cTemp ), "=" ) + + IF lmacrosec + + IF Alltrim( Left( cTemp, 7 ) ) <> '!ifndef' .AND. Alltrim( Left( cTemp, 6 ) ) <> "!endif" .AND. Alltrim( Left( cTemp, 7 ) ) <> '!IFfile' .AND. Alltrim( Left( cTemp, 7 ) ) <> '!stdout' .AND. Alltrim( Left( cTemp, 6 ) ) <> '!ifdef' + + IF Len( aTemp ) > 1 + + IF "$" $ aTemp[ 2 ] + + IF s_lGcc .AND. aTemp[ 1 ] = "CFLAG1" .OR. s_lGcc .AND. aTemp[ 1 ] = "CFLAG2" + AAdd( s_aMacros, { aTemp[ 1 ], Strtran( ReplaceMacros( aTemp[ 2 ] ), "\", "/" ) } ) + + x++ + ELSE + + IF aTemp[ 1 ] == "MT" .AND. aTemp[ 2 ] == "YES" + s_lMt := .T. + ENDIF + + IF aTemp[ 1 ] == "LIBFILES" .AND. ! s_lMt + + aLib := ListAsArray2( aTemp[ 2 ], ' ' ) + + FOR each aLibx in aLib + + IF At( 'mt.lib', Lower( aLibx ) ) > 0 + s_lMt := .T. + ENDIF + + IF "-l" $ Lower( aLibx ) + s_lBcc := .F. + s_lGcc := .T. + s_lMSVcc := .F. + s_lPocc := .F. + s_aDefines[2] := { "MAKE_DIR", GetGccDir() } + s_aDefines[3] := { "HARBOUR_DIR", s_cHarbourDir } + + ENDIF + + NEXT + + ENDIF + + IF aTemp[ 1 ] == "ALLOBJ" .AND. ! s_lMt + + ENDIF + + AAdd( s_aMacros, { aTemp[ 1 ], ReplaceMacros( aTemp[ 2 ] ) } ) + + ENDIF + + ELSE + + IF s_lGcc .AND. aTemp[ 1 ] = "CFLAG1" .OR. s_lGcc .AND. aTemp[ 1 ] = "CFLAG2" + AAdd( s_aMacros, { aTemp[ 1 ], Strtran( aTemp[ 2 ], "\", "/" ) } ) + + x++ + + ELSE + IF aTemp[ 1 ] == "LIBFILES" .AND. ! s_lMt + + aLib := ListAsArray2( aTemp[ 2 ], ' ' ) + + FOR each aLibx in aLib + + IF At( 'mt.lib', Lower( aLibx ) ) > 0 + s_lMt := .T. + ENDIF + + IF "-l" $ Lower( aLibx ) + s_lBcc := .F. + s_lGcc := .T. + s_lMSVcc := .F. + s_lPocc := .F. + s_aDefines[2] := { "MAKE_DIR", GetGccDir() } + s_aMacros[2,2] := GetGccDir() + ENDIF + + NEXT + elseif aTemp[ 1 ] == "SHELL" + if !empty( Atemp[ 2 ] ) + __run( (Atemp[ 2 ]) + " > e.txt") + Atemp[ 2 ] := alltrim( memoread( "e.txt" ) ) + aTemp[ 2 ] := strtran( aTemp[ 2 ],chr(13),"") + aTemp[ 2 ] := strtran( aTemp[ 2 ],chr(10),"") + ferase("e.txt") + endif + ENDIF + AAdd( s_aMacros, { aTemp[ 1 ], aTemp[ 2 ] } ) + ENDIF + + ENDIF + + ENDIF + + + IF aTemp[ 1 ] == "COMPRESS" + s_lCompress := "YES" $ aTemp[ 2 ] + ENDIF + + + IF aTemp[ 1 ] == "GUI" + s_lGui := "YES" $ aTemp[ 2 ] + ENDIF + + IF aTemp[ 1 ] == "EXTERNALLIB" + s_lExternalLib := "YES" $ aTemp[ 2 ] + ENDIF + + IF aTemp[ 1 ] == "SRC02" // obj dir + s_cObjDir := aTemp[ 2 ] + ENDIF + + IF aTemp[ 1 ] == "PROJECT" + + IF At( '.lib', aTemp[ 2 ] ) > 0 .OR. At( '.a', aTemp[ 2 ] ) > 0 + s_lLibrary := .T. + ENDIF + + s_cAppName := SubStr( aTemp[ 2 ], 1, AT( ' ', aTemp[ 2 ] ) -1 ) + + ENDIF + + IF aTemp[ 1 ] == "OBJFILES" + s_aObjs := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + IF aTemp[ 1 ] == "OBJCFILES" + + aTemp1 := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + + IF Len( aTemp1 ) == 1 + + IF ! Empty( aTemp[ 1 ] ) + s_aObjsC := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + ELSE + s_aObjsC := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + ENDIF + + IF aTemp[ 1 ] == "PRGFILES" + s_aPrgs := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + s_lExtended := .T. + lCfgFound := FindHarbourCfg( @cCfg ) + ENDIF + + IF aTemp[ 1 ] == "PRGFILE" + s_aPrgs := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + IF aTemp[ 1 ] == "EXTLIBFILES" + s_aExtLibs := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + IF aTemp[ 1 ] == "CFILES" + + IF s_lExtended + aTempCFiles := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + + IF ( Len( aTempCFiles ) == 1 ) + + IF ! Empty( aTempCFiles[ 1 ] ) + s_aCFiles := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + ELSE + s_aCFiles := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + ELSE + s_aCFiles := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + + ENDIF + + IF aTemp[ 1 ] == "RESFILES" + s_aResources := ListAsArray2( ReplaceMacros( aTemp[ 2 ] ), " " ) + ENDIF + + IF aTemp[ 1 ] == "EDITOR" + s_cEditor := Trim( aTemp[ 2 ] ) + ENDIF + + ELSE + + IF '!ifndef' $ cTemp + CheckDefine( cTemp ) + ELSEIF '!ifdef' $ cTemp + CheckIFdef( cTemp ) + ELSEIF '!iffile' $ cTemp + CheckIFFile( cTemp ) + ELSEIF '!stdout' $ cTemp + CheckStdOut( cTemp ) + ENDIF + + ENDIF + + ENDIF + IF s_lMingw .and. s_lGcc + x := ascan(s_aMacros,{|x| X[1] == "HB_DIR"}) + IF x>0 + IF s_aMacros[x,2] != s_cHarbourDir + s_aMacros[x,2] := s_cHarbourDir + ENDIF + ENDIF + ENDIF + + IF lBuildSec + + s_szProject := cTemp + s_aBuildOrder := ListAsArray2( cTemp, ":" ) + + IF !s_lLibrary + SetBuild() + ELSE + SetBuildLib() + ENDIF + + ENDIF + + IF lComSec + + IF ! Empty( cTemp ) + Setcommands( cTemp ) + ENDIF + + ENDIF + +#IfDef HBM_USE_DEPENDS + IF lDepSec + + IF ! Empty( cTemp ) + SetDependencies( cTemp ) + ENDIF + + ENDIF +#Endif + + IF cTemp = "#BUILD" + cBuffer := cTemp + ELSEIF cTemp == "#COMMANDS" + cbuffer := cTemp +#IfDef HBM_USE_DEPENDS + ELSEIF cTemp == "#DEPENDS" + cbuffer := cTemp +#Endif + ENDIF + + ENDDO + + FT_FUSE() // Close the opened file & release memory + + IF s_lExtended .AND. (!lCfgFound .or. s_lForce) + + IF s_lBcc + BuildBccCfgFile() + ELSEIF s_lMSVcc + BuildMscCfgFile() + ELSEIF s_lPocc + BuildPccCfgFile() + ELSEIF s_lGcc .AND. !lLinux + BuildGccCfgFile() + ELSEIF s_lGcc .AND. lLinux + BuildGccCfgFileL() + ENDIF + + ENDIF + +RETURN .T. + +*---------------------------- +FUNCTION Checkdefine( cTemp ) +*---------------------------- + + LOCAL cDef + LOCAL nPos + LOCAL cRead + LOCAL aSet := {} + LOCAL nMakePos + + IF cTemp == "!endif" + RETURN NIL + ENDIF + + cTemp := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + cTemp := Strtran( cTemp, "!ifndef ", "" ) + cTemp := Strtran( cTemp, "\..", "" ) + cTemp := Strtran( cTemp, "/..", "" ) + + IF "\.." $ cTemp + cTemp := Substr( cTemp, 1, At( "\..", cTemp ) - 1 ) + ELSEIF "/.." $ cTemp + cTemp := Substr( cTemp, 1, At( "/..", cTemp ) - 1 ) + ENDIF + + aSet := ListAsArray2( cTemp, "=" ) + nPos := AScan( s_aDefines, { | x | x[ 1 ] == aSet[ 1 ] } ) + + IF nPos = 0 + cRead := Alltrim( Strtran( aSet[ 2 ], "$(", "" ) ) + cRead := Strtran( cRead, ")", "" ) + nMakePos := AScan( s_aDefines, { | x | x[ 1 ] == cRead } ) + + IF nMakePos > 0 + AAdd( s_aDefines, { aSet[ 1 ], s_aDefines[ nMakePos, 2 ] } ) + AAdd( s_aMacros, { aSet[ 1 ], s_aDefines[ nMakePos, 2 ] } ) + ENDIF + + ENDIF + +RETURN NIL + +*---------------------------- +FUNCTION Setcommands( cTemp ) +*---------------------------- + + LOCAL cRead := Alltrim( readln( @s_lEof ) ) + LOCAL nPos + LOCAL nCount := 0 + LOCAL aTempMacros := {} + LOCAL aLocalMacros := {} + + aTempMacros := ListAsArray2( cREad, " " ) + + AEval( aTempMacros, { | xMacro | IIF( At( "$", xMacro ) > 0, ; + IIF( At( ";", xMacro ) > 0, ( aLocalMacros := ListAsArray2( xMacro, ";" ), ; + AEval( aLocalMacros, { | x | Findmacro( x, @cRead ) } ) ), ; + Findmacro( xMacro, @cRead ) ), ) } ) + AAdd( s_aCommands, { cTemp, cRead } ) + +RETURN NIL + +#IfDef HBM_USE_DEPENDS + +*-------------------------------- +FUNCTION SetDependencies( cTemp ) +*-------------------------------- + + LOCAL nPos + LOCAL nCount := 0 + LOCAL aTempMacros := {} + LOCAL aLocalMacros := {} + LOCAL cTmp := "" + + aTempMacros := ListAsArray2( ReplaceMacros(cTemp), " " ) + + IF Len( aTempMacros ) > 1 + cTmp := aTempMacros[ 1 ] + IF Right(cTmp,1) == ":" + cTmp := Left(cTmp,Len(cTmp) - 1) + ENDIF + aTempMacros := ADel( aTempMacros , 1) + ASize(aTempMacros,Len(aTempMacros) - 1) + AAdd( s_aDepends, { cTmp, AClone( aTempMacros ) } ) + ENDIF + +RETURN NIL +#Endif + +*---------------------------------- +FUNCTION Findmacro( cMacro, cRead ) +*---------------------------------- + + LOCAL nPos + LOCAL cTemp + LOCAL aLocalMacros := {} + + cMacro := Substr( cMacro, 1, At( ")", cMacro ) ) + + IF "-" $ cMacro + cMacro := Substr( cMacro, 3 ) + ENDIF + + IF ";" $ cMacro + cMacro := Substr( cMacro, At( ";", cMacro ) + 1 ) + ENDIF + + nPos := AScan( s_aMacros, { | x | "$(" + Alltrim( x[ 1 ] ) + ")" == cMacro } ) + + IF nPos = 0 + cTemp := Strtran( cMacro, "$(", "" ) + cTemp := Strtran( cTemp, ")", "" ) + + IF ! Empty( cTemp ) + cRead := Alltrim( Strtran( cRead, cMacro, Gete( cTemp ) ) ) + ENDIF + + ELSE + cRead := Alltrim( Strtran( cRead, cMacro, s_aMacros[ npos, 2 ] ) ) + ENDIF + +RETURN cRead + +*-------------------------------- +FUNCTION ReplaceMacros( cMacros ) +*-------------------------------- + + LOCAL nPos + LOCAL nCount := 0 + LOCAL aTempMacros := {} + LOCAL aLocalMacros := {} + LOCAL cLibPath := "" + LOCAL cLibPath1 := "" + LOCAL cLibPath2:= "" + + IF "/LIBPATH2:" $ cMacros + cLibPath2 := "/LIBPATH2:" + cMacros := StrTran(cMacros,cLibPath2,"cccccccccc ") + ENDIF + + IF "/LIBPATH1:" $ cMacros + cLibPath1 := "/LIBPATH1:" + cMacros := StrTran(cMacros,cLibPath1,"bbbbbbbbbb ") + ENDIF + + IF "/LIBPATH:" $ cMacros + cLibPath := "/LIBPATH:" + cMacros := StrTran(cMacros,cLibPath,"aaaaaaaaaa ") + ENDIF + + aTempMacros := ListAsArray2( cMacros, " " ) + + AEval( aTempMacros, { | xMacro | IIF( "$" $ xMacro , ; + IIF( ";" $ xMacro , ( aLocalMacros := ListAsArray2( xMacro, ";" ), ; + AEval( aLocalMacros, { | x | Findmacro( x, @cMacros ) } ) ), ; + Findmacro( xMacro, @cMacros ) ), ) } ) + + IF !empty(cLibPath) + + cMacros := strtran(cMacros,"aaaaaaaaaa ","/LIBPATH:") + cMacros := strtran(cMacros,"bbbbbbbbbb ","/LIBPATH:") + cMacros := strtran(cMacros,"cccccccccc ","/LIBPATH:") + + IF s_lPocc + cMacros := StrTran(cMacros,"\BIN","") + cMacros := StrTran(cMacros,"\bin","") + ENDIF + + ENDIF + +RETURN cMacros + +*------------------ +FUNCTION SetBuild() +*------------------ + + LOCAL cRead + LOCAL nPos + LOCAL aMacro + LOCAL aTemp + LOCAL nCount + LOCAL cCurrentRead := '' + LOCAL cMacro + LOCAL xInfo + LOCAL xItem + + cRead := Alltrim( readln( @s_lEof ) ) + s_szProject := cRead + aMacro := ListAsArray2( cRead, ":" ) + + IF Len( aMacro ) > 1 + aTemp := ListAsArray2( aMacro[ 2 ], " " ) + AEval( aTemp, { | xItem | AAdd( s_aBuildOrder, xItem ) } ) + ENDIF + + AAdd( s_aBuildOrder, aMacro[ 1 ] ) + cRead := Strtran( cRead, "@&&!", "" ) + aMacro := ListAsArray2( cRead, '\' ) + + AEval( aMacro, { | xMacro | IIF( "$" $ xMacro , FindMacro( xMacro, @cRead ), ) } ) + + IF ! s_lLinux .AND. !s_lMinGW + + s_cLinkCommands := cRead + " @" + s_cMakeFileName + s_nMakeFileHandle := FCreate( s_cMakeFileName ) + + IF s_nMakeFileHandle = F_ERROR + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+s_cMakeFileName + "> nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+s_cMakeFileName + "> no pode ser criado." + ELSE // english + s_cAlertMsg := "<"+s_cMakeFileName + "> cannot be created." + ENDIF + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + ENDIF + + ELSE + s_cLinkCommands := cRead + " " + ENDIF + + FOR nPos := 1 TO 7 + + cRead := Alltrim( readln( @s_lEof ) ) + cCurrentRead := cRead + aMacro := ListAsArray2( cRead, " " ) + + FOR EACH cMacro IN aMacro + + IF "$" $ cMacro + + FindMacro( cMacro , @cRead ) + + IF At( '$(PROJECT)', cCurrentRead ) > 0 + + IF ! s_lGcc + + IF ! s_lLinux + IF s_lMSVcc .OR. s_lPocc + cRead := strtran(cRead,",","") + cRead := strtran(cRead,"+","") + xInfo := iif(s_lMSVcc," -out:","/out:") + xInfo += cRead + cRead := xInfo + ENDIF + FWrite( s_nMakeFileHandle, cRead + CRLF ) + ENDIF + + ELSEIF s_lGcc .AND. s_lLinux .OR. ( s_lGcc .AND. s_lMinGW) + s_cLinkCommands += "-o " + cRead + " " + + ELSEIF s_lGcc .AND. ! s_lLinux .AND. At( '.exe', cRead ) > 0 + FWrite( s_nMakeFileHandle, "-o " + cRead + CRLF ) + + ENDIF + + ELSE + + IF ! s_lLinux + + IF s_lMsVcc .OR. s_lPocc + + cRead := strtran(cRead,",","") + cRead := strtran(cRead,"+","") +// cRead := strtran(cRead," ", '"' +CRLF+'"') + aTemp := ListAsArray2( cRead, " " ) + cRead :="" + FOR EACH xItem IN aTemp + cRead +=xItem+CRLF + NEXT + cRead := substr(cRead,1,rat(CRLF,cRead)-1) + + ENDIF + + IF s_lMinGW + s_cLinkCommands += strtran(cRead,"/","\") + " " + ELSE + FWrite( s_nMakeFileHandle, cRead + CRLF ) + ENDIF + + ELSE + s_cLinkCommands += cRead + " " + ENDIF + + ENDIF + + ENDIF + + NEXT + + NEXT + + //IF !s_lLinux .and. s_lMinGW + IF s_lWin32 .OR. s_lOS2 .OR. s_lMinGW + FClose( s_nMakeFileHandle ) + ENDIF + + IF s_lMsVcc + s_cLinkCommands +=" /nologo " + IIF( s_lGui, "/SUBSYSTEM:WINDOWS"," /SUBSYSTEM:CONSOLE") + " /force:multiple " + ENDIF + + qqout( HbMake_Id() ) + qout( HbMake_Copyright() ) + + IF s_lBcc .OR. s_lPocc .OR. s_lMSVcc + qout( version() + ' / '+HB_Compiler() ) + ELSE + qout(s_cLinkCommands) + ENDIF + + + +RETURN NIL + +*---------------------- +FUNCTION CompileFiles() +*---------------------- + + LOCAL cComm + LOCAL cOld + LOCAL nPos + LOCAL nCount + LOCAL nFiles + LOCAL cErrText := "" + LOCAL aOrder := ListAsArray2( s_aBuildOrder[ 2 ], " " ) + LOCAL lEnd := .F. + LOCAL xItem + LOCAL lLinux := s_lLinux + LOCAL cPrg := '' + LOCAL cOrder := "" + LOCAL nFile := 1 + LOCAL aGauge := GaugeNew( 5, 5, 7, 40, "W/B", "W+/B", '²' ) + + + @ 4, 5 SAY "Compiling :" + + FOR EACH cOrder IN aOrder + + IF ! s_lExtended + + IF cOrder == "$(CFILES)" + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".prg.c:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".PRG.C:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + ENDIF + + FOR EACH cPrg IN s_aPrgs + + xItem := Substr( cPrg, Rat( IIF( s_lGcc, '/', '\' ), ; + cPrg ) + 1 ) + nPos := AScan( s_aCFiles, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), ; + Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) + + IF nPos > 0 + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + s_aCFiles[ nPos ] ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + s_aCFiles[ nPos ] ) + ENDIF + cComm := Strtran( cComm, "$**", cPrg ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + Outstd( cComm ) + Outstd( CRLF ) + setpos(9,0) + __RUN( (cComm) ) + cErrText := Memoread( (s_cLog) ) + lEnd := 'C2006' $ cErrText .OR. 'No code generated' $ cErrText + + IF ! s_lIgnoreErrors .AND. lEnd + __run( s_cEditor +" "+(s_cLog) ) + SET CURSOR ON + QUIT + ELSE + // Ferase( s_cLog ) + ENDIF + + cComm := cOld + + ENDIF + + NEXT + + ENDIF + + IF cOrder == "$(OBJFILES)" + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.o:" .OR. x[ 1 ] == ".cpp.o:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.obj:" .OR. x[ 1 ] == ".cpp.obj:" } ) + ENDIF + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ELSE + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".C.O:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".C.OBJ:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + ENDIF + + ENDIF + + FOR nFiles := 1 TO Len( s_aCFiles ) + + xItem := Substr( s_aCFiles[ nFiles ], Rat( IIF( s_lGcc, '/', '\' ), ; + s_aCFiles[ nFiles ] ) + 1 ) + nPos := AScan( s_aObjs, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), ; + Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) + + IF nPos > 0 + + IF llinux + cComm := Strtran( cComm, "o$*", "o" + s_aObjs[ nPos ] ) + ELSE + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + Strtran( s_aObjs[ nPos ], '/', '\' ) ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + Strtran( s_aObjs[ nPos ], '/', '\' ) ) + ENDIF + ENDIF + + cComm := Strtran( cComm, "$**", s_aCFiles[ nFiles ] ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + Outstd( " " ) + Outstd( cComm ) + Outstd( CRLF ) + setpos(9,0) + __RUN( (cComm) ) + cComm := cOld + ENDIF + + NEXT + + ENDIF + + ELSE /****** Extended mode *****/ + + IF cOrder == "$(CFILES)" + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.o:" .OR. x[ 1 ] == ".cpp.o:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.obj:" .OR. x[ 1 ] == ".cpp.obj:" } ) + ENDIF + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".C.OBJ:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + ENDIF + + IF Len( s_aCFiles ) > 0 + + GaugeDisplay( aGauge ) + nFile := 1 + + FOR nFiles := 1 TO Len( s_aCFiles ) + @ 4, 16 SAY Space( 50 ) + xItem := Substr( s_aCFiles[ nFiles ], Rat( IIF( s_lGcc, '/', '\' ), ; + s_aCFiles[ nFiles ] ) + 1 ) + nPos := AScan( s_aObjsC, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), ; + Left( x, At( ".", x ) ) == Left( xitem, At( ".", xitem ) ) } ) + + IF nPos > 0 + + IF llinux + cComm := Strtran( cComm, "o$*", "o" + s_aObjsC[ nPos ] ) + ELSE + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + Strtran( s_aObjsC[ nPos ], '/', '\' ) ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + Strtran( s_aObjsC[ nPos ], '/', '\' ) ) + ENDIF + ENDIF + + cComm := Strtran( cComm, "$**", s_aCFiles[ nFiles ] ) + + cComm += IIF( s_lLinux , " "," >>"+ (s_cLog)) + + @4,16 SAY s_aCFiles[ nFiles ] + GaugeUpdate( aGauge, nFile / Len( s_aCFiles ) ) // Changed s_aPrgs to s_aCFiles, Ath 2004-06-08 + nFile ++ + //Outstd( cComm ) + setpos(9,0) + if s_lMingw + cComm := strtran(cComm ,"\","/") + endif + __RUN( (cComm) ) + cErrText := Memoread( (s_cLog) ) + lEnd := 'Error E' $ cErrText + IF ! s_lIgnoreErrors .AND. lEnd + __run( s_cEditor + " "+(s_cLog) ) + SET CURSOR ON + QUIT + ELSE + // FErase( s_cLog ) + ENDIF + lEnd := 'Error F' $ cErrText + + cComm := cOld + + ENDIF + + NEXT + + ENDIF + + ENDIF + + IF cOrder == "$(OBJFILES)" + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".prg.o:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".prg.obj:" } ) + ENDIF + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ELSE + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".PRG.O:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".PRG.OBJ:" } ) + ENDIF + + ENDIF + + GaugeDisplay( aGauge ) + nFile := 1 + + FOR EACH cPrg IN s_aPrgs + + @ 4, 16 SAY Space( 50 ) + xItem := Substr( cPrg, Rat( IIF( s_lGcc, '/', '\' ), ; + cPrg ) + 1 ) + nPos := AScan( s_aObjs, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), ; + Left( x, At( ".", x ) ) == Left( xItem, At( ".", xitem ) ) } ) + + IF nPos > 0 + + IF llinux + cComm := Strtran( cComm, "o$*", "o" + s_aObjs[ nPos ] ) + ELSE + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + Strtran( s_aObjs[ nPos ], '/', '\' ) ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + Strtran( s_aObjs[ nPos ], '/', '\' ) ) + ENDIF + ENDIF + + cComm := Strtran( cComm, "$**", cPrg ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + + @4,16 SAY cPrg + GaugeUpdate( aGauge, nFile / Len( s_aPrgs ) ) + // Outstd( CRLF ) + nFile ++ + setpos(9,0) + __RUN( (cComm) ) + cErrText := Memoread( (s_cLog) ) + lEnd := 'C2006' $ cErrText .OR. 'No code generated' $ cErrText .or. "Error E" $ cErrText .or. "Error F" $ cErrText + + IF ! s_lIgnoreErrors .AND. lEnd + __run( s_cEditor + " "+(s_cLog) ) + SET CURSOR ON + QUIT + ELSE + //FErase( s_cLog ) + ENDIF + + cComm := cOld + + ENDIF + + NEXT + + ENDIF + + ENDIF + + IF cOrder == "$(RESDEPEN)" + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".rc.res:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + FOR nFiles := 1 TO Len( s_aResources ) + + IF ! Empty( s_aResources[ nFiles ] ) + cComm := Strtran( cComm, "$<", s_aResources[ nFiles ] ) + outstd( " " ) + ? cComm + setpos(9,0) + __RUN( (cComm) ) + ENDIF + + cComm := cOld + + NEXT + + ENDIF + + NEXT + +RETURN NIL + +*------------------------------- +FUNCTION GetParaDefines( cTemp ) +*------------------------------- + + LOCAL nPos + LOCAL cRead + LOCAL aSet := {} + LOCAL nMakePos + + IF "\.." $ cTemp + cTemp := Substr( cTemp, 1, At( "\..", cTemp ) - 1 ) + ELSEIF "/.." $ cTemp + cTemp := Substr( cTemp, 1, At( "/..", cTemp ) - 1 ) + ENDIF + if at("=",ctemp) == 0 + cTemp += [=""] + endif + aSet := ListAsArray2( cTemp, "=" ) + nPos := AScan( s_aDefines, { | x | x[ 1 ] == aSet[ 1 ] } ) + + IF nPos == 0 + cRead := Alltrim( Strtran( aSet[ 2 ], "$(", "" ) ) + cRead := Strtran( cRead, ")", "" ) + nMakePos := AScan( s_aDefines, { | x | x[ 1 ] == cRead } ) + + IF nMakePos = 0 + if(aSet[1] == "MYDEFINES") + ASet[ 2 ] := Strtran( aSet[ 2 ], ",", ";" ) + else + ASet[ 2 ] := Strtran( aSet[ 2 ], ",", " " ) + endif + AAdd( s_aDefines, { aSet[ 1 ], aSet[ 2 ] } ) + AAdd( s_aMacros, { aSet[ 1 ], aSet[ 2 ] } ) + else + s_aDefines[nMakepos,2] +=";"+aSet[ 2 ] + s_aMacros[nMakepos,2]+=";"+ aSet[ 2 ] + + ENDIF + + ENDIF + +RETURN NIL + +*--------------------- +FUNCTION PrintMacros() +*--------------------- + + LOCAL nPos + + Outstd( HbMake_Id()+ " "+HbMake_Copyright()+ CRLF ) + Outstd( "" + CRLF ) + Outstd( "Macros:" + CRLF ) + AEval( s_aMacros, { | xItem | Outstd( " " + xItem[ 1 ] + " = " + xItem[ 2 ] + CRLF ) } ) + Outstd( "Implicit Rules:" + CRLF ) + AEval( s_aCommands, { | xItem | Outstd( " " + xItem[ 1 ] + CRLF + " " + xItem[ 2 ] + CRLF ) } ) + Outstd( "" + CRLF ) + Outstd( "Targets:" ) + Outstd( " " + s_szProject + ":" + CRLF ) + Outstd( " " + "Flags :" + CRLF ) + Outstd( " " + "Dependents :" ) + AEval( s_aCFiles, { | xItem | Outstd( xitem + " " ) } ) + AEval( s_aObjs, { | xItem | Outstd( xitem + " " ) } ) + Outstd( " " + CRLF ) + Outstd( " commands:" + s_aBuildOrder[ Len( s_aBuildOrder ) ] ) + Outstd( " " + CRLF ) + Outstd( " " + CRLF ) + Outstd( " " + CRLF ) + +RETURN NIL + +*-------------------------------------------------- +FUNCTION CreateMakeFile( cFile, lCreateAndCompile ) +*-------------------------------------------------- + + LOCAL aInFiles := {} + LOCAL aOutFiles := {} + LOCAL aOutc := {} + LOCAL aSrc := Directory( "*.prg" ) + LOCAL nLenaSrc := Len( aSrc ) + + LOCAL lFwh := .F. +// LOCAL lxFwh := .F. + LOCAL lC4W := .F. + LOCAL lMiniGui := .F. + LOCAL lHwGui := .F. + LOCAL lWhoo := .F. + LOCAL lWhat32 := .F. + LOCAL lGtWvt := .F. + LOCAL lGtWvw := .F. + LOCAL lMWvw := .F. + LOCAL lXwt := .F. + LOCAL lxHGtk := .F. + + LOCAL lRddAds := .F. + LOCAL lMediator := .F. + LOCAL lApollo := .F. + +// LOCAL lMt := .F. + LOCAL cOS := IIF( s_lUnix, "Unix", IIF( s_lLinux, "Linux", iif(s_lOS2,"OS/2","Win32") ) ) + LOCAL cCompiler := IIF( s_lLinux .OR. s_lGcc, "GCC",iif(s_lPocc,"POCC",iif(s_lMSVcc,"MSVC","BCC"))) + + // External GUI Libs + LOCAL cFwhPath := Space( 200 ) + LOCAL cC4WPath := Space( 200 ) + LOCAL cMiniPath := Space( 200 ) + LOCAL cHwPath := Space( 200 ) + LOCAL cxHGPath := Space( 200 ) + + LOCAL cMedPath := Space( 200 ) + LOCAL cApolloPath := Space( 200 ) + + LOCAL cObjDir := s_cObjDir + space( 20 ) + LOCAL lAutoMemvar := .F. + LOCAL lVarIsMemvar := .F. + LOCAL lDebug := .F. + LOCAL lSupressLine := .F. + LOCAL nPos + LOCAL cHarbourFlags := "" + +// LOCAL nWarningLevel :=0 + + LOCAL lUseharbourDll := .F. + + LOCAL lCompMod := .F. + +// LOCAL lGenppo := .F. + LOCAL x + LOCAL getlist := {} + LOCAL cTopFile := Space(50) + LOCAL cAppName := padr(s_cAppName,50) + LOCAL cDefaultLibs := "lang.lib vm.lib rtl.lib rdd.lib macro.lib pp.lib dbfntx.lib dbfcdx.lib dbffpt.lib common.lib gtwin.lib codepage.lib ct.lib tip.lib pcrepos.lib hsx.lib hbsix.lib" + LOCAL cDefGccLibs := "-lvm -lrtl -lpcrepos -lgtdos -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -ldbffpt -lhsx -lhbsix -lcommon -lcodepage -lm " + LOCAL cDefGccLibsUnix := "-lvm -lcodepage -ltef -lrtl -lrdd -lrtl -lvm -lmacro -lpp -llang -lcommon -lnulsys -lbmdbfcdx -ldbfntx -ldbfcdx -ldbffpt -lhbsix -lhsx -lusrrdd -lpcrepos -lgtnul -lgtsln -lslang -lm -lrt " + LOCAL cDefGccLibsw := "-lvm -lrtl -lpcrepos -lgtwin -lgtnul -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -ldbffpt -lhsx -lhbsix -lcommon -lcodepage -lm" + LOCAL cGccLibsOs2 := "-lvm -lrtl -lpcrepos -lgtos2 -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -ldbffpt -lhsx -lhbsix -lcommon -lcodepage -lm" + LOCAL cDefLibGccLibs := "-lvm -lrtl -lpcrepos -lgtcrs -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -ldbffpt -lhsx -lhbsix -lcommon -lcodepage -lgtnul" + LOCAL cDefaultLibsMt := "lang.lib vmmt.lib rtlmt.lib rddmt.lib macromt.lib ppmt.lib dbfntxmt.lib dbfcdxmt.lib dbffptmt.lib common.lib gtwin.lib codepage.lib ctmt.lib tipmt.lib pcrepos.lib hsxmt.lib hbsixmt.lib" + LOCAL cDefGccLibsUnixMt := "-lvmmt -lcodepage -ltef -lrtlmt -lrddmt -lrtl -lvmmt -lmacromt -lpp -llang -lcommon -lnulsys -lbmdbfcdx -ldbfntx -ldbfcdx -ldbffpt -lhbsix -lhsx -lusrrdd -lpcrepos -lgtnul -lgtsln -lslang -lm -lrt" + LOCAL cDefGccLibsMt := "-lvmmt -lrtlmt -lpcrepos -lgtdos -llang -lrddmt -lrtlmt -lvmmt -lmacromt -lppmt -ldbfntxmt -ldbfcdxmt -ldbffptmt -lhsxmt -lhbsixmt -lcommon -lcodepage -lm" + LOCAL cDefGccLibsMtw := "-lvmmt -lrtlmt -lpcrepos -lgtwin -lgtnul -llang -lrddmt -lrtlmt -lvmmt -lmacromt -lppmt -ldbfntxmt -ldbfcdxmt -ldbffptmt -lhsxmt -lhbsixmt -lcommon -lcodepage -lm" + LOCAL cGccLibsOs2Mt := "-lvmmt -lrtlmt -lpcrepos -lgtos2 -llang -lrddmt -lrtlmt -lvmmt -lmacromt -lppmt -ldbfntxmt -ldbfcdxmt -ldbffptmt -lhsxmt -lhbsixmt -lcommon -lcodepage -lm" +// LOCAL cDefLibGccLibsMt := "-lvmmt -lrtlmt -lpcrepos -lgtcrs -llang -lrddmt -lrtlmt -lvmmt -lmacromt -lppmt -ldbfntxmt -ldbfcdxmt -ldbffptmt -lhsxmt -lhbsixmt -lcommon -lcodepage" + LOCAL cDefLibGccLibsMt := "-lvmmt -lrtlmt -lpcrepos -lgtsln -llang -lrddmt -lrtlmt -lvmmt -lmacromt -lppmt -ldbfntxmt -ldbfcdxmt -ldbffptmt -lhsxmt -lhbsixmt -lcommon -lcodepage" + LOCAL cHarbDll := "harbour.lib" + LOCAL cHARso := "-lharbour -lncurses -lgpm -lslang -lpthread -lm" + LOCAL cSystemLibs := If( s_lUnix, "", "-lncurses " ) + "-lslang " + If( s_lUnix, "", "-lgpm " ) + " -lpthread -lm" + + LOCAL cLibs := "" + LOCAL citem := "" + LOCAL cExt := "" + LOCAL cDrive := "" + LOCAL cPath := "" + LOCAL cTest := "" + LOCAL cGuiLib := "None" + LOCAL aLibs + LOCAL aLibsIn := {} + LOCAL aLibsOut := {} + LOCAL cGt := "" + + LOCAL cOldLib := "" + LOCAL cHtmlLib := "" + LOCAL lLinux := s_lLinux + LOCAL lUnix := s_lUnix + LOCAL nWriteFiles := 0 + LOCAL cResName := space(200) + LOCAL aSelFiles + + LOCAL cBuild := " " + LOCAL cBuildForced := " " + LOCAL cBuildParam := NIL + + LOCAL aUserDefs + LOCAL cCurrentDef := "" + LOCAL cRdd := "None" + LOCAL cCurrentDir := "" + LOCAL nOption + LOCAL lNew := .F. + LOCAL oMake + LOCAL cAllRes := "" + LOCAL cTemp + LOCAL cExtraLibs :="" + LOCAL cTempLibs := "" + LOCAL aTempLibs + + LOCAL aUserLibs + LOCAL cUserLib + + #IFdef HBM_USE_DEPENDS + LOCAL cIncl := "" + LOCAL lScanIncludes := .F. + // Provisions for recursive scanning + LOCAL lScanIncRecursive := .F. + LOCAL cExcludeExts := PadR(".ch",40) + #ENDIF + + #ifndef __PLATFORM__Windows + LOCAL lHashhso := File("/usr/lib/libharbour.so") + LOCAL lusexhb := FILE("/usr/bin/hb-build") + #ELSE + LOCAL lusexhb := .F. + #ENDIF + + LOCAL cHarbourLibDir := s_cHarbourDir + iif(s_lLinux,"/lib","\lib") + LOCAL lCancelMake := .F. + + + s_cUserInclude := space(200) + s_cUserDefine := space(200) + s_cUserLibs := space(200) + + + IF File( cFile ) + + CLS + + IF s_nLang == 1 // Portuguese-BR + nOption := Alert( "O makefile <" + cFile +"> j  existe.",{ "Editar", "Criar Novo" , "Cancelar" } ) + ELSEIF s_nLang == 3 // Spanish + nOption := Alert( "Lo makefile <" + cFile +"> ya existe.",{ "Editar", "Crear Nuevo" , "Cancelar" } ) + ELSE // English + nOption := Alert( "The makefile <" + cFile +"> already exist ",{ "Edit" , "Create New" , "Cancel" } ) + ENDIF + + + IF nOption = 1 // edit makefile + + // Verify if "cFile" can be openned to write mode. + + s_nMakeFileHandle := FOpen( cFile, FO_WRITE ) + + IF s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser aberto para edi‡Æo." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser abierto para edici¢n." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be openned for edition." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+LTrim(Str(FError()))+")" ) + + RETURN NIL + ELSE + FClose( s_nMakeFileHandle ) + ENDIF + + oMake :=THbMake():new() + oMake:cMakefile := cFile + oMake:cMacro := iif(s_lMSVcc,"#MSVC",iif(s_lPocc,"#POCC",iif(s_lGcc,"#GCC","#BCC"))) + oMake:ReadMakefile(cFile) + + FRename(cFile,cFile+".old") + + IF LEN(oMake:aRes) >0 + FOR EACH cTemp IN oMake:aRes + cAllRes += cTemp+ " " + NEXT + ENDIF + + lAutoMemVar := oMake:lAutomemvar + lVarIsMemVar := oMake:lvarismemvar + lDebug := oMake:ldebug + lSupressline := oMake:lSupressline + lCompMod := oMake:lCompMod + s_lGenppo := oMake:lGenppo + s_lGui := oMake:lGui + cRdd := IIF( oMake:lRddAds, "RddAds", IIF( oMake:lMediator, "Mediator", "None" ) ) + cGuiLib := IIF( oMake:lFwh , "FWH", ; + IIF( oMake:lMini , "MINIGUI", ; + IIF( oMake:lWhoo , "WHOO", ; + IIF( oMake:lCw , "C4W", ; + IIF( oMake:lHwGui , "HWGUI", ; + IIF( oMake:lGtWvt , "GTWVT", ; + IIF( oMake:lMWvW , "GTWVW+MWVW", ; + IIF( oMake:lGtWvw , "GTWVW", ; + IIF( oMake:lXWt , "XWT", ; + IIF( oMake:lWhat32, "WHAT32", ; + IIF( oMake:lxHGtk , "XHGTK", "" ) ) ) ) ) ) ) ) ) )) + cFwhpath := padr(oMake:cFmc,200) + cApolloPath := padr(oMake:cFmc,200) + cC4WPath := padr(oMake:cFmc,200) + cMiniPath := padr(oMake:cFmc,200) + cHwPath := padr(oMake:cFmc,200) + cxHGPath := padr(oMake:cFmc,200) + cMedpath := padr(oMake:cMedpath,200) + cAppName := padr(oMake:cAppLibName,50) + s_cAppName := cAppName + s_lCompress := oMake:lCompress + s_lExternalLib := oMake:lExternalLib + s_cUserInclude := padr(oMake:cUserInclude,200) + s_cUserDefine := padr(oMake:cUserDef,200) + s_cUserLibs := padr(oMake:cUserLib,200) + s_lxFwh := oMake:lxFwh + s_nFilesToAdd := oMake:cFilesToAdd + s_lMt := oMake:lMt + s_nWarningLevel := oMake:cWarningLevel + cTopFile := PadR(oMake:cTopModule,50," ") + cResName := PadR(oMake:cRes,200) + s_cObjDir := oMake:cObj + cObjDir := s_cObjDir + space(20) + s_lGenCsource := oMake:lGenCsource + s_cEditor := trim(oMake:cEditor) + + if Empty( s_cEditor ) + if s_lOS2 .OR. s_lLinux + s_cEditor := "mcedit" + else + s_cEditor := "edit" + endif + endif + + if !s_lRecursive + s_lRecursive := oMake:lRecurse + endif + + + IF nLenaSrc == 0 .and. !s_lRecursive + + CLS + + IF s_nLang=1 // PT-BR + s_cAlertMsg := "NÆo h  nenhum prg na pasta "+CurDir()+". Use o modo recursivo -r" + ELSEIF s_nLang=3 // Spanish + s_cAlertMsg := "No hay ning£n prg en la carpeta "+CurDir()+". Use lo modo recursivo -r" + ELSE + s_cAlertMsg := "Does not have any prg in "+CurDir()+" folder. Use the recursive mode -r" + ENDIF + + Alert( s_cAlertMsg ) + + SetColor("W/N,N/W") + CLS + set cursor on + QUIT + + ENDIF + + if s_lCancelRecursive + s_lRecursive := .F. + endif + + // after oMake read, recreate other clean makefile to edit. + s_nMakeFileHandle := FCreate(cFile) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser aberto para edi‡Æo." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser abierto para edici¢n." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be openned for edition." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + + RETURN NIL + + endif + + WriteMakeFileHeader() + + s_lEditMake := .T. + + + ELSEIF nOption = 2 // create a new makefile + + + IF nLenaSrc == 0 .and. !s_lRecursive + + CLS + + IF s_nLang=1 // PT-BR + s_cAlertMsg := "NÆo h  nenhum prg na pasta "+CurDir()+". Use o modo recursivo -r" + ELSEIF s_nLang=3 // Spanish + s_cAlertMsg := "No hay ning£n prg en la carpeta "+CurDir()+". Use lo modo recursivo -r" + ELSE + s_cAlertMsg := "Does not have any prg in "+CurDir()+" folder. Use the recursive mode -r" + ENDIF + + Alert( s_cAlertMsg ) + SetColor("W/N,N/W") + CLS + set cursor on + QUIT + + ENDIF + + s_lEditMake := .F. + + s_nMakeFileHandle := FCreate( cFile ) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser criado." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be created." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + + RETURN NIL + + endif + + + WriteMakeFileHeader() + lNew := .T. + + ELSE + SetColor("W/N,N/W") + CLS + set cursor on + QUIT + ENDIF + + ELSE + + s_nMakeFileHandle := FCreate( cFile ) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser criado." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be created." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + + RETURN NIL + + ENDIF + + WriteMakeFileHeader() + nOption := 2 // create a new makefile + lNew := .T. + + ENDIF + +IF ! lCreateAndCompile + +While .t. + + CLS + Setcolor( 'w/b+,b+/w,w+/b,w/b+,w/b,w+/b' ) + @ 0, 0, Maxrow(), Maxcol() BOX( Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 ) + Space( 1 ) ) + + Attention( HbMake_Id() + space(10)+s_aLangMessages[ 27 ], 0 ) + + Attention( s_aLangMessages[ 47 ], maxrow() ) + + @ 01,01 SAY s_aLangMessages[ 28 ] + + @ 01,16,06,21 GET cOS; + LISTBOX { "Win32", "OS/2", "Linux","Unix" }; + MESSAGE s_aLangMessages[ 49 ]; + STATE OsSpec(getlist,1,@cOS); + DROPDOWN + + @ 01,23 SAY s_aLangMessages[ 29 ] + + @ 01,47,08,52 GET cCompiler; + LISTBOX { "BCC", "MSVC", "GCC", "POCC","MINGW" }; + MESSAGE s_aLangMessages[ 50 ]; + STATE OsSpec(getlist,2,@cCompiler); + DROPDOWN + + @ 01,56 SAY s_aLangMessages[ 30 ] + + @ 01,67,10,78 GET cGuiLib; + LISTBOX { "None","C4W","FWH","GTWVT","GTWVW","GTWVW+MWVW","HWGUI","MINIGUI","XWT","WHAT32","WHOO","XHGTK"}; + STATE OsSpec(getlist,3,@cGuiLib); + DROPDOWN; + WHEN CheckCompiler(cOS); + MESSAGE s_aLangMessages[ 51 ] + + @ 02,01 SAY s_aLangMessages[ 48 ] + + @ 02,16,08,26 GET cRdd; + LISTBOX { "None","RddAds","Mediator","Apollo"}; + WHEN cOS == "Win32" .or. cOS == "Linux"; + DROPDOWN; + MESSAGE s_aLangMessages[ 52 ] + + @ 02,30 GET s_lCompress; + CHECKBOX; + CAPTION s_aLangMessages[ 53 ]; + STYLE "[X ]"; + MESSAGE s_aLangMessages[ 54 ] + + @ 02,53 GET lUseHarbourDll; + CHECKBOX; + CAPTION "use Harbour[.dll|.so]" style "[X ]"; + WHEN cOS == "Win32" .or. cOS == "Linux"; + MESSAGE s_aLangMessages[ 55 ] + + @ 03,01 SAY "Obj Files Dir"; + GET cObjDir; + PICT "@S20"; + MESSAGE s_aLangMessages[ 56 ] + + @ 03,47 SAY s_aLangMessages[ 66 ] + +#ifdef __PLATFORM__Windows + @ 03,68,07,77 GET s_cEditor; + LISTBOX { "edit", "notepad" }; + MESSAGE s_aLangMessages[ 67 ]; + STATE OsSpec(getlist,4,@s_cEditor); + DROPDOWN +#endif + @ 04,01 SAY s_aLangMessages[ 45 ]; + GET cAppName; + PICT "@S15"; + VALID ! Empty( cAppName ); + MESSAGE s_aLangMessages[ 57 ] + + @ 04,53 GET s_lasdll; + CHECKBOX; + CAPTION "Create dll"; + STYLE "[X ]" + + READ MSG AT MaxRow() - 1, 1, MaxCol() - 1 + + s_cAppName := alltrim( cAppName ) + + IF cOS != "Linux" .or. cOS != "Unix" + IF s_lasdll + s_cAppName += ".dll" + ELSE + s_cAppName += ".exe" + ENDIF + ENDIF + + if s_lasdll + lUseharbourDll:= .T. + endif + + lFwh := "FWH" $ alltrim(cGuiLib) + lC4W := "C4W" $ alltrim(cGuiLib) + lMiniGui := "MINIGUI" $ alltrim(cGuiLib) + lHwGui := "HWGUI" $ alltrim(cGuiLib) + lWhoo := "WHOO" $ alltrim(cGuiLib) + lWhat32 := "WHAT32" $ alltrim(cGuiLib) + lGtWvt := "GTWVT" $ alltrim(cGuiLib) + lGtWvw := "GTWVW" $ alltrim(cGuiLib) + lMWvw := "MWVW" $ alltrim(cGuiLib) + lXwt := "XWT" $ alltrim(cGuiLib) + lxHGtk := "XHGTK" $ alltrim(cGuiLib) + s_lGui := lWhoo .or. lFwh .or. lC4W .or. lMinigui .or. lGtWvt .or. lHwGui .or. lXwt .or. lWhat32 .or. lxHGtk .or. lGtWvw .or. lMWvw + + lRddAds := "RddAds" $ cRdd + lMediator := "Mediator" $ cRdd + lApollo := "Apollo" $ cRdd + + IF lUseharbourDll + cDefLibGccLibs := cHARso + cDefaultLibs := cHarbDll + " dllmain.lib " + ENDIF + + IF lFwh + @ 3, 40 SAY "FWH path"; + GET cFwhPath; + PICT "@S25" + ELSEIF lC4W + @ 3, 40 SAY "C4W path"; + GET cC4WPath; + PICT "@S25" + ELSEIF lMiniGui + @ 3, 40 SAY "MiniGui path"; + GET cMiniPath; + PICT "@S25" + ELSEIF lHwGui + @ 3, 40 SAY "HwGUI path"; + GET cHwPath; + PICT "@S25" + ELSEIF lxHGtk + @ 3, 40 SAY "xHGtk path"; + GET cxHGPath; + PICT "@S25" + ENDIF + + IF lMediator + @ 3, 40 SAY "Mediator path"; + GET cMedPath; + PICT "@S25" + ENDIF + + IF lApollo + @ 03, 40 SAY "Apollo path"; + GET cApolloPath; + PICT "@S25" + ENDIF + + IF nOption = 2 // create a new makefile + cResName := PadR(alltrim(cResName)+iIF(!empty(cResName)," ","")+alltrim(cAllRes),200 ) + ENDIF + + Attention( s_aLangMessages[ 31 ], 5 ) + + @ 06, 01 GET lAutoMemVar; + CHECKBOX; + CAPTION s_aLangMessages[ 32 ]; + STYLE "[X ]" + + @ 06, 40 GET lVarIsMemVar; + CHECKBOX; + CAPTION s_aLangMessages[ 33 ]; + STYLE "[X ]" + + @ 07, 01 GET lDebug; + CHECKBOX; + CAPTION s_aLangMessages[ 34 ]; + STYLE "[X ]" + + @ 07, 40 GET lSupressLine; + CHECKBOX; + CAPTION s_aLangMessages[ 35 ]; + STYLE "[X ]" + + @ 08, 01 GET s_lGenppo; + CHECKBOX; + CAPTION s_aLangMessages[ 36 ]; + STYLE "[X ]" + + @ 08, 40 GET lCompMod; + CHECKBOX; + CAPTION s_aLangMessages[ 37 ]; + STYLE "[X ]" + + @ 09, 01 SAY s_aLangMessages[ 38 ]; + GET s_cUserDefine; + PICT "@s23" + + @ 09, 40 SAY s_aLangMessages[ 39 ]; + GET s_cUserInclude; + PICT "@s18" + + @ 10, 01 GET s_lExternalLib; + CHECKBOX; + CAPTION s_aLangMessages[ 40 ]; + STYLE "[X ]" + + @ 10, 40 GET s_lxFwh; + CHECKBOX; + CAPTION "Harbour FWH"; + STYLE "[X ]" + + @ 11, 01 SAY "Resource file Name: "; + GET cResName; + PICT "@S55" + + @ 12, 01 SAY s_aLangMessages[ 43 ]; + GET s_nFilestoAdd; + PICT "99"; + VALID s_nFilestoAdd > 0 + + @ 13, 01 GET s_lMt; + CHECKBOX; + CAPTION s_aLangMessages[ 44 ]; + STYLE "[X ]" + + @ 13, 40 SAY s_aLangMessages[ 46 ]; + GET s_nWarningLevel; + PICT "9"; + VALID s_nWarningLevel>=0 .AND. s_nWarningLevel <= 4 + + @ 14, 01 GET s_lGenCsource; + CHECKBOX; + CAPTION "Generate C-source, not PCode (-go3)"; + STYLE "[X ]" + + @ 15, 01 SAY s_aLangMessages[ 65 ]; + GET s_cUserLibs; + PICT "@S58" + + READ msg at maxrow()-1,1,maxcol()-1 + + IF LastKey()==K_ESC + SET CURSOR ON + SetColor("W/N") + CLS + RETURN NIL + ENDIF + + IF Empty( cAppName ) + IF s_nLang == 1 + Alert("Falta nome da aplica‡Æo.") + ELSEIF s_nLang == 3 + Alert("Falta lo nombre de la aplicacion.") + ELSE + Alert("Application name is missing.") + ENDIF + ELSE + EXIT + ENDIF + +Enddo + +Endif // Create and compile + + IF ! Empty( s_cUserDefine ) + aUserDefs := ListasArray2(Alltrim( s_cUserDefine ), ";") + + FOR EACH cCurrentDef in aUserDefs + cHarbourFlags += " -D" + Alltrim( cCurrentDef ) + " " + NEXT + ENDIF + + IF ! Empty( s_cUserLibs ) + aUserLibs := ListAsArray2( alltrim(s_cUserLibs), ";" ) + FOR EACH cUserLib IN aUserLibs + if !file( cUserLib ) + alert( "User Lib: "+cUserLib +" not found.") + exit + endif + NEXT + ENDIF + + IF ! Empty( s_cUserInclude ) + cHarbourFlags += " -I" + Alltrim( s_cUserInclude ) + " " + ENDIF + + s_lBcc := "BCC" $ cCompiler + s_lMSVcc := "MSVC" $ cCompiler + s_lGcc := "GCC" $ cCompiler + s_lPocc := "POCC" $ cCompiler + s_lMinGW := "MINGW" $ cCompiler + + if s_lMinGW + s_lGcc := .T. + s_lBcc := s_lMSVcc := s_lPocc := .F. + endif + + cObjDir := Alltrim( cObjDir ) + + IF "Linux" $ cOS .or. "Unix" $ cOS + cCurrentDir := "/"+CurDir() + ELSE + cCurrentDir := CurDrive()+":\"+CurDir() + ENDIF + + IF ! Empty( cObjDir ) + + IF !hb_DirExists( cObjDir ) +#ifdef HB_COMPAT_C53 + MakeDir( cObjDir ) +#endif + ENDIF + + ENDIF + + s_aMacros := GetSourceDirMacros( s_lGcc, cOS ) + + IF lLinux .or. lUnix + cObjDir := Alltrim( cObjDir ) + + IF ! Empty( cObjDir ) + cObjDir += '/' + ENDIF + + cTest := cObjDir + ELSE + cObjDir := Alltrim( cObjDir ) + + IF ! Empty( cObjDir ) + cObjDir += '\' + ENDIF + + cTest := Upper( cObjDir ) + '\' + ENDIF + + AEval( s_aMacros, { | x, y | cItem := Substr( x[ 2 ], 1, Len( x[ 2 ] ) ), IIF( At( citem, cTest ) > 0, ( s_aMacros[ y, 1 ] := 'OBJ', s_aMacros[ y, 2 ] := cObjDir ), ) } ) + + IF lAutomemvar + cHarbourFlags += " -a " + ENDIF + + IF lvarismemvar + cHarbourFlags += " -v " + ENDIF + + + IF lDebug + cHarbourFlags += " -b " + cDefaultLibs += " debug.lib " + cDefGccLibs += " -ldebug " + cDefGccLibsw += " -ldebug " + cGccLibsOs2 += " -ldebug " + cDefLibGccLibs += " -ldebug " + cDefGccLibsUnix += " -ldebug " + cDefGccLibsUnixMt+= " -ldebug " + cDefaultLibsMt += " debug.lib " + cDefGccLibsMt += " -ldebug " + cDefGccLibsMtw += " -ldebug " + cGccLibsOs2Mt += " -ldebug " + cDefLibGccLibsMt += " -ldebug " + ENDIF + + IF lSupressline + cHarbourFlags += " -l " + ENDIF + + IF s_lGenppo + cHarbourFlags += " -p " + ENDIF + + IF lCompmod + cHarbourFlags += " -m " + ENDIF + + if lMWvw + cHarbourFlags += ' -u+mwvw.ch ' + endif + + + IF s_nWarningLevel >= 0 + cHarbourFlags += " -w" + Str(s_nWarningLevel,1) + ENDIF + + + IF s_lBcc + + AAdd( s_aCommands, { ".cpp.obj:", "$(CC_DIR)\BIN\bcc32 $(CFLAG1) $(CFLAG2) -o$* $**" } ) + AAdd( s_aCommands, { ".c.obj:", "$(CC_DIR)\BIN\bcc32 -I$(HB_DIR)\include $(CFLAG1) $(CFLAG2) -o$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.obj:", "$(HB_DIR)\bin\harbour -D__EXPORT__ -n"+if(s_lasdll,"1","")+" -go" + if(s_lGenCsource,"3","") + " -I$(HB_DIR)\include $(HARBOURFLAGS)" + IIF( lFwh, " -I$(FWH)\include", IIF( lMinigui, " -I$(MINIGUI)\include",IIF( lHwgui, " -I$(HWGUI)\include","" ) ) )+IIF( lWhoo," -I$(WHOO)\include ","")+ IIF( lMediator," -I$(MEDIATOR)\include ","")+" -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)\include $(HARBOURFLAGS)" + IIF( lFwh, " -I$(FWH)\include", IIF( lMinigui, " -I$(MINIGUI)\include",IIF( lHwgui, " -I$(HWGUI)\include","" ) )) + " -o$* $**" } ) + ENDIF + + AAdd( s_aCommands, { ".rc.res:", "$(CC_DIR)\BIN\brcc32 $(RFLAGS) $<" } ) + + ELSEIF s_lGcc + + IF ("linux" $ Lower(Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Linux" ) .or.; + ("unix" $ Lower(Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Unix" .OR. cOS == "HP-UX" ) + AAdd( s_aCommands, { ".cpp.o:", "gcc $(CFLAG1) $(CFLAG2) -o$* $**" } ) + AAdd( s_aCommands, { ".c.o:", "gcc -I/usr/include/harbour $(CFLAG1) $(CFLAG2) -I. -g -o$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.o:", "harbour -D__EXPORT__ -n"+if(s_lasdll,"1","")+" -go" + if(s_lGenCsource,"3","") + " -I/usr/include/harbour $(HARBOURFLAGS) -I. -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "harbour -n -I/usr/include/harbour $(HARBOURFLAGS) -I. -o$* $**" } ) + ENDIF + + ELSE + AAdd( s_aCommands, { ".cpp.o:", "$(CC_DIR)\bin\gcc $(CFLAG1) $(CFLAG2) -o$* $**" } ) + AAdd( s_aCommands, { ".c.o:", "$(CC_DIR)\bin\gcc -I$(HB_DIR)/include $(CFLAG1) $(CFLAG2) -I. -o$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.o:", "$(HB_DIR)\bin\harbour -D__EXPORT__ -n"+if(s_lasdll,"1","")+" -go" + if(s_lGenCsource,"3","") + " -I$(HB_DIR)/include $(HARBOURFLAGS) " +IIF( lHwgui, " -I$(HWGUI)/include","" ) +" -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)/include $(HARBOURFLAGS) " +IIF( lHwgui, " -I$(HWGUI)/include","" ) +" -o$* $**" } ) + ENDIF + + ENDIF + + ELSEIF s_lMSVcc + + AAdd( s_aCommands, { ".cpp.obj:", "$(CC_DIR)\bin\cl $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + AAdd( s_aCommands, { ".c.obj:", "$(CC_DIR)\bin\cl -I$(HB_DIR)\include $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.obj:", "$(HB_DIR)\bin\harbour -D__EXPORT__ -n -I$(HB_DIR)\include $(HARBOURFLAGS) -go" + if(s_lGenCsource,"3","") + " -I$(C4W)\include" + IIF( lMediator," -I$(MEDIATOR)\include ","")+ "-o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(C4W)\include -o$* $**" } ) + ENDIF + + AAdd( s_aCommands, { ".rc.res:", "$(CC_DIR)\rc $(RFLAGS) $<" } ) + + ELSEIF s_lPocc + + AAdd( s_aCommands, { ".cpp.obj:", "$(CC_DIR)\BIN\pocc $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + AAdd( s_aCommands, { ".c.obj:", "$(CC_DIR)\BIN\pocc -I$(HB_DIR)\include $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.obj:", "$(HB_DIR)\bin\harbour -D__EXPORT__ -n"+if(s_lasdll,"1","")+" -go" + if(s_lGenCsource,"3","") + " -I$(HB_DIR)\include $(HARBOURFLAGS)" + IIF( lFwh, " -I$(FWH)\include", IIF( lMinigui, " -I$(MINIGUI)\include",IIF( lHwgui, " -I$(HWGUI)\include","" ) ) )+IIF( lWhoo," -I$(WHOO)\include ","")+ IIF( lMediator," -I$(MEDIATOR)\include ","")+" -o$** $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)\include $(HARBOURFLAGS)" + IIF( lFwh, " -I$(FWH)\include", IIF( lMinigui, " -I$(MINIGUI)\include",IIF( lHwgui, " -I$(HWGUI)\include","" ) )) + " -o$** $**" } ) + ENDIF + + AAdd( s_aCommands, { ".rc.res:", "$(CC_DIR)\BIN\porc $(RFLAGS) $<" } ) + + ENDIF + + + // Selecting PRG files. + + aInFiles := GetSourceFiles( s_lRecursive, s_lGcc, cOS ) + nLenaSrc := Len( aInFiles ) + + IF nLenaSrc == 0 + + IF s_nLang=1 // PT-BR + s_cAlertMsg := "Nenhum prg foi encontrado." + ELSEIF s_nLang=3 // Spanish + s_cAlertMsg := "Ning£n prg foi encontrado." + ELSE + s_cAlertMsg := "No one prg were found." + ENDIF + + lCancelMake := .T. + + Alert( s_cAlertMsg ) + + ENDIF + + + IF "Win32" $ cOS + AEval( aInFiles, { |x,y| aInFiles[y] := Upper( aInFiles[y] ) } ) + ENDIF + + aOutFiles := AClone( aInFiles ) + + //if Len( aOutFiles ) > 1 + if Len( aOutFiles ) > 1 .AND. ! lCreateAndCompile + + Attention( s_aLangMessages[ 41 ], 22 ) + + if s_nLang=1 + s_cAlertMsg := "Selecione os PRGs a compilar" + elseif s_nLang=3 + s_cAlertMsg := "Seleccione los PRG a compilar" + else + s_cAlertMsg := "Select the PRG files to compile" + endif + + + IF nOption !=2 // not create a makefile + pickarry( 11, 15, 20, 64, aInFiles, aOutFiles ,ArrayAJoin( { oMake:aPrgs, oMake:aCs } ), .T., s_cAlertMsg ) + ELSE + pickarry( 11, 15, 20, 64, aInFiles, aOutFiles, {}, .T., s_cAlertMsg ) + ENDIF + + + AEval( aOutFiles, { | x, y | aOutFiles[ y ] := Trim( Substr( aOutFiles[ y ], 1, At( ' ', aOutFiles[ y ] ) ) ) } ) + + aOutFiles := ASort( aOutFiles ) + + @ 22,01 say space(78) + + aSelFiles := GetSelFiles( aInFiles, aOutFiles ) + + ASort( aSelFiles ) + + else + AEval( aOutFiles, { | x, y | aOutFiles[ y ] := Trim( Substr( aOutFiles[ y ], 1, At( ' ', aOutFiles[ y ] ) ) ) } ) + aSelFiles := aOutFiles + endif + + + if Len( aSelFiles ) = 1 + + cTopFile := aSelFiles[1] + cTopFile := PadR( Left(cTopfile,At(Upper(".prg"),Upper(cTopFile))+4 ), 50) + + elseif Len( aSelFiles ) = 0 + + cTopFile := "" + + IF s_nLang=1 // PT + s_cAlertMsg := "Nenhum PRG foi selecionado." + ELSEIF s_nLang=3 + s_cAlertMsg := "Ning£m PRG foi seleccionado." + ELSE + s_cAlertMsg := "No one PRG were selected." + ENDIF + + Alert( s_cAlertMsg ) + + endif + + + WHILE Len( aSelFiles ) > 1 + + IF !lCreateAndCompile + + IF s_nLang=1 // PT + s_cAlertMsg := "Informe o PRG principal da sua aplica‡Æo:" + ELSEIF s_nLang=3 + s_cAlertMsg := "Informe o PRG principale de su aplicacion:" + ELSE + s_cAlertMsg := "Inform the main PRG of your application:" + ENDIF + + @ 15,01 say s_cAlertMsg Get cTopFile pict "@S35" valid !empty(cTopFile) + READ + + if LastKey() = K_ESC + Exit + endif + + ELSE + cTopFile := alltrim(cAppName)+".prg" + ENDIF + + IF "Win32" $ cOS + cTopFile := Upper( cTopFile ) + ENDIF + + + IF ! File( alltrim(cTopFile) ) + + IF s_nLang=1 // PT + s_cAlertMsg := "Arquivo "+alltrim(cTopFile)+" nÆo encontrado."+iif(s_lRecursive," O flag -r est  ativo. Informe o subdir tamb‚m se o PRG principal estiver dentro dele.","") + ELSEIF s_nLang=3 + s_cAlertMsg := "Fichero "+alltrim(cTopFile)+" no encontrado."+iif(s_lRecursive," Lo flag -r esta activado. Informe lo subdir tambi‚n si lo PRG principale est s dentro dele.","") + ELSE + s_cAlertMsg := "File "+alltrim(cTopFile)+" not found."+iif(s_lRecursive," The flag -r is active. Inform the subdir also if the main PRG is within it.","") + ENDIF + + Alert( s_cAlertMsg ) + + IF lCreateAndCompile + FClose( s_nMakeFileHandle ) + FErase( cFile ) + RETURN NIL + ENDIF + + ELSE + EXIT + ENDIF + + END + + + // Selecting External Libs. + IF s_lExternalLib + + aLibs := GetLibs( s_lGcc, cHarbourLibDir ) + + if len(aLibs)=0 + alert("aLibs is empty") + endif + + IF s_nLang == 1 // PT + s_cAlertMsg := ' para selecionar. para continuar o processo.' + ELSEIF s_nLang == 2 + s_cAlertMsg := ' to select. to continue process' + ELSEIF s_nLang == 3 + s_cAlertMsg := ' para seleccionar. para continuar o proceso.' + ENDIF + + Attention( s_cAlertMsg, 22 ) + + AEval( aLibs, { | x | AAdd( aLibsIn, x[ 1 ] ) } ) + AEval( aLibs, { | x | AAdd( aLibsOut, x[ 2 ] ) } ) + + if s_nLang=1 + s_cAlertMsg := "Selecione as LIBs externas a compilar" + elseif s_nLang=3 + s_cAlertMsg := "Seleccione las LIB externas a compilar" + else + s_cAlertMsg := "Select the external LIBs to compile" + endif + + + IF nOption != 2 // not create makefile + pickarry( 11, 15, 20, 64, aLibsIn, aLibsOut ,oMake:aExtLibs, .T. , s_cAlertMsg, .T. ) + ELSE + pickarry( 11, 15, 20, 64, aLibsIn, aLibsOut ,{}, .T., s_cAlertMsg, .T. ) + ENDIF + + ENDIF + +#IFDEF HBM_USE_DEPENDS + + if ! lCreateAndCompile + + clear typeahead + + Attention( "HbMake options", 16 ) + + @ 17, 01 GET lScanIncludes; + CHECKBOX; + CAPTION "Create #DEPENDS from #include"; + STYLE "[X ]" + // Provisions for recursive scanning + @ 17, 40 GET lScanIncRecursive; + CHECKBOX; + CAPTION "Scan recursive" style "[X ]" //when lScanIncludes + @ 18, 01 SAY "Excluding these extensions :" ; + GET cExcludeExts; + WHEN lScanIncludes + READ + + Endif + +#ENDIF + + if ! lCreateAndCompile + + AEval( aOutFiles, { | xItem | IIF( '.c' $ xItem .OR. '.C' $ xItem , AAdd( aOutc, xItem ), ) } ) + AEval( aOutc, { | x, z | cItem := x, z := AScan( aOutFiles, { | t | t = cItem } ), IIF( z > 0, aSize( aDel( aOutFiles, z ), Len( aOutFiles ) - 1 ), ) } ) + + @ 22,01 say space(78) + + aOutFiles := ASort( aOutFiles ) + + else + aOutFiles := { alltrim(cAppName) } + endif + + s_aPrgs := AClone( aOutFiles ) + s_aObjs := AClone( aOutFiles ) + + s_aExtLibs := AClone( aLibsOut ) + + // searching for main prg file into obj array. + x := AScan( s_aObjs, { | x | Lower( x ) $ Lower( alltrim(cTopFile) ) } ) + + // putting main prg in the top + IF x > 0 + ADel( s_aObjs, x ) + ASize( s_aObjs, Len( s_aObjs ) - 1 ) + ASize( s_aObjs, Len( s_aObjs ) + 1 ) + AIns( s_aObjs, 1 ) + s_aObjs[ 1 ] := AllTrim( cTopFile ) + ENDIF + + // searching for main prg file into prg array. + x := AScan( s_aPrgs, { | x | Lower( x ) $ Lower( alltrim(cTopFile) ) } ) + + // putting main prg in the top + IF x > 0 + ADel( s_aPrgs, x ) + ASize( s_aPrgs, Len( s_aPrgs ) - 1 ) + ASize( s_aPrgs, Len( s_aPrgs ) + 1 ) + AIns( s_aPrgs, 1 ) + s_aPrgs[ 1 ] := AllTrim( cTopFile ) + ENDIF + + AEval( s_aObjs, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), IIF( ! s_lGcc, s_aObjs[ x ] := cObjDir + cTest + "." + Exte( cExt, 2 ), s_aObjs[ x ] := cObjDir + cTest + "." + Exte( cExt, 3 ) ) } ) + s_aCFiles := aClone( aOutc ) + + IF ! s_lExtended + AEval( aOutc, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), IIF( ! s_lGcc, AAdd( s_aObjs, cObjDir + cTest + "." + Exten( cExt, 2 ) ), AAdd( s_aObjs, cObjDir + cTest + "." + Exten( cExt, 1 ) ) ) } ) + AEval( aOutFiles, { | xItem | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cExt := Substr( cExt, 2 ), AAdd( s_aCFiles, cObjDir + cTest + "." + Exte( cExt, 1 ) ) } ) + ELSE + s_aObjsC := aClone( aOutc ) + AEval( aOutc, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), IIF( ! s_lGcc, s_aObjsC[ x ] := IIF( ! Empty( cObjDir ), cObjDir, '' ) + cTest + "." + Exten( cExt, 2 ), s_aObjsC[ x ] := IIF( ! Empty( cObjDir ), cObjDir, '' ) + cTest + "." + Exten( cExt, 1 ) ) } ) + ENDIF + + FWrite( s_nMakeFileHandle, "RECURSE=" + IIF( s_lRecursive, " YES ", " NO " ) + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "SHELL = " + CRLF ) + FWrite( s_nMakeFileHandle, "COMPRESS = " + IIF( s_lCompress, "YES", "NO" ) + CRLF ) + FWrite( s_nMakeFileHandle, "EXTERNALLIB = " + IIF( s_lExternalLib, "YES", "NO" ) + CRLF ) + FWrite( s_nMakeFileHandle, "XFWH = " + IIF( s_lxFwh, "YES", "NO" ) + CRLF ) + FWrite( s_nMakeFileHandle, "FILESTOADD = " + Str( s_nFilesToAdd, 2 ) + CRLF ) + FWrite( s_nMakeFileHandle, "WARNINGLEVEL = " + Str(s_nWarningLevel, 2) + CRLF ) + FWrite( s_nMakeFileHandle, "USERDEFINE = " + alltrim(s_cUserDefine) + CRLF ) + FWrite( s_nMakeFileHandle, "USERINCLUDE = " + alltrim(s_cUserInclude) + CRLF ) + FWrite( s_nMakeFileHandle, "USERLIBS = " + alltrim(s_cUserLibs) + CRLF ) + FWrite( s_nMakeFileHandle, "EDITOR = " + s_cEditor + CRLF ) + + IF lFwh + FWrite( s_nMakeFileHandle, "FWH = " + alltrim(cFwhPath) + CRLF ) + ELSEIF lC4W + FWrite( s_nMakeFileHandle, "C4W = " + alltrim(cC4WPath) + CRLF ) + ELSEIF lMiniGui + FWrite( s_nMakeFileHandle, "MINIGUI = " + alltrim(cMiniPath) + CRLF ) + ELSEIF lHwGui + FWrite( s_nMakeFileHandle, "HWGUI = " + if(!s_lMinGW,alltrim(cHwPath),strtran(alltrim(cHwPath),"\","/")) + CRLF ) + ELSEIF lGtwvt + FWrite( s_nMakeFileHandle, "GTWVT = " + CRLF ) + ELSEIF lGtwvw + FWrite( s_nMakeFileHandle, "GTWVW = " + CRLF ) + + IF lMwvw + FWrite( s_nMakeFileHandle, "MWVW = " + CRLF ) + endif + + ELSEIF lXwt + FWrite( s_nMakeFileHandle, "XWT = " + CRLF ) + ELSEIF lWhoo + FWrite( s_nMakeFileHandle, "WHOO = " + CRLF ) + ELSEIF lWhat32 + FWrite( s_nMakeFileHandle, "WHAT32 = " + CRLF ) + ELSEIF lxHGtk + FWrite( s_nMakeFileHandle, "XHGTK = " + CRLF ) + ENDIF + + IF lMediator + FWrite( s_nMakeFileHandle, "MEDIATOR = " + alltrim(cMedPath) + CRLF ) + ENDIF + + IF lApollo + FWrite( s_nMakeFileHandle, "APOLLO = " + alltrim(cApolloPath) + CRLF ) + ENDIF + + FWrite( s_nMakeFileHandle, "GUI = " + iif(lWhoo .or. lFwh .or. lC4W .or. lMinigui .or. lGtWvt .or. lHwGui .or. lXwt .or. lWhat32 .or. lxHGtk .or. lGtWvw , "YES", "NO" ) + CRLF ) + FWrite( s_nMakeFileHandle, "MT = " + IIF( s_lMt, "YES", "NO" ) + CRLF ) + + FOR x := 1 TO Len( s_aMacros ) + + IF ! Empty( s_aMacros[ x, 2 ] ) + + cItem := s_aMacros[ x, 2 ] + nPos := AScan( s_aPrgs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + AEval( s_aPrgs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aPrgs[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ')/', ')\' ) ), ) } ) + + IF ! s_aMacros[ x, 3 ] + FWrite( s_nMakeFileHandle, s_aMacros[ x, 1 ] + ' = ' + Left( s_aMacros[ x, 2 ], Len( s_aMacros[ x, 2 ] ) - 1 ) + " " + CRLF ) + s_aMacros[ x, 3 ] := .T. + ENDIF + + ENDIF + + nPos := AScan( s_aCFiles, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + + IF ! s_aMacros[ x, 3 ] + AEval( s_aCFiles, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aCFiles[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + FWrite( s_nMakeFileHandle, s_aMacros[ x, 1 ] + ' = ' + Left( s_aMacros[ x, 2 ], Len( s_aMacros[ x, 2 ] ) - 1 ) + " " + CRLF ) + s_aMacros[ x, 3 ] := .T. + ENDIF + + ENDIF + + nPos := AScan( s_aObjs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + + IF ! Empty( cObjDir ) + AEval( s_aObjs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aObjs[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + FWrite( s_nMakeFileHandle, s_aMacros[ x, 1 ] + ' = ' + Left( s_aMacros[ x, 2 ], Len( s_aMacros[ x, 2 ] ) - 1 ) + " " + CRLF ) + ENDIF + + ENDIF + + IF s_lExtended + nPos := AScan( s_aObjsC, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + + IF ! Empty( cObjDir ) + AEval( s_aObjsC, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aObjsC[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + ENDIF + + ENDIF + + ENDIF + + ENDIF + + NEXT + + IF s_lGcc + IF ( "linux" $ Lower( Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Linux" ) .or.; + ( "unix" $ Lower( Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Unix" .or. cOS == "HP-UX" ) + FWrite( s_nMakeFileHandle, "PROJECT = " + Alltrim( Lower( cAppName ) ) + " $(PR) " + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, "PROJECT = " + Alltrim( Lower( cAppName ) ) + ".exe" + " $(PR) " + CRLF ) + ENDIF + ELSE + FWrite( s_nMakeFileHandle, "PROJECT = " + Alltrim( Lower( cAppName ) ) + if(s_lasdll,".dll",".exe" ) + " $(PR) " + CRLF ) + ENDIF + + + IF ! s_lExtended + + FWrite( s_nMakeFileHandle, "OBJFILES = " ) + + IF Len( s_aObjs ) < 1 + FWrite( s_nMakeFileHandle, + " $(OB) " + CRLF ) + ELSE + AEval( s_aObjs, { | x, i | IIF( ( i <> Len( s_aObjs ) .AND. x <> alltrim(cTopfile) ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) ), FWrite( s_nMakeFileHandle, " " + " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) + ENDIF + + FWrite( s_nMakeFileHandle, "CFILES =" ) + + IF Len( s_aCFiles ) < 1 + FWrite( s_nMakeFileHandle, + " $(CF)" + CRLF ) + ELSE + AEval( s_aCFiles, { | x, i | IIF( ( i <> Len( s_aCFiles ) .AND. x <> alltrim(cTopfile) ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(CF) " + CRLF ) ) } ) + ENDIF + + FWrite( s_nMakeFileHandle, "PRGFILE =" ) + + IF Len( s_aPrgs ) < 1 + FWrite( s_nMakeFileHandle, + " $(PS)" + CRLF ) + ELSE + AEval( s_aPrgs, { | x, i | IIF( i <> Len( s_aPrgs) .AND. x <> alltrim(cTopfile) , FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) + ENDIF + + ELSE + + FWrite( s_nMakeFileHandle, "OBJFILES =" ) + + IF Len( s_aObjs ) < 1 + FWrite( s_nMakeFileHandle, + " $(OB) " + CRLF ) + ELSE + AEval( s_aObjs, { | x, i | nWriteFiles ++, IIF( ( i <> Len( s_aObjs ) .AND. x <> alltrim(cTopfile) ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % s_nFilestoAdd == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) + ENDIF + + nWriteFiles := 0 + FWrite( s_nMakeFileHandle, "PRGFILES =" ) + + IF Len( s_aPrgs ) < 1 + FWrite( s_nMakeFileHandle, + " $(PS)" + CRLF ) + ELSE + AEval( s_aPrgs, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aPrgs ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % s_nFilestoAdd == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) + ENDIF + + nWriteFiles := 0 + FWrite( s_nMakeFileHandle, "OBJCFILES =" ) + + IF Len( s_aObjsC ) < 1 + FWrite( s_nMakeFileHandle, + " $(OBC) " + CRLF ) + ELSE + AEval( s_aObjsC, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aObjsC ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % s_nFilestoAdd == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(OBC) " + CRLF ) ) } ) + ENDIF + + nWriteFiles := 0 + FWrite( s_nMakeFileHandle, "CFILES =" ) + + IF Len( s_aCFiles ) < 1 + FWrite( s_nMakeFileHandle, + " $(CF)" + CRLF ) + ELSE + AEval( s_aCFiles, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aCFiles ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % s_nFilestoAdd == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) + ENDIF + + + ENDIF + + cResName := Lower( alltrim(cResName) ) + FWrite( s_nMakeFileHandle, "RESFILES = " + cResName + CRLF ) + FWrite( s_nMakeFileHandle, "RESDEPEN = " + StrTran( cResName, ".rc", ".res" ) + CRLF ) + FWrite( s_nMakeFileHandle, "TOPMODULE = " + alltrim(cTopFile) + CRLF ) + + IF lRddads + cDefaultLibs += " rddads.lib ace32.lib" + cDefLibGccLibs += " -lrddads -ladsloc " + cDefaultLibsMt += " rddads.lib ace32.lib" + cDefLibGccLibsMt += " -lrddads -ladsloc " + cDefGccLibsw += " -lrddads -lads32 " + cExtraLibs += " -lrddads -ladsloc " + ENDIF + + // remove obsolete bcc640xx.lib + // + IF "bcc640" $ cDefaultLibs + cDefaultLibs := StrTran( cDefaultLibs, "bcc640.lib", "") + ENDIF + + IF "bcc640" $ cDefaultLibsMt + cDefaultLibsMt := StrTran( cDefaultLibsMt, "bcc640mt.lib", "") + ENDIF + + // if external libs was selected... + IF Len( aLibsOut ) > 0 .AND. s_lExternalLib + + IF s_lMSVcc .OR. s_lBcc .OR. s_lPocc + + IF ! s_lMt + cOldLib := cDefaultLibs + ELSE + cOldLib := cDefaultLibsMt + ENDIF + + // searching for html lib... + nPos := AScan( aLibsOut, { | z | At( "html", Lower( z ) ) > 0 } ) + + IF nPos > 0 + cHtmlLib += aLibsOut[ nPos ] + aDel( aLibsOut, nPos ) + aSize( aLibsOut, Len( aLibsOut ) - 1 ) + cOldLib := StrTran( cOldLib, "gtwin" , "gtcgi" ) + ENDIF + + // searching for mysql lib... + AEval( aLibsOut, { | cLib | cLibs += " " + cLib } ) + nPos := AScan( aLibsOut, { | z | At( "mysql", Lower( z ) ) > 0 } ) + + IF nPos >0 + cLibs += " libmysql.lib" + ENDIF + + // searching for postgre lib... + nPos := AScan( aLibsOut, { | z | At( "hbpg", Lower( z ) ) > 0 } ) + IF nPos >0 + cLibs += " libpq.lib" + cLibs := strtran(cLibs,"hbpg","hbpg") + ENDIF + + IF ! s_lmt + cDefaultLibs := cHtmlLib + " " + cOldLib + " " + cLibs + ELSE + cDefaultLibsMt := cHtmlLib + " " + cOldLib + " " + cLibs + ENDIF + + ENDIF + + IF s_lGcc + + nPos := AScan( aLibsOut, { | z | At( "html", Lower( z ) ) > 0 } ) + + IF nPos > 0 + cHtmlLib += "-l" + Strtran( aLibsOut[ nPos ], '.a', "" ) + aDel( aLibsOut, nPos ) + aSize( aLibsOut, Len( aLibsOut ) - 1 ) + ENDIF + + AEval( aLibsOut, { | cLib | iif( Len(aTempLibs :=ListAsArray2( cLib, " ") )> 0 ,cLibs += SetthisLibs(AtempLibs) ,cLibs += " -l" + Strtran( cLib, '.a', "" ))} ) + + nPos := AScan( aLibsOut, { | z | At( "mysql", Lower( z ) ) > 0 } ) + + if nPos >0 + cLibs += " -lmysqlclient" + endif + nPos := AScan( aLibsOut, { | z | At( "hbpg", Lower( z ) ) > 0 } ) + + if nPos >0 + cLibs += " -lpq" + endif + + cExtraLibs := cLibs + + IF cOS == "Linux" + + IF ! s_lMt + cOldLib := " " + cDefLibGccLibs + cDefLibGccLibs := cHtmlLib + " " + cOldLib + " " + cLibs + + IF "html" $ cDefLibGccLibs + cDefLibGccLibs := StrTran( cDefLibGccLibs, "gtcrs" , "gtcgi" ) + cDefLibGccLibs := StrTran( cDefLibGccLibs, "ncurses" , "" ) + ENDIF + + ELSE + + cOldLib := " " + cDefLibGccLibsMt + cDefLibGccLibsMt := cHtmlLib + " " + cOldLib + " " + cLibs + + IF "html" $ cDefLibGccLibsMt + cDefLibGccLibsMt := StrTran( cDefLibGccLibsMt, "gtcrs" , "gtcgi" ) + cDefLibGccLibsMt := StrTran( cDefLibGccLibsMt, "ncurses" , "" ) + ENDIF + + ENDIF + + ELSEIF cOS == "OS/2" + + IF ! s_lMt + cOldLib := " " + cGccLibsOs2 + cGccLibsOs2 := cHtmlLib + " " + cOldLib + " " + cLibs + + IF "html" $ cGccLibsOs2 + cGccLibsOs2 := StrTran( cGccLibsOs2, "gtos2" , "gtcgi" ) + ENDIF + + ELSE + cOldLib := " " + cGccLibsOs2Mt + cGccLibsOs2Mt := cHtmlLib + " " + cOldLib + " " + cLibs + IF "html" $ cGccLibsOs2Mt + cGccLibsOs2Mt := StrTran( cGccLibsOs2Mt, "gtos2" , "gtcgi" ) + ENDIF + + ENDIF + + ELSE + + IF s_lMt + cOldLib := " " + cDefGccLibsMt + cDefGccLibsMt := cHtmlLib + " " + cOldLib + " " + cLibs + else + cOldLib := " " + cDefGccLibsw + cDefGccLibsw := cHtmlLib + " " + cOldLib + " " + cLibs + endif + + + ENDIF + + ENDIF + + ENDIF + + + IF s_lBcc .OR. s_lMSVcc .OR. s_lPocc + if lFwh .or. lMiniGui .or. lC4W .or. lWhoo .or. lHwGui .or. lWhat32 + cDefaultLibs := strtran(cDefaultLibs,"gtwin.lib","gtgui.lib gtnul.lib") + cDefaultLibsMt := strtran(cDefaultLibsMt,"gtwin.lib","gtgui.lib gtnul.lib") + endif + + IF lFwh + IF s_lxFwh + FWrite( s_nMakeFileHandle, "LIBFILES = $(FWH)\lib\fivehx.lib $(FWH)\lib\fivehc.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, "LIBFILES = $(FWH)\lib\fiveh.lib $(FWH)\lib\fivehc.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ENDIF + ELSEIF lMiniGui + FWrite( s_nMakeFileHandle, "LIBFILES = minigui.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ELSEIF lWhoo + FWrite( s_nMakeFileHandle, "LIBFILES = whoo.lib what32.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ELSEIF lWhat32 + FWrite( s_nMakeFileHandle, "LIBFILES = what32.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ELSEIF lHwGui + FWrite( s_nMakeFileHandle, "LIBFILES = hwgui.lib procmisc.lib hwg_qhtm.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ELSEIF lC4W + FWrite( s_nMakeFileHandle, "LIBFILES = $(C4W)\c4wclass.lib $(C4W)\wbrowset.lib $(C4W)\otabt.lib $(C4W)\clip4win.lib " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ELSE + if lGtwvt + cDefaultLibs := strtran(cDefaultLibs,"gtwin.lib","gtwvt.lib wvtgui.lib") + cDefaultLibsMt := strtran(cDefaultLibsMt,"gtwin.lib","gtwvt.lib wvtgui.lib") + elseif lGtwvw + cDefaultLibs := if(lMWvW,'mwvw.lib ', '') + strtran(cDefaultLibs,"gtwin.lib","gtwvw.lib ") + cDefaultLibsMt := if(lMWvW,'mwvw.lib ', '') + strtran(cDefaultLibsMt,"gtwin.lib","gtwvw.lib ") + + endif + + FWrite( s_nMakeFileHandle, "LIBFILES = " + IIF( ! s_lMt, cDefaultLibs, cDefaultLibsMt ) + CRLF ) + ENDIF + + ELSEIF s_lGcc + + IF cOS == "Linux" + FWrite( s_nMakeFileHandle, "LIBFILES = " + IIF(lusexhb, cExtraLibs , "-Wl,--start-group " + IIF( ! s_lMt, cDefLibGccLibs, cDefLibGccLibsMt ) + " -Wl,--end-group " + cSystemLibs ) + CRLF ) + ELSEIF cOS == "Unix" .or. cOS == "UP-UX" + FWrite( s_nMakeFileHandle, "LIBFILES = " + IIF(lusexhb, cExtraLibs , " " + IIF( ! s_lMt, cDefGccLibsUnix, cDefGccLibsUnixmt ) + " " + cSystemLibs ) + CRLF ) + ELSEIF cOS == "OS/2" + FWrite( s_nMakeFileHandle, "LIBFILES = " + IIF( ! s_lMt, cGccLibsOs2, cGccLibsOs2Mt ) + CRLF ) + ELSEIF "MINGW" $ cCompiler + IF lHwGui + cDefGccLibsw :=strtran( cDefGccLibsw,"-lgtwin" ,"-lgtgui") + cDefGccLibsMtw :=strtran( cDefGccLibsMtw,"-lgtwin" ,"-lgtgui") + FWrite( s_nMakeFileHandle, "LIBFILES = " + "-Wl,--allow-multiple-definition -Wl,--start-group " + "-lhwgui -lprocmisc -lhwg_qhtm " + IIF( ! s_lMt, cDefGccLibsw, cDefGccLibsMtw ) + " -Wl,--end-group " + CRLF) + else + FWrite( s_nMakeFileHandle, "LIBFILES = " + "-Wl,--allow-multiple-definition -Wl,--start-group " + IIF( ! s_lMt, cDefGccLibsw, cDefGccLibsMtw ) + " -Wl,--end-group " + CRLF ) + endif + ELSE + FWrite( s_nMakeFileHandle, "LIBFILES = " + IIF( ! s_lMt, cDefGccLibs, cDefGccLibs ) + CRLF ) + ENDIF + + ENDIF + + nWriteFiles := 0 + FWrite( s_nMakeFileHandle, "EXTLIBFILES =" ) + + if Len(s_aExtLibs) < 1 + FWrite( s_nMakeFileHandle, CRLF ) + else + AEval( s_aExtLibs, { | x, i | nWriteFiles ++, FWrite( s_nMakeFileHandle, " " + Alltrim( x ) ) } ) + FWrite( s_nMakeFileHandle, CRLF ) + endif + + FWrite( s_nMakeFileHandle, "DEFFILE = " + CRLF ) + FWrite( s_nMakeFileHandle, "HARBOURFLAGS = " + cHarbourFlags + CRLF ) + + + IF s_lBcc + + FWrite( s_nMakeFileHandle, "CFLAG1 = -OS $(SHELL) $(CFLAGS) -d -c -L$(HB_DIR)\lib"+iif(lFwh,";$(FWH)\lib ","")+iif(!empty(s_cUserInclude)," -I" + alltrim( s_cUserInclude ),"") + " " +CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = -I$(HB_DIR)\include;$(CC_DIR)\include" + iif( s_lMt, " -DHB_THREAD_SUPPORT " , "" ) + CRLF ) + + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) +/* added "-x" flag to LFLAGS statment to suppress creation of map file and speed up link. */ + FWrite( s_nMakeFileHandle, "LFLAGS = -L$(CC_DIR)\lib\obj;$(CC_DIR)\lib;$(HB_DIR)\lib -Gn -M -m -s -Tp"+ if(s_lasdll,"d","e") + " -x" + IIF( lFWH .or. lMiniGui .or. lWhoo .or. lHwgui .or. lGtWvt .or. lGtWvw ," -aa"," -ap") + IIF( lMinigui, " -L$(MINIGUI)\lib",IIF( lFwh, " -L$(FWH)\lib",IIF( lHwgui, " -L$(HWGUI)\lib","" ))) + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = ilink32" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = " + IIF( ( lWhoo .OR. lWhat32 .OR. lFwh .OR. lMinigui .OR. lHwgui .or. lGtWvt .or. lGtWvw .or. lXwt .or. lxHGtk ), "c0w32.obj", if(s_lAsDll,"c0d32.obj","c0x32.obj" )) + " $(OBJFILES)" + IIF( s_lExtended, " $(OBJCFILES)", " " ) + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = $(USERLIBS) $(LIBFILES) import32.lib " + IIF( s_lMt,"cw32mt.lib", "cw32.lib" )+ CRLF ) + FWrite( s_nMakeFileHandle, ".autodepend" + CRLF ) + + ELSEIF s_lMSVcc + + FWrite( s_nMakeFileHandle, "CFLAG1 = -I$(INCLUDE_DIR) -TP -W3 -nologo $(C_USR) $(SHELL) $(CFLAGS)" +IIF( s_lMt, " -DHB_THREAD_SUPPORT " , "" ) + CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = -c" +" -I" + alltrim( s_cUserInclude ) + " " + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = /LIBPATH:$(CC_DIR)\lib /LIBPATH1:$(HB_DIR)\lib /LIBPATH2:$(C4W)\lib" +IIF(s_lMt, " /Nodefaultlib:LIBC "," /Nodefaultlib:LIBCMT " ) + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = link" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = " + IIF( lC4W, "$(C4W)\initc.obj", "" ) + "$(OBJFILES)" + IIF( s_lExtended, " $(OBJCFILES)", " " ) + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = $(USERLIBS) $(LIBFILES) kernel32.lib user32.lib gdi32.lib winspool.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mpr.lib vfw32.lib winmm.lib " + CRLF ) + + ELSEIF s_lPocc + + FWrite( s_nMakeFileHandle, "CFLAG1 = $(SHELL) /Ze /Go /Ot /Tx86-coff /I$(INCLUDE_DIR) $(C_USR) $(CFLAGS)" +IIF( s_lMt, ' /D"HB_THREAD_SUPPORT" /MT' , "" ) + CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = " + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = /LIBPATH:$(CC_DIR)\LIB /LIBPATH:$(CC_DIR)\LIB\WIN /LIBPATH:$(HB_DIR)\LIB /MACHINE:IX86"+IIF(!s_lGui," /SUBSYSTEM:CONSOLE"," /SUBSYSTEM:WINDOWS") + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = polink" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = " + IIF( lC4W, "$(C4W)\initc.obj", "" ) + "$(OBJFILES)" + IIF( s_lExtended, " $(OBJCFILES)", " " ) + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = $(USERLIBS) $(LIBFILES) "+IIF(s_lMT,"crtmt.lib","crt.lib") + " kernel32.lib user32.lib gdi32.lib winspool.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mpr.lib winmm.lib wsock32.lib" + CRLF ) + + ELSEIF s_lGcc + + FWrite( s_nMakeFileHandle, "CFLAG1 = $(SHELL) " +IIF( !EMPTY(s_cUserInclude ) ," -I" + Alltrim( s_cUserInclude ) ,"") + IIF( "Unix" $ cOs , " -I/usr/include/harbour ", "" ) + IIF( "Linux" $ cOS, "-I/usr/include/harbour", " -I$(HB_DIR)/include" ) + " -c -Wall" + IIF( s_lMt, " -DHB_THREAD_SUPPORT " , "" ) + if(s_lmingw, " -mno-cygwin "," " )+ CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = " + IIF( "Linux" $ cOS, "-L$(HB_LIB_INSTALL)", " -L$(HB_DIR)/lib -L$(CC_DIR)/lib" ) + IIF( "Unix" $ cOs , " -L/usr/lib/harbour ", "" ) + IIF( lHwgui, " -L$(HWGUI)\lib","" ) + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = " + if(!s_lLinux," ","-Wl,--noinhibit-exec ") + IIF(lUseXhb ,IIF(lUseharbourDll,"","-static ") + if(lXwt .or. lhwgui ,"-gtcgi " , "-gtcrs "), "$(CFLAG2)") + iif(lXwt,"`pkg-config --libs gtk+-2.0` -lxwt -lxwt_gtk -lxwt","") + iif( lxHGtk, "`pkg-config --libs gtk+-2.0 libglade-2.0` -lxhgtk ","") + iif( lhwgui .and. !s_lMinGW, " `pkg-config --libs gtk+-2.0 libglade-2.0 libgnomeprint-2.2` -hwgui ","") + iif(lhwgui .and. s_lMinGW," -mwindows " ,"" )+ iif(s_lLinux .and. s_lmt ," -mt "," " ) +CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = "+ IIF(lusexhb,"hblnk","gcc") + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = $(OBJFILES) " + IIF( s_lExtended, " $(OBJCFILES)", " " ) + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN) " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = $(USERLIBS) $(LIBFILES) " +if(s_lMinGW," -luser32 -lwinspool -lgdi32 -lcomctl32 -lcomdlg32 -lole32 -loleaut32 -luuid -lmpr -lwsock32 -lws2_32 -lmapi32","") + CRLF ) + FWrite( s_nMakeFileHandle, ".autodepend" + CRLF ) + + ENDIF + +#IFdef HBM_USE_DEPENDS + + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "#DEPENDS" + CRLF ) + + IF lScanIncludes + // Clipper/(x)Harbour sources: .prg + IF Len( s_aPrgs ) = Len( s_aObjs ) + Attention("Scanning .PRG sources...",19) + FOR nPos := 1 to Len(s_aPrgs) + cIncl := ScanInclude( ReplaceMacros( s_aPrgs[ nPos ] ), lScanIncRecursive, cExcludeExts ) + // Only add in list if dependencies exist + IF ! Empty(cIncl) + FWrite( s_nMakeFileHandle, s_aObjs[ nPos ] + ': ' + Alltrim( cIncl ) + CRLF, "" ) + ENDIF + NEXT + ENDIF + + // C-sources: .c + IF Len( s_aCFiles ) = Len( s_aObjsC ) + Attention("Scanning .C sources...",19) + FOR nPos := 1 to Len(s_aCFiles) + cIncl := ScanInclude( s_aCFiles[ nPos ], lScanIncRecursive, cExcludeExts ) + // Only add in list if dependencies exist + IF ! Empty(cIncl) + FWrite( s_nMakeFileHandle, s_aObjsC[ nPos ] + ': ' + Alltrim( cIncl ) + CRLF, "" ) + ENDIF + NEXT + ENDIF + + // Cleanup message + @ 19, 1 say Space(MaxCol() - 2) + ENDIF + +#ENDIF + + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "#COMMANDS" + CRLF ) + + AEval( s_aCommands, { | xItem | FWrite( s_nMakeFileHandle, xitem[ 1 ] + CRLF ), FWrite( s_nMakeFileHandle, xitem[ 2 ] + CRLF ), FWrite( s_nMakeFileHandle, " " + CRLF ) } ) + + IF s_lBcc .OR. s_lMSVcc .OR. s_lPocc + + FWrite( s_nMakeFileHandle, "#BUILD" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "$(PROJECT): $(CFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)" + CRLF ) + FWrite( s_nMakeFileHandle, " $(CC_DIR)\BIN\$(LINKER) @&&! " + CRLF ) + FWrite( s_nMakeFileHandle, " $(LFLAGS) +" + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLOBJ), +" + CRLF ) + FWrite( s_nMakeFileHandle, " $(PROJECT),, +" + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLLIB), +" + CRLF ) + FWrite( s_nMakeFileHandle, " $(DEFFILE), +" + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLRES) " + CRLF ) + FWrite( s_nMakeFileHandle, "!" + CRLF ) + + ELSEIF s_lGcc + + FWrite( s_nMakeFileHandle, "#BUILD" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "$(PROJECT): $(CFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)" + CRLF ) + + IF 'Linux' $ cOS + FWrite( s_nMakeFileHandle, " $(LINKER) @&&!" + CRLF ) + ELSEIF 'Unix' $ cOS .or. "HP-UX" $ cOS + FWrite( s_nMakeFileHandle, " $(LINKER) @&&!" + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, " $(CC_DIR)\bin\$(LINKER) @&&!" + CRLF ) + ENDIF + + FWrite( s_nMakeFileHandle, " $(PROJECT) " + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLOBJ) " + CRLF ) + FWrite( s_nMakeFileHandle, " $(LFLAGS) " + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLLIB) " + CRLF ) + FWrite( s_nMakeFileHandle, "!" + CRLF ) + + ENDIF + + FClose( s_nMakeFileHandle ) + + IF !lCancelMake + + IF s_nLang == 1 .OR. s_nLang == 3 + s_cAlertMsg := "Compilar app ? (S/N) " + ELSE // English + s_cAlertMsg := "Build app ? (Y/N) " + ENDIF + + if ! lCreateAndCompile + + @ 20,5 SAY s_cAlertMsg; + GET cBuild; + PICT "!"; + VALID cBuild $ iif(s_nLang=2,"YN","SN") + READ + + else + cBuild := "Y" + endif + + IF ( cBuild == "S" .or. cBuild == "Y" ) + + IF lNew .OR. Len(aSelFiles)=1 + cBuildForced := "Y" + ELSE + + IF s_nLang == 1 + s_cAlertMsg := "For‡ar recompila‡Æo para todos PRGs ? (S/N) " + ELSEIF s_nLang == 3 // Spanish + s_cAlertMsg := "Forzar recompilaci¢n para todos los PRGs ? (S/N) " + ELSE // English + s_cAlertMsg := "Force recompiling for all PRGs ? (Y/N) " + ENDIF + + @ 21,5 SAY s_cAlertMsg; + GET cBuildForced; + PICT "!"; + VALID cBuildForced $ iif(s_nLang=2,"YN","SN") + READ + + ENDIF + + IF cBuildForced == "S" .or. cBuildForced == "Y" + cBuildParam := " -f " + iif(s_nLang=1,"-lPT",iif(s_nLang=3,"-lES","-lEN")) + ENDIF + + ENDIF + + + IF cBuild == "S" .OR. cBuild == "Y" + ResetInternalVars() + SetColor("W/N,N/W") + Clear + SetPos(9,0) +// Main( cFile, " -f "+iif(s_nLang=1,"-lPT",iif(s_nLang=3,"-lES","-lEN")) ) + if cBuildParam != NIL + Main( cFile, cBuildParam ) + else + Main( cFile ) + endif + ELSE + set cursor on + setcolor("W/N,N/W") + clear + ENDIF + + ELSE + set cursor on + setcolor("W/N,N/W") + clear + ENDIF + +RETURN NIL + +#IfDef HBM_USE_DEPENDS + +*------------------------------------------------------------ +FUNCTION ScanInclude( cFile, lRecursive, cExclExtent, aFiles) +*------------------------------------------------------------ +// Search for #Include & Set Procedure To & Set Proc To + + LOCAL cFileList := "" + LOCAL nHandle := -1 + LOCAL lEof := .F. + LOCAL cTemp := "" + LOCAL cBuffer := "" + LOCAL aQuotes := {{'"','"'},{"'","'"},{"[","]"},{"<",">"}} + LOCAL cQuote := "" + LOCAL cQuoteA := "" + LOCAL cInclude := "" + LOCAL lPrg := .F. + Local lC := .F. + LOCAL lCh := .F. + LOCAL cPath := "" + LOCAL cFnam := "" + LOCAL cExt := "" + LOCAL cDrive := "" + LOCAL cContinue := "" + + DEFAULT lRecursive TO .F. + DEFAULT cExclExtent TO "" // specify extensions to exclude like ".ch.def" etc., including the dot + DEFAULT aFiles TO {} + + IF File(cFile) + + HB_FNAMESPLIT( cFile, @cPath, @cFnam, @cExt, @cDrive ) + + lPrg := (Lower(cExt) == ".prg") + lC := (Lower(cExt) == ".c") + lCh := (Lower(cExt) == ".ch") + cContinue := IIF(lPrg,";",IIF(lC,"\","")) + + nHandle := FOpen(cFile) + + IF nHandle != F_ERROR + + // Provisions for recursive scanning + // Add current file to list, making it by default the first in the list + + IF s_lWin32 + IF AScan(aFiles, {| x | Lower( x ) == Lower( cFnam + cExt ) } ) = 0 // Case IN-sensitive! + AAdd(aFiles, cFnam + cExt) + ENDIF + ELSE + IF AScan(aFiles, cFnam + cExt ) = 0 // Case Sensitive! + AAdd(aFiles, cFnam + cExt) + ENDIF + ENDIF + + lEof := (HB_FReadLine(nHandle,@cTemp,{chr(13)+chr(10), chr(10)}) = -1) + cTemp := LTrim( cTemp ) + // Loop reading file + WHILE !lEof + IF lPrg .OR. lC // Check for line-continuation + WHILE Right(cTemp, 1 ) == cContinue + + cTemp := Left( cTemp , Len( cTemp ) - 1) + IF !lEof + lEof := (HB_FReadLine(nHandle,@cBuffer,{chr(13)+chr(10), chr(10)}) = -1) + cTemp += LTrim( cBuffer) + ENDIF + + ENDDO + ENDIF + // Dependencies + IF Upper(Left( cTemp ,8)) == "#INCLUDE" + cTemp := AllTrim(SubStr( cTemp, 9)) + Else + IF lPrg .and. Upper(Left( cTemp, 16)) == "SET PROCEDURE TO" + cTemp := AllTrim(SubStr( cTemp, 17)) + ELSE + IF lPrg .and. Upper(Left( cTemp, 11)) == "SET PROC TO" // Alternative + cTemp := AllTrim(SubStr( cTemp, 12)) + ELSE + cTemp := "" + ENDIF + ENDIF + Endif + // Something Ok? + IF Len(cTemp) > 0 + cQuote := Left( cTemp, 1) + cQuoteA := "" + AEval(aQuotes,{| x |Iif(x[1] == cQuote,cQuoteA := x[2],)}) // Determine closing quote + IF cQuoteA == "" + cInclude := AllTrim(Left(cTemp, At(" ", cTemp + " ") - 1)) // Handle set procedure to, not using quotes + ELSE + cTemp := SubStr(cTemp, 2) + cInclude := AllTrim(Left(cTemp, At(cQuoteA, cTemp) - 1)) // Find closing quote + ENDIF + IF Len(cInclude) > 0 .and. Len(Alltrim(cExclExtent)) > 0 + HB_FNAMESPLIT( cInclude, @cPath, @cFnam, @cExt, @cDrive ) + IF lPrg .AND. Len(cExt) = 0 + cInclude := cInclude + ".prg" // Handle set procedure to, using default extension + ENDIF + IF AT(Lower(cExt), Lower(cExclExtent)) > 0 + cInclude := "" + ENDIF + ENDIF + IF Len(cInclude) > 0 + // Still Ok, add to list? + IF s_lWin32 + IF AScan(aFiles, {| x | Lower( x ) == Lower( cInclude ) } ) = 0 // Case IN-sensitive! + AAdd(aFiles, (cInclude) ) + // recursive scanning + IF lRecursive + ScanInclude(FileInIncludePath(cInclude), lRecursive, cExclExtent, aFiles ) + ENDIF + ENDIF + ELSE + IF AScan(aFiles, cInclude ) = 0 // Case Sensitive! + AAdd(aFiles, (cInclude) ) + // recursive scanning + IF lRecursive + ScanInclude(FileInIncludePath(cInclude), lRecursive, cExclExtent, aFiles ) + ENDIF + ENDIF + ENDIF + ENDIF + ENDIF + IF !lEof + lEof := (HB_FReadLine(nHandle,@cTemp,{chr(13)+chr(10), chr(10)}) = -1) + cTemp := LTrim( cTemp) + ENDIF + ENDDO + + FClose( nHandle ) + ENDIF + + ENDIF + // Return results, a space-separated list of filenames, unsorted + IF Len(aFiles) > 1 // Skip generation of list if only main source (1) was added, caller knows what to do + AEval(aFiles,{| x | cFileList := cFileList + " " + x } ) + ENDIF + +RETURN cFileList +#Endif + +*----------------------------- +FUNCTION CompileUpdatedFiles() +*----------------------------- + + LOCAL cComm + LOCAL cOld + LOCAL nPos + LOCAL nCount + + LOCAL aCtocompile := {} + LOCAL aOrder := ListAsArray2( s_aBuildOrder[ 2 ], " " ) + LOCAL lEnd + LOCAL cErrText := "" + LOCAL xItem + LOCAL nObjPos + LOCAL cOrder := "" + LOCAL cPrg := "" + LOCAL nFiles + LOCAL nFile := 1 + LOCAL lNewer := .F. +#IfDef HBM_USE_DEPENDS + LOCAL nPos1 := 0 + LOCAL cDepSrc := "" +#Endif + LOCAL aGauge := GaugeNew( 5, 5, 7, 40, "W/B", "W+/B", '²' ) + + @ 4,5 SAY "Compiling :" + + FOR EACH cOrder in aOrder + IF ! s_lExtended + + IF cOrder == "$(CFILES)" + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".prg.c:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + FOR nFiles := 1 TO Len( s_aPrgs ) + xItem := Substr( s_aPrgs[ nFiles ], Rat( IIF( s_lGcc, '/', '\' ), s_aPrgs[ nFiles ] ) + 1 ) + nPos := AScan( s_aCFiles, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) + nObjPos := AScan( s_aObjs, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xItem, At( ".", xItem ) ) } ) + +#IfDef HBM_USE_DEPENDS + lNewer := .F. + nPos1 := AScan( s_aDepends, { | x |lower(x[1]) == lower( s_aObjs[ npos ] )}) + IF nPos1 > 0 + FOR EACH cDepSrc in s_aDepends[ nPos1 , 2 ] + lNewer := lNewer .OR. Fileisnewer( cDepSrc, s_aObjs[ npos ], .T. ) + NEXT + ENDIF +#Endif + + IF lNewer .or. FileIsNewer( s_aPrgs[ nFiles ], s_aObjs[ nObjPos ] ) + + IF nPos > 0 + AAdd( aCtocompile, s_aCFiles[ nPos ] ) + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + s_aCFiles[ nPos ] ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + s_aCFiles[ nPos ] ) + ENDIF + cComm := Strtran( cComm, "$**", s_aPrgs[ nFiles ] ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + + //Outstd( cComm ) + //Outstd( CRLF ) + setpos(9,0) + __RUN( (cComm) ) + cErrText := Memoread( (s_cLog) ) + lEnd := 'C2006' $ cErrText .OR. 'No code generated' $ cErrText + + IF ! s_lIgnoreErrors .AND. lEnd + __run( s_cEditor +" "+ (s_cLog) ) + set cursor on + QUIT + ELSE + // FErase( s_cLog ) + ENDIF + + cComm := cOld + + ENDIF + + ENDIF + + NEXT + + ENDIF + + IF cOrder == "$(OBJFILES)" + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.o:" .OR. x[ 1 ] == ".cpp.o:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.obj:" .OR. x[ 1 ] == ".cpp.obj:" } ) + ENDIF + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + IF Len( aCtoCompile ) >= 1 + + FOR nFiles := 1 TO Len( s_aCFiles ) + nPos := AScan( s_aCFiles, { | x | Left( x, At( ".", x ) ) == Left( aCtoCompile[ nfiles ], At( ".", aCtoCompile[ nfiles ] ) ) } ) + + IF nPos == 0 + AAdd( aCtoCompile, s_aCFiles[ nFiles ] ) + ENDIF + + NEXT + + ENDIF + + FOR nFiles := 1 TO Len( aCtocompile ) + xItem := Substr( aCtocompile[ nFiles ], Rat( IIF( s_lGcc, '/', '\' ), aCtocompile[ nFiles ] ) + 1 ) + nPos := AScan( s_aObjs, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( aCtocompile[ nFiles ], At( ".", xItem ) ) } ) + + IF nPos > 0 + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + s_aObjs[ nPos ] ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + s_aObjs[ nPos ] ) + ENDIF + cComm := Strtran( cComm, "$**", aCtocompile[ nFiles ] ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + Outstd( " " ) + + Outstd( cComm ) + Outstd( CRLF ) + setpos(9,0) + __RUN( (cComm) ) + cComm := cOld + ENDIF + + NEXT + + ENDIF + + ELSE /**************Extended mode ******/ //// + + IF cOrder == "$(CFILES)" + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".c.obj:" .OR. x[ 1 ] == ".cpp.obj:" .or. x[ 1 ] == ".cpp.o:" .or. x[ 1 ] == ".c.o:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".C.OBJ:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + ENDIF + + GaugeDisplay( aGauge ) + + FOR nFiles := 1 TO Len( s_aCFiles ) + @ 4, 16 SAY Space( 50 ) + xItem := Substr( s_aCFiles[ nFiles ], Rat( IIF( s_lGcc, '/', '\' ), s_aCFiles[ nFiles ] ) + 1 ) + nPos := AScan( s_aObjsC, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xitem, At( ".", xitem ) ) } ) + +#IfDef HBM_USE_DEPENDS + lNewer := .F. + nPos1 := AScan( s_aDepends, { | x |lower(x[1]) == lower( s_aObjs[ npos ] )}) + IF nPos1 > 0 + FOR EACH cDepSrc in s_aDepends[ nPos1 , 2 ] + lNewer := lNewer .OR. Fileisnewer( cDepSrc, s_aObjs[ npos ], .T. ) + NEXT + ENDIF +#Endif + IF lNewer .or. Fileisnewer( s_aCFiles[ nFiles ], s_aObjsC[ nPos ] ) + + IF nPos > 0 + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + s_aObjsC[ nPos ] ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + s_aObjsC[ nPos ] ) + ENDIF + cComm := Strtran( cComm, "$**", s_aCFiles[ nFiles ] ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + @4,16 SAY s_aCFiles[ nFiles ] + GaugeUpdate( aGauge, nFile / Len( s_aCFiles ) ) // changed s_aPrgs to s_aCFiles Ath 2004-06-08 + nFile ++ + //Outstd( cComm ) + //Outstd( CRLF ) + setpos(9,0) + __RUN( (cComm) ) + cErrText := Memoread( (s_cLog) ) + lEnd := 'Error E' $ cErrText + + IF ! s_lIgnoreErrors .AND. lEnd + __run( s_cEditor +" "+ (s_cLog) ) + set cursor on + QUIT + ELSE + // FErase( s_cLog ) + ENDIF + + cComm := cOld + + ENDIF + + ENDIF + + NEXT + //nFile++ + ENDIF + + GaugeDisplay( aGauge ) + + IF cOrder == "$(OBJFILES)" + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".prg.o:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".prg.obj:" } ) + ENDIF + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ELSE + + IF s_lGcc + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".PRG.O:" } ) + ELSE + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".PRG.OBJ:" } ) + ENDIF + + ENDIF + + nFile := 1 + + FOR EACH cPrg IN s_aPrgs + @ 4, 16 SAY Space( 50 ) + xItem := Substr( cPrg, Rat( IIF( s_lGcc, '/', '\' ), cPrg ) + 1 ) + nPos := AScan( s_aObjs, { | x | x := Substr( x, Rat( IIF( s_lGcc, '/', '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xItem, At( ".", xitem ) ) } ) + +#IfDef HBM_USE_DEPENDS + lNewer := .F. + nPos1 := AScan( s_aDepends, { | x |lower(x[1]) == lower( s_aObjs[ npos ] )}) + IF nPos1 > 0 + FOR EACH cDepSrc in s_aDepends[ nPos1 , 2 ] + lNewer := lNewer .OR. Fileisnewer( cDepSrc, s_aObjs[ npos ], .T. ) + NEXT + ENDIF +#Endif + + IF !empty( cPrg ) .AND. (lNewer .OR. Fileisnewer( cPrg, s_aObjs[ npos ] )) + + IF nPos > 0 + IF s_lMSVcc //.OR. s_lPocc + cComm := Strtran( cComm, "-Fo$*", "-Fo" + s_aObjs[ nPos ] ) + ELSE + cComm := Strtran( cComm, "o$*", "o" + s_aObjs[ nPos ] ) + ENDIF + cComm := Strtran( cComm, "$**", cPrg ) + cComm += IIF( s_lLinux , " > "+ (s_cLog)," >>"+ (s_cLog)) + @4,16 SAY cPrg + GaugeUpdate( aGauge, nFile / Len( s_aPrgs ) ) + nFile ++ // moved from outside 'FOR EACH', Ath 2004-06-08 + + setpos(9,0) + __RUN( (cComm) ) + cErrText := Memoread( (s_cLog) ) + lEnd := 'C2006' $ cErrText .OR. 'No code generated' $ cErrText .or. "Error E" $ cErrText .or. "Error F" $ cErrText + + IF ! s_lIgnoreErrors .AND. lEnd + __run( s_cEditor +" "+ (s_cLog) ) + set cursor on + QUIT + ELSE + // FErase( s_cLog ) + ENDIF + + cComm := cOld + + ENDIF + + ENDIF + + NEXT + + // nFile ++ // removed, useless, Ath 2004-06-08 + + ENDIF + + ENDIF + + IF cOrder == "$(RESDEPEN)" + nPos := AScan( s_aCommands, { | x | x[ 1 ] == ".rc.res:" } ) + + IF nPos > 0 + cComm := s_aCommands[ nPos, 2 ] + cOld := cComm + ENDIF + + FOR nFiles := 1 TO Len( s_aResources ) + + IF ! Empty( s_aResources[ nFiles ] ) + cComm := Strtran( cComm, "$<", s_aResources[ nFiles ] ) + outstd( " " ) + setpos(9,0) + __RUN( (cComm) ) + ENDIF + + cComm := cOld + + NEXT + + ENDIF + + NEXT + +RETURN NIL + +*------------------------------------------ +FUNCTION FileIsNewer( cFile, as, lInclude ) +*------------------------------------------ + + LOCAL nCount := 0 + LOCAL cSrcPath := "" + + DEFAULT lInclude TO .F. + + // Check all paths in INCLUDE environment variable, if requested + IF lInclude + cFile := FileInIncludePath(cFile) + ENDIF + + IF ! s_lExtended + + FOR nCount := 1 TO Len( s_aPrgs ) + s_aDir := { cFile,, Hbmake_Filedate( cFile ), hbmake_filetime( cFile ), ; + as[ nCount ], Hbmake_Filedate( as[ nCount ] ), hbmake_filetime( as[ nCount ] ) } + + IF Empty( s_aDir[ 7 ] ) + s_aDir[ 2 ] := .T. + ELSE + s_aDir[ 2 ] := td2jul( s_aDir[ 4 ], s_aDir[ 3 ] ) > td2jul( s_aDir[ 7 ], s_aDir[ 6 ] ) + ENDIF + + NEXT + + ELSE + s_aDir := { cFile,, Hbmake_Filedate( cFile ), hbmake_filetime( cFile ), ; + as, Hbmake_Filedate( as ), hbmake_filetime( as ) } + + IF Empty( s_aDir[ 7 ] ) + s_aDir[ 2 ] := .T. + ELSE + s_aDir[ 2 ] := td2jul( s_aDir[ 4 ], s_aDir[ 3 ] ) > td2jul( s_aDir[ 7 ], s_aDir[ 6 ] ) + ENDIF + + ENDIF + +RETURN s_aDir[ 2 ] + +*-------------------------------- +FUNCTION FileInIncludePath(cFile) +*-------------------------------- + + LOCAL cFilePath := "" + LOCAL cSrcPath := "" + + IF Len(s_aSrcPaths) = 0 + s_aSrcPaths := ListAsArray2( GetEnv( "INCLUDE" ) , HB_OSPATHLISTSEPARATOR() ) ENDIF + IF ! File(cFile) + FOR EACH cSrcPath IN s_aSrcPaths + IF Len(cSrcPath) > 0 .and. Right(cSrcPath,1) <> HB_OSPATHSEPARATOR() + cSrcPath := cSrcPath + HB_OSPATHSEPARATOR() + ENDIF + IF File(cSrcPath + cFile) + cFile := cSrcPath + cFile + EXIT + ENDIF + NEXT + ENDIF + +RETURN cFile + +*---------------------------------- +FUNCTION CreateLibMakeFile( cFile ) +*---------------------------------- + + LOCAL aInFiles := {} + LOCAL aOutFiles := {} + LOCAL aSrc := Directory( "*.prg" ) + LOCAL nLenaSrc := Len( aSrc ) + + LOCAL aOutC := {} + LOCAL aSrcC := Directory( "*.c" ) + LOCAL cOS := IIF( s_lLinux, "Linux", "Win32") + LOCAL cCompiler := IIF( s_lLinux, "GCC",IIF(s_lMSVcc,"MSVC",IIF(s_lPocc,"POCC","BCC"))) + LOCAL cLibName := Padr( Left( cFile, At( '.', cFile ) - 1 ) ,40) + + LOCAL lAutomemvar := .F. + LOCAL lVarIsMemvar := .F. + LOCAL lDebug := .F. + LOCAL lSupressline := .F. + LOCAL cHarbourFlags := "" + LOCAL cObjDir := s_cObjDir + space( 20 ) + LOCAL lCompMod := .F. + LOCAL lInstallLib := .F. + LOCAL x + LOCAL y + LOCAL nPos +// LOCAL lGenppo := .F. + LOCAL GetList := {} + LOCAL cItem := "" + LOCAL cExt := "" + LOCAL cDrive := "" + LOCAL cPath := "" + LOCAL cTest := "" + LOCAL cLast := '' + LOCAL nWriteFiles := 0 + LOCAL aUserDefs + LOCAL cCurrentDef := "" + LOCAL cBuild := " " + LOCAL lCancelMake := .F. + LOCAL nOption + LOCAL lNew := .F. + LOCAL oMake + LOCAL cAllRes := "" + LOCAL cTemp + + IF nLenaSrc == 0 .AND. !s_lRecursive + IF s_nLang == 1 // Portuguese-BR + s_cAlertMsg := "NÆo h  prg na pasta "+curdir() + ELSEIF s_nLang == 3 // Spanish + s_cAlertMsg := "No hay ning£n prg en la carpeta "+curdir() + ELSE + s_cAlertMsg := "Have not any prg in "+curdir()+" folder." + ENDIF + Alert( s_cAlertMsg ) + RETURN NIL + ENDIF + + s_cUserInclude := space(200) + s_cUserDefine := space(200) + + + IF File( cFile ) + + CLS + + IF s_nLang == 1 // Portuguese-BR + nOption := Alert( "O makefile <" + cFile +"> j  existe.",{ "Editar", "Criar Novo" , "Cancelar" } ) + ELSEIF s_nLang == 3 // Spanish + nOption := Alert( "Lo makefile <" + cFile +"> ya existe.",{ "Editar", "Crear Nuevo" , "Cancelar" } ) + ELSE // English + nOption := Alert( "The makefile <" + cFile +"> already exist ",{ "Edit" , "Create New" , "Cancel" } ) + ENDIF + + + IF nOption = 1 // edit makefile + + + // Verify if "cFile" can be openned to write mode. + + s_nMakeFileHandle := FOpen( cFile, FO_WRITE ) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser aberto para edi‡Æo." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser abierto para edici¢n." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be openned for edition." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+LTrim(Str(FError()))+")" ) + + RETURN NIL + else + FClose( s_nMakeFileHandle ) + endif + + oMake :=THbMake():new() + oMake:cMakefile := cFile + oMake:cMacro := iif(s_lMSVcc,"#MSVC",iif(s_lPocc,"#POCC",iif(s_lGcc,"#GCC","#BCC"))) + oMake:ReadMakefile(cFile) + + FRename(cFile,cFile+".old") + + IF LEN(oMake:aRes) >0 + FOR EACH cTemp IN oMake:aRes + cAllRes += cTemp+ " " + NEXT + ENDIF + + lAutoMemVar := oMake:lAutomemvar + lVarIsMemVar := oMake:lVarIsMemvar + lDebug := oMake:ldebug + lSupressline := oMake:lSupressline + lCompMod := oMake:lCompMod + s_lGenppo := oMake:lGenppo + lInstallLib := oMake:lInstallLib + s_cUserInclude := PadR(oMake:cUserInclude,200 ) + s_cUserDefine := PadR(oMake:cUserDef,200 ) + s_cUserLibs := PadR(oMake:cUserLib,200 ) + s_cEditor := trim(oMake:cEditor) + + if Empty( s_cEditor ) + if s_lOS2 .OR. s_lLinux + s_cEditor := "mcedit" + else + s_cEditor := "edit" + endif + endif + + if !empty(oMake:cFmc) + cLibName := PadR(oMake:cFmc,200) + endif + + + if !s_lRecursive + s_lRecursive := oMake:lRecurse + endif + + + IF nLenaSrc == 0 .and. !s_lRecursive + + CLS + + IF s_nLang=1 // PT-BR + s_cAlertMsg := "NÆo h  nenhum prg na pasta "+CurDir()+". Use o modo recursivo -r" + ELSEIF s_nLang=3 // Spanish + s_cAlertMsg := "No hay ning£n prg en la carpeta "+CurDir()+". Use lo modo recursivo -r" + ELSE + s_cAlertMsg := "Does not have any prg in "+CurDir()+" folder. Use the recursive mode -r" + ENDIF + + Alert( s_cAlertMsg ) + + SetColor("W/N,N/W") + CLS + set cursor on + QUIT + + ENDIF + + if s_lCancelRecursive + s_lRecursive := .F. + endif + + // after oMake read, recreate other clean makefile to edit. + s_nMakeFileHandle := FCreate(cFile) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser aberto para edi‡Æo." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser abierto para edici¢n." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be openned for edition." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + + RETURN NIL + + endif + + WriteMakeFileHeader() + + s_lEditMake := .T. + + + ELSEIF nOption = 2 // create a new makefile + + + IF nLenaSrc == 0 .and. !s_lRecursive + + CLS + + IF s_nLang=1 // PT-BR + s_cAlertMsg := "NÆo h  nenhum prg na pasta "+CurDir()+". Use o modo recursivo -r" + ELSEIF s_nLang=3 // Spanish + s_cAlertMsg := "No hay ning£n prg en la carpeta "+CurDir()+". Use lo modo recursivo -r" + ELSE + s_cAlertMsg := "Does not have any prg in "+CurDir()+" folder. Use the recursive mode -r" + ENDIF + + Alert( s_cAlertMsg ) + SetColor("W/N,N/W") + CLS + set cursor on + QUIT + + ENDIF + + s_lEditMake := .F. + + s_nMakeFileHandle := FCreate( cFile ) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser criado." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be created." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + + RETURN NIL + + endif + + WriteMakeFileHeader() + lNew := .T. + + ELSE + SetColor("W/N,N/W") + CLS + set cursor on + QUIT + ENDIF + + ELSE + + s_nMakeFileHandle := FCreate( cFile ) + + if s_nMakeFileHandle = F_ERROR + + CLS + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+cFile + "> nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+cFile + "> no pode ser criado." + ELSE // english + s_cAlertMsg := "<"+cFile + "> cannot be created." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + + RETURN NIL + + ENDIF + + WriteMakeFileHeader() + nOption := 2 // create a new makefile + lNew := .T. + + ENDIF + + CLS + Setcolor( 'w/b+,b+/w,w+/b,w/b+,w/b,w+/b' ) + @ 0, 0, Maxrow(), Maxcol() BOX( Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 ) + Space( 1 ) ) + + Attention( HbMake_Id() + space(10)+s_aLangMessages[ 27 ], 0 ) + + SET CURSOR OFF + + @ 01,01 SAY s_aLangMessages[ 28 ] + + @ 01,17,06,24 GET cOS; + LISTBOX { "Win32", "OS/2", "Linux" }; + MESSAGE s_aLangMessages[ 49 ]; + STATE OsSpec(getlist,1,@cOS); + DROPDOWN + + @ 01,30 SAY s_aLangMessages[ 29 ] + + @ 01,54,06,59 GET cCompiler; + LISTBOX { "BCC", "MSVC", "POCC", "GCC","MINGW" }; + MESSAGE s_aLangMessages[ 50 ]; + STATE OsSpec(getlist,2,@cCompiler); + DROPDOWN + + @ 02,47 SAY s_aLangMessages[ 66 ] + +#ifdef __PLATFORM__Windows + @ 02,68,06,77 GET s_cEditor; + LISTBOX { "edit", "notepad" }; + MESSAGE s_aLangMessages[ 67 ]; + STATE OsSpec(getlist,3,@s_cEditor); + DROPDOWN +#endif + + @ 03,01 SAY s_aLangMessages[ 59 ]; + GET cLibName; + PICT "@S15"; + MESSAGE s_aLangMessages[ 58 ] + + @ 03,35 SAY s_aLangMessages[ 60 ]; + GET cObjDir; + PICT "@S15" + + Attention( "Harbour Options", 5 ) + + @ 06,01 GET lAutoMemvar; + CHECKBOX; + CAPTION s_aLangMessages[ 32 ]; + STYLE "[X ]" + + @ 06,40 GET lVarIsMemvar; + CHECKBOX; + CAPTION s_aLangMessages[ 33 ]; + STYLE "[X ]" + + @ 07,01 GET lDebug; + CHECKBOX; + CAPTION s_aLangMessages[ 34 ]; + STYLE "[X ]" + + @ 07,40 GET lSupressLine; + CHECKBOX; + CAPTION s_aLangMessages[ 35 ]; + STYLE "[X ]" + + @ 08,01 GET s_lGenppo; + CHECKBOX; + CAPTION s_aLangMessages[ 36 ]; + STYLE "[X ]" + + @ 08,40 GET lCompMod; + CHECKBOX; + CAPTION s_aLangMessages[ 37 ]; + STYLE "[X ]" + + @ 09,01 SAY s_aLangMessages[ 38 ]; + GET s_cUserDefine; + PICT "@S23" + + @ 09,40 SAY s_aLangMessages[ 39 ]; + GET s_cUserInclude; + PICT "@S18" + + @ 10,01 GET lInstallLib; + CHECKBOX; + CAPTION s_aLangMessages[ 61 ]; + STYLE "[X ]" + + READ MSG AT MaxRow() - 1, 1, MaxCol() - 1 + +// SET CURSOR ON + + IF ! Empty( s_cUserDefine ) + aUserDefs := ListasArray2(Alltrim( s_cUserDefine ), ";") + + FOR EACH cCurrentDef in aUserDefs + cHarbourFlags += " -D" + Alltrim( cCurrentDef ) + " " + NEXT + ENDIF + + IF ! Empty( s_cUserInclude ) + cHarbourFlags += " -I" + Alltrim( s_cUserInclude ) + " " + ENDIF + + s_lBcc := "BCC" $ cCompiler + s_lMSVcc := "MSVC" $ cCompiler + s_lGcc := "GCC" $ cCompiler + s_lPocc := "POCC" $ cCompiler + s_lMinGW := "MINGW" $ cCompiler + + if s_lMinGW + s_lGcc := .T. + s_lBcc := s_lMSVcc := s_lPocc := .F. + endif + + cObjDir := Alltrim( cObjDir ) + + IF ! Empty( cObjDir ) + + IF !hb_DirExists( cObjDir ) +#ifdef HB_COMPAT_C53 + MakeDir( cObjDir ) +#endif + ENDIF + + ENDIF + + s_aMacros := GetSourceDirMacros( s_lGcc, cOS ) + + IF s_lGcc + cObjDir := Alltrim( cObjDir ) + + IF ! Empty( cObjDir ) + cObjDir += '/' + ENDIF + + cTest := cObjDir + '/' + ELSE + cObjDir := Alltrim( cObjDir ) + + IF ! Empty( cObjDir ) + cObjDir += '\' + ENDIF + + cTest := cObjDir + '\' + ENDIF + + AEval( s_aMacros, { | x, y | cItem := Substr( x[ 2 ], 1, Len( x[ 2 ] ) ), IIF( At( citem, cTest ) > 0, ( s_aMacros[ y, 1 ] := 'OBJ', s_aMacros[ y, 2 ] := cObjDir ), ) } ) + + IF lAutoMemvar + cHarbourFlags += " -a " + ENDIF + + IF lVarIsMemvar + cHarbourFlags += " -v " + ENDIF + + IF lDebug + cHarbourFlags += " -b " + ENDIF + + IF lSupressline + cHarbourFlags += " -l " + ENDIF + + IF s_lGenppo + cHarbourFlags += " -p " + ENDIF + + IF lCompmod + cHarbourFlags += " -m " + ENDIF + + IF s_lBcc + AAdd( s_aCommands, { ".cpp.obj:", "$(CC_DIR)\BIN\bcc32 $(CFLAG1) $(CFLAG2) -o$* $**" } ) + AAdd( s_aCommands, { ".c.obj:", "$(CC_DIR)\BIN\bcc32 -I$(HB_DIR)\include $(CFLAG1) $(CFLAG2) -o$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.obj:", "$(HB_DIR)\bin\harbour -n -go" + if(s_lGenCsource,"3","") + " -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(FWH)\include -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(FWH)\include -o$* $**" } ) + ENDIF + + AAdd( s_aCommands, { ".rc.res:", "$(CC_DIR)\BIN\brcc32 $(RFLAGS) $<" } ) + + ELSEIF s_lGcc + + IF "linux" $ Lower( Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Linux" + AAdd( s_aCommands, { ".cpp.o:", "gcc $(CFLAG1) $(CFLAG2) -o$* $**" } ) + AAdd( s_aCommands, { ".c.o:", "gcc -I/usr/include/harbour $(CFLAG1) $(CFLAG2) -I. -o$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.o:", "harbour -n $(HARBOURFLAGS) -I/usr/include/harbour -I. -go" + if(s_lGenCsource,"3","") + " -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "harbour -n $(HARBOURFLAGS) -I/usr/include/harbour -I. -o$* $**" } ) + ENDIF + + ELSE + AAdd( s_aCommands, { ".cpp.o:", "$(CC_DIR)\bin\gcc $(CFLAG1) $(CFLAG2) -o$* $**" } ) + AAdd( s_aCommands, { ".c.o:", "$(CC_DIR)\bin\gcc -I$(HB_DIR)/include $(CFLAG1) $(CFLAG2) -I. -o$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.o:", "$(HB_DIR)\bin\harbour -n -go" + if(s_lGenCsource,"3","") + " -I$(HB_DIR)/include $(HARBOURFLAGS) -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)/include $(HARBOURFLAGS) -o$* $**" } ) + ENDIF + + ENDIF + + ELSEIF s_lMSVcc + AAdd( s_aCommands, { ".cpp.obj:", "$(CC_DIR)\bin\cl $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + AAdd( s_aCommands, { ".c.obj:", "$(CC_DIR)\bin\cl -I$(HB_DIR)\include $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.obj:", "$(HB_DIR)\bin\harbour -go" + if(s_lGenCsource,"3","") + " -n -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(C4W)\include -o$* $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(C4W)\include -o$* $**" } ) + ENDIF + + AAdd( s_aCommands, { ".rc.res:", "$(CC_DIR)\BIN\rc $(RFLAGS) $<" } ) + + ELSEIF s_lPocc + AAdd( s_aCommands, { ".cpp.obj:", "$(CC_DIR)\BIN\pocc $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + AAdd( s_aCommands, { ".c.obj:", "$(CC_DIR)\BIN\pocc -I$(HB_DIR)\include $(CFLAG1) $(CFLAG2) -Fo$* $**" } ) + + IF s_lExtended + AAdd( s_aCommands, { ".prg.obj:", "$(HB_DIR)\bin\harbour -n -go" + if(s_lGenCsource,"3","") + " -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(FWH)\include -o$** $**" } ) + ELSE + AAdd( s_aCommands, { ".prg.c:", "$(HB_DIR)\bin\harbour -n -I$(HB_DIR)\include $(HARBOURFLAGS) -I$(FWH)\include -o$** $**" } ) + ENDIF + + AAdd( s_aCommands, { ".rc.res:", "$(CC_DIR)\BIN\porc $(RFLAGS) $<" } ) + + ENDIF + + + if s_nLang=1 + s_cAlertMsg := "Selecione os PRGs a compilar" + elseif s_nLang=3 + s_cAlertMsg := "Seleccione los PRG a compilar" + else + s_cAlertMsg := "Select the PRG files to compile" + endif + + aInFiles := GetSourceFiles( s_lRecursive, s_lGcc, cOS ) + + nLenaSrc := Len( aInFiles ) + + aOutFiles := aClone( aInFiles ) + + + IF nOption !=2 // not create a makefile + pickarry( 10, 15, 19, 64, aInFiles, aOutFiles, ArrayAJoin( { oMake:aPrgs, oMake:aCs } ), .T., s_cAlertMsg ) + ELSE + pickarry( 10, 15, 19, 64, aInFiles, aOutFiles, {}, .T., s_cAlertMsg ) + ENDIF + + + AEval( aOutFiles, { | x, y | aOutFiles[ y ] := Trim( Substr( aOutFiles[ y ], 1, At( ' ', aOutFiles[ y ] ) ) ) } ) + AEval( aOutFiles, { | xItem | IIF( At( '.c', xItem ) > 0 .OR. At( '.C', xItem ) > 0 .OR. At( '.cpp', xItem ) > 0 .OR. At( '.CPP', xItem ) > 0, AAdd( aOutc, xitem ), ) } ) + AEval( aOutc, { | x, z | citem := x, z := AScan( aOutFiles, { | t | t = citem } ), IIF( z > 0, aSize( aDel( aOutFiles, z ), Len( aOutFiles ) - 1 ), ) } ) + + aOutFiles := aSort( aOutFiles ) + s_aPrgs := aClone( aOutFiles ) + + s_aObjs := aClone( aOutFiles ) + AEval( s_aObjs, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), IIF( ! s_lGcc, s_aObjs[ x ] := cObjDir + cTest + "." + Exte( cExt, 2 ), s_aObjs[ x ] := cObjDir + cTest + "." + Exte( cExt, 3 ) ) } ) + s_aCFiles := aClone( aOutc ) + + IF ! s_lExtended + AEval( aOutc, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), IIF( ! s_lGcc, AAdd( s_aObjs, cObjDir + cTest + "." + Exten( cExt, 2 ) ), AAdd( s_aObjs, cObjDir + cTest + "." + Exten( cExt, 1 ) ) ) } ) + AEval( aOutFiles, { | xItem | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cExt := Substr( cExt, 2 ), AAdd( s_aCFiles, cObjDir + cTest + "." + Exte( cExt, 1 ) ) } ) + ELSE + s_aObjsC := aClone( aOutc ) + AEval( aOutc, { | xItem, x | hb_FNAMESPLIT( xiTem, @cPath, @cTest, @cExt, @cDrive ), cext := Substr( cExt, 2 ), IIF( ! s_lGcc, s_aObjsC[ x ] := cObjDir + cTest + "." + Exten( cExt, 2 ), s_aObjsC[ x ] := cObjDir + cTest + "." + Exten( cExt, 1 ) ) } ) + ENDIF + + FOR x := 1 TO Len( s_aMacros ) + + IF ! Empty( s_aMacros[ x, 2 ] ) + cItem := s_aMacros[ x, 2 ] + nPos := AScan( s_aPrgs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + AEval( s_aPrgs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aPrgs[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + + IF ! s_aMacros[ x, 3 ] + FWrite( s_nMakeFileHandle, s_aMacros[ x, 1 ] + ' = ' + Left( s_aMacros[ x, 2 ], Len( s_aMacros[ x, 2 ] ) - 1 ) + " " + CRLF ) + s_aMacros[ x, 3 ] := .T. + ENDIF + + ENDIF + + nPos := AScan( s_aCFiles, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + AEval( s_aCFiles, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aCFiles[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + + IF ! s_aMacros[ x, 3 ] + FWrite( s_nMakeFileHandle, s_aMacros[ x, 1 ] + ' = ' + Left( s_aMacros[ x, 2 ], Len( s_aMacros[ x, 2 ] ) - 1 ) + " " + CRLF ) + s_aMacros[ x, 3 ] := .T. + ENDIF + + ENDIF + + nPos := AScan( s_aObjs, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + + IF ! Empty( cObjDir ) + AEval( s_aObjs, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aObjs[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + FWrite( s_nMakeFileHandle, s_aMacros[ x, 1 ] + ' = ' + Left( s_aMacros[ x, 2 ], Len( s_aMacros[ x, 2 ] ) - 1 ) + " " + CRLF ) + ENDIF + + ENDIF + + IF s_lExtended + nPos := AScan( s_aObjsC, { | z | hb_FNAMESPLIT( z, @cPath, @cTest, @cExt, @cDrive ), cPath == citem } ) + + IF nPos > 0 + + IF ! Empty( cObjDir ) + AEval( s_aObjsC, { | a, b | hb_FNAMESPLIT( a, @cPath, @cTest, @cExt, @cDrive ), IIF( cPath == citem, s_aObjsC[ b ] := Strtran( a, cPath, "$(" + s_aMacros[ x, 1 ] + IIF( s_lGcc, ")/", ')\' ) ), ) } ) + ENDIF + + ENDIF + + ENDIF + + ENDIF + + NEXT + + IF s_lGcc + + IF "linux" $ Lower( Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Linux" + FWrite( s_nMakeFileHandle, "PROJECT = " + IIF( lInstallLib, "$(HB_DIR)/lib/", "" ) + Alltrim( cLibName ) + ".a " + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, "PROJECT = " + IIF( lInstallLib, "$(HB_DIR)\lib\", "" ) + Alltrim( Lower( cLibName ) ) + ".a " + CRLF ) + ENDIF + + ELSE + FWrite( s_nMakeFileHandle, "PROJECT = " + IIF( lInstallLib, "$(HB_DIR)\lib\", "" ) + Alltrim( Lower( cLibName ) ) + ".lib " + "$(PR)" + CRLF ) + ENDIF + + IF ! s_lExtended + nWriteFiles := 0 + FWrite( s_nMakeFileHandle, "OBJFILES =" ) + + IF Len( s_aObjs ) < 1 + FWrite( s_nMakeFileHandle, + " $(OB) " + CRLF ) + ELSE + nWriteFiles := 0 + AEval( s_aObjs, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aObjs ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) + ENDIF + + nWriteFiles := 0 + FWrite( s_nMakeFileHandle, "CFILES =" ) + + IF Len( s_aCFiles ) < 1 + FWrite( s_nMakeFileHandle, + " $(CF)" + CRLF ) + ELSE + AEval( s_aCFiles, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aCFiles ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(CF) " + CRLF ) ) } ) + ENDIF + + FWrite( s_nMakeFileHandle, "PRGFILE =" ) + nWriteFiles := 0 + + IF Len( s_aPrgs ) < 1 + FWrite( s_nMakeFileHandle, + " $(PS)" + CRLF ) + ELSE + AEval( s_aPrgs, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aPrgs ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) + ENDIF + + ELSE /****extended moded ****/ + FWrite( s_nMakeFileHandle, "OBJFILES =" ) + nWriteFiles := 0 + + IF Len( s_aObjs ) < 1 + FWrite( s_nMakeFileHandle, + " $(OB) " + CRLF ) + ELSE + AEval( s_aObjs, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aObjs ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(OB) " + CRLF ) ) } ) + ENDIF + + FWrite( s_nMakeFileHandle, "PRGFILES =" ) + nWriteFiles := 0 + + IF Len( s_aPrgs ) < 1 + FWrite( s_nMakeFileHandle, + " $(PS)" + CRLF ) + ELSE + AEval( s_aPrgs, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aPrgs ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(PS) " + CRLF ) ) } ) + ENDIF + + nWriteFiles := 0 + + IF Len( s_aObjsC ) > 0 + FWrite( s_nMakeFileHandle, "OBJCFILES =" ) + + IF Len( s_aObjsC ) < 1 + FWrite( s_nMakeFileHandle, + " $(OBC) " + CRLF ) + ELSE + AEval( s_aObjsC, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aObjsC ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(OBC) " + CRLF ) ) } ) + ENDIF + + ENDIF + + nWriteFiles := 0 + + IF Len( s_aCFiles ) > 0 + FWrite( s_nMakeFileHandle, "CFILES =" ) + + IF Len( s_aCFiles ) < 1 + FWrite( s_nMakeFileHandle, + " $(CF)" + CRLF ) + ELSE + AEval( s_aCFiles, { | x, i | nWriteFiles ++, IIF( i <> Len( s_aCFiles ), FWrite( s_nMakeFileHandle, ' ' + Alltrim( x ) + IIF( nWriteFiles % 10 == 0, " //" + CRLF, "" ) ), FWrite( s_nMakeFileHandle, " " + Alltrim( x ) + " $(CF) " + CRLF ) ) } ) + ENDIF + + ENDIF + + ENDIF + + FWrite( s_nMakeFileHandle, "RESFILES =" + CRLF ) + FWrite( s_nMakeFileHandle, "RESDEPEN = $(RESFILES)" + CRLF ) + FWrite( s_nMakeFileHandle, "DEFFILE = " + CRLF ) + FWrite( s_nMakeFileHandle, "HARBOURFLAGS = " + cHarbourFlags + CRLF ) + FWrite( s_nMakeFileHandle, "INSTALLLIB = " + IIF( lInstallLib, "YES","NO" ) + CRLF ) + FWrite( s_nMakeFileHandle, "USERDEFINE = " + alltrim(s_cUserDefine) + CRLF ) + FWrite( s_nMakeFileHandle, "USERINCLUDE = " + alltrim(s_cUserInclude) + CRLF ) + FWrite( s_nMakeFileHandle, "EDITOR = " + s_cEditor + CRLF ) + + IF s_lBcc + + FWrite( s_nMakeFileHandle, "CFLAG1 = -OS $(SHELL) $(CFLAGS) -d -L$(HB_DIR)\lib;$(FWH)\lib -c" + CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = -I$(HB_DIR)\include -I$(CC_DIR)\include -I" + Alltrim( s_cUserInclude ) + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = /P32 /0" + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = tlib $(LFLAGS) $(PROJECT)" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = " + CRLF ) + FWrite( s_nMakeFileHandle, ".autodepend" + CRLF ) + + ELSEIF s_lMSVcc + + FWrite( s_nMakeFileHandle, "CFLAG1 = -I$(INCLUDE_DIR) -TP -W3 -nologo $(C_USR) $(SHELL) $(CFLAGS)" + CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = -c -I" + Alltrim( s_cUserInclude ) + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = lib $(PROJECT)" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES) " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = " + CRLF ) + + ELSEIF s_lPocc + + FWrite( s_nMakeFileHandle, "CFLAG1 = " + CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = " + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) +// FWrite( s_nMakeFileHandle, "LINKER = polib $(PROJECT)" + CRLF ) + FWrite( s_nMakeFileHandle, "LINKER = polib " + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES) " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN)" + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = " + CRLF ) + + ELSEIF s_lGcc + + FWrite( s_nMakeFileHandle, "CFLAG1 = " + IIF( s_lLinux , "-I/usr/include/harbour", " -I$(HB_DIR)/include " ) + " $(SHELL) -c -Wall" + CRLF ) + FWrite( s_nMakeFileHandle, "CFLAG2 = " + IIF( s_lLinux , "-L /usr/lib/harbour", " -L $(HB_DIR)/lib" ) + CRLF ) + FWrite( s_nMakeFileHandle, "RFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "LFLAGS = " + CRLF ) + FWrite( s_nMakeFileHandle, "IFLAGS = " + CRLF ) + + IF "linux" $ Lower( Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Linux" .OR. s_lLinux + FWrite( s_nMakeFileHandle, "LINKER = ar -M " + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, "LINKER = ar -M " + CRLF ) + ENDIF + + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLOBJ = $(OBJFILES) $(OBJCFILES) " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLRES = $(RESDEPEN) " + CRLF ) + FWrite( s_nMakeFileHandle, "ALLLIB = $(LIBFILES) " + CRLF ) + FWrite( s_nMakeFileHandle, ".autodepend" + CRLF ) + + ENDIF + + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "#COMMANDS" + CRLF ) + AEval( s_aCommands, { | xItem | FWrite( s_nMakeFileHandle, xitem[ 1 ] + CRLF ), FWrite( s_nMakeFileHandle, xitem[ 2 ] + CRLF ), FWrite( s_nMakeFileHandle, " " + CRLF ) } ) + + IF s_lBcc + + FWrite( s_nMakeFileHandle, "#BUILD" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "$(PROJECT): $(CFILES) $(OBJFILES)" + CRLF ) + FWrite( s_nMakeFileHandle, " $(CC_DIR)\BIN\$(LINKER) @&&!" + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLOBJ)" + CRLF ) + FWrite( s_nMakeFileHandle, "!" + CRLF ) + + ELSEIF s_lMSVcc .OR. s_lPocc + + FWrite( s_nMakeFileHandle, "#BUILD" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "$(PROJECT): $(CFILES) $(OBJFILES)" + CRLF ) + FWrite( s_nMakeFileHandle, " $(CC_DIR)\BIN\$(LINKER) @&&!" + CRLF ) + FWrite( s_nMakeFileHandle, " $(PROJECT)" + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLOBJ)" + CRLF ) + FWrite( s_nMakeFileHandle, "!" + CRLF ) + + ELSEIF s_lGcc + + FWrite( s_nMakeFileHandle, "#BUILD" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) + FWrite( s_nMakeFileHandle, "$(PROJECT): $(CFILES) $(OBJFILES) " + CRLF ) + + IF "linux" $ Lower( Getenv( "HB_ARCHITECTURE" ) ) .OR. cOS == "Linux" + FWrite( s_nMakeFileHandle, " $(LINKER) @&&!" + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, " $(CC_DIR)\bin\$(LINKER) @&&!" + CRLF ) + ENDIF + + FWrite( s_nMakeFileHandle, " $(PROJECT) " + CRLF ) + FWrite( s_nMakeFileHandle, " $(ALLOBJ) " + CRLF ) + FWrite( s_nMakeFileHandle, "!" + CRLF ) + + ENDIF + + FClose( s_nMakeFileHandle ) + + IF !lCancelMake + + IF s_nLang == 1 .OR. s_nLang == 3 + s_cAlertMsg := "Compilar lib ? (S/N) " + ELSE // English + s_cAlertMsg := "Build lib ? (Y/N) " + ENDIF + + @ 20,5 Say s_cAlertMsg Get cBuild PICT "!" Valid cBuild $ iif(s_nLang=2,"YN","SN") + READ + + IF cBuild == "S" .OR. cBuild == "Y" + ResetInternalVars() + SetColor("W/N,N/W") + Clear + SetPos(9,0) + Main( cFile, " -f "+iif(s_nLang=1,"-lPT",iif(s_nLang=3,"-lES","-lEN")) ) + ELSE + set cursor on + SetColor("W/N,N/W") + Clear + ENDIF + + ELSE + set cursor on + SetColor("W/N,N/W") + Clear + ENDIF + +RETURN NIL + +*--------------------- +FUNCTION SetBuildLib() +*--------------------- + + LOCAL cRead as String + LOCAL nPos as Numeric + LOCAL aMacro as Array + LOCAL aTemp as Array + LOCAL nCount as Numeric + LOCAL aCurobjs as Array + LOCAL nObjPos as Numeric + LOCAL cLib + LOCAL xInfo + + cRead := Alltrim( readln( @s_lEof ) ) + s_nMakeFileHandle := FCreate( s_cMakeFileName ) + + + IF s_nMakeFileHandle = F_ERROR + + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := "<"+s_cMakeFileName + "> nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := "<"+s_cMakeFileName + "> no pode ser criado." + ELSE // english + s_cAlertMsg := "<"+s_cMakeFileName + "> cannot be created." + ENDIF + + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + + ENDIF + + s_szProject := cRead + aMacro := ListAsArray2( cRead, ":" ) + + IF Len( aMacro ) > 1 + aTemp := ListAsArray2( aMacro[ 2 ], " " ) + AEval( aTemp, { | xItem | AAdd( s_aBuildOrder, xItem ) } ) + ENDIF + + AAdd( s_aBuildOrder, aMacro[ 1 ] ) + cRead := Strtran( cRead, "@&&!", "" ) + aMacro := ListAsArray2( cRead, '\' ) + AEval( aMacro, { | xMacro | Findmacro( xMacro, @cRead ) } ) + + IF s_lBcc .OR. s_lMSVcc .OR. s_lPocc + s_cLinkCommands := cRead + " @" + s_cMakeFileName + ELSE + s_cLinkCommands := cRead + " < " + s_cMakeFileName + ENDIF + + + FOR nPos := 1 TO 7 + + cRead := Alltrim( readln( @s_lEof ) ) + aMacro := ListAsArray2( cRead, " " ) + + FOR nCount := 1 TO Len( aMacro ) + + + IF "$" $ aMacro[ nCount ] + + IF ( aMacro[ nCount ] = "$(PROJECT)" ) .AND. (s_lGcc .OR. s_lMSVcc .OR. s_lPocc) + + FindMacro( aMacro[ nCount ], @cRead ) + + IF s_lGcc + FWrite( s_nMakeFileHandle, "CREATE " + " lib" + cRead + CRLF ) + cLib := "lib" + cRead +// FWrite( s_nMakeFileHandle, cRead + CRLF ) + ELSE + cRead := strtran(cRead,",","") + cRead := strtran(cRead,"+","") + xInfo := iif(s_lMSVcc," -out:","/out:") + xInfo += cRead + cRead := xInfo + FWrite( s_nMakeFileHandle, cRead + CRLF ) + ENDIF + + ELSEIF ( aMacro[ nCount ] == "$(ALLOBJ)" ) + + Findmacro( aMacro[ nCount ], @cRead ) + aCurObjs := ListAsArray2( cRead, " " ) + + FOR nObjPos := 1 TO Len( aCurObjs ) + + IF s_lGcc + FWrite( s_nMakeFileHandle, "ADDMOD " + aCurObjs[ nObjPos ] + CRLF ) + ENDIF + + IF s_lBcc .OR. s_lMSVcc .OR. s_lPocc + + IF nObjPos < Len( aCurObjs ) + FWrite( s_nMakeFileHandle, iif(s_lBcc,"+-","") + aCurObjs[ nObjPos ] + iif(s_lBcc," &","") + CRLF ) + ELSE + FWrite( s_nMakeFileHandle, iif(s_lBcc,"+-","") + aCurObjs[ nObjPos ] + CRLF ) + ENDIF + + ENDIF + + NEXT + + ENDIF + + ENDIF + + NEXT + + NEXT + + IF s_lGcc + FWrite( s_nMakeFileHandle, "SAVE" + CRLF ) + FWrite( s_nMakeFileHandle, "END " + CRLF ) + ENDIF + + FClose( s_nMakeFileHandle ) + + IF s_lLinux + s_cLinkCommands += " || rm -f " + cLib + ENDIF + +RETURN NIL + +*--------------------------------- +FUNCTION FindCfile( citem, aSrcc ) +*--------------------------------- + LOCAL nReturnPos := 0 + + nReturnPos := AScan( aSrcc, { | x | Lower( x[ 1 ] ) == cItem } ) + +RETURN nReturnPos + +/* +#IFNDEF __HARBOUR__ +FUNCTION CRLF + RETURN Chr( 13 ) + Chr( 10 ) +#ENDIF +*/ + +*---------------------------- +FUNCTION CheckIFfile( cFile ) +*---------------------------- + + LOCAL cNextLine := '' + LOCAL cCommand := '' + LOCAL cTemp + + cTemp := Substr( cFile, At( " ", cFile ) + 1 ) + + IF File( cTemp ) + cNextLine := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + IF "!" $ cNextLine + cCommand := Substr( cNextLine, At( ' ', cNextLine ) + 1 ) + RUN( cCommand ) + ENDIF + + RETURN .T. + + ENDIF + +RETURN .F. + +*---------------------------- +FUNCTION Checkstdout( cText ) +*---------------------------- + + cText := Strtran( cText, "!stdout", "" ) + Outstd( cText ) + +RETURN NIL + +*--------------------------- +FUNCTION CheckIFdef( cTemp ) +*--------------------------- + + LOCAL nPos + LOCAL cRead := "" + LOCAL aSet := {} + LOCAL nMakePos + + IF cTemp == "!endif" + RETURN NIL + ENDIF + + WHILE At( "!endif", cRead ) == 0 + cRead := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + IF "!endif" $ cRead + FT_FSKIP( - 1 ) + EXIT + ENDIF + + cTemp := Strtran( cTemp, "!ifdef ", "" ) + + IF '=' $ cRead + + IF "\.." $ cRead + cRead := Substr( cRead, 1, At( "\..", cRead ) - 1 ) + ELSEIF "/.." $ cRead + cRead := Substr( cRead, 1, At( "/..", cRead ) - 1 ) + ENDIF + + aSet := ListAsArray2( cRead, "=" ) + nPos := AScan( s_aDefines, { | x | x[ 1 ] == cTemp } ) + + IF nPos > 0 + cRead := Alltrim( Strtran( aSet[ 1 ], "$(", "" ) ) + cRead := Strtran( cRead, ")", "" ) + nMakePos := AScan( s_aMacros, { | x | x[ 1 ] == cRead } ) + + IF nMakePos == 0 + AAdd( s_aMacros, { aSet[ 1 ], aSet[ 2 ] } ) + ENDIF + + ELSE /* Locate For !ELSE */ + + WHILE At( "!endif", cRead ) == 0 + cRead := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + IF "!ELSE" $ cRead + + WHILE At( "!endif", cRead ) == 0 + cRead := Trim( Substr( ReadLN( @s_lEof ), 1 ) ) + + IF "!endif" $ cRead + FT_FSKIP( - 1 ) + EXIT + ENDIF + + aSet := ListAsArray2( cRead, "=" ) + AAdd( s_aMacros, { aSet[ 1 ], aSet[ 2 ] } ) + ENDDO + + ENDIF + + ENDDO + + ENDIF + + ELSEIF '!stdout' $ cRead + Checkstdout( cRead ) + ENDIF + + ENDDO + +RETURN NIL + +*------------------------- +FUNCTION BuildBccCfgFile() +*------------------------- +LOCAL cCfg := s_cHarbourDir + '\bin\'+s_cHarbourCFG +LOCAL nCfg + + IF !File( cCfg ) .or. s_lForce + + nCfg := FCreate( cCfg ) + + if nCfg = F_ERROR + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := cCfg + " nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := cCfg + " no pode ser criado." + ELSE // english + s_cAlertMsg := cCfg + " cannot be created." + ENDIF + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + endif + + FWrite( nCfg, "CC=BCC32" + CRLF ) +// FWrite( nCfg, "CFLAGS= -c " + ReplaceMacros( "-I$(HB_DIR)\include -OS $(CFLAGS) -d -L$(HB_DIR)\lib" ) + CRLF ) + FWrite( nCfg, "CFLAGS= -c -D__EXPORT__ " + ReplaceMacros( "-I$(HB_DIR)\include $(CFLAGS) -d -L$(HB_DIR)\lib" ) + CRLF ) + FWrite( nCfg, "VERBOSE=YES" + CRLF ) + FWrite( nCfg, "DELTMP=YES" + CRLF ) + FClose( nCfg ) + ENDIF + +RETURN NIL + +*------------------------- +FUNCTION BuildMscCfgFile() +*------------------------- + LOCAL cCfg := s_cHarbourDir + '\bin\'+s_cHarbourCFG + LOCAL nCfg + + IF !File( cCfg ) .or. s_lForce + + nCfg := FCreate( cCfg ) + + if nCfg = F_ERROR + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := cCfg + " nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := cCfg + " no pode ser criado." + ELSE // english + s_cAlertMsg := cCfg + " cannot be created." + ENDIF + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + endif + + FWrite( nCfg, "CC=cl" + CRLF ) + FWrite( nCfg, "CFLAGS= -c -D__EXPORT__" + ReplaceMacros( "-I$(HB_DIR) -TP -W3 -nologo $(C_USR) $(CFLAGS)" ) + CRLF ) + FWrite( nCfg, "VERBOSE=YES" + CRLF ) + FWrite( nCfg, "DELTMP=YES" + CRLF ) + FClose( nCfg ) + ENDIF + +RETURN NIL + + +*------------------------- +FUNCTION BuildPccCfgFile() +*------------------------- + LOCAL cCfg := s_cHarbourDir + '\bin\'+s_cHarbourCFG + LOCAL nCfg + + IF !File( cCfg ) .or. s_lForce + + nCfg := FCreate( cCfg ) + + if nCfg = F_ERROR + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := cCfg + " nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := cCfg + " no pode ser criado." + ELSE // english + s_cAlertMsg := cCfg + " cannot be created." + ENDIF + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + endif + + FWrite( nCfg, "CC=POCC" + CRLF ) + FWrite( nCfg, "CFLAGS= /Ze /Go /Ot /Tx86-coff /D__EXPORT__ " + ReplaceMacros( "-I$(HB_DIR)\include $(C_USR) $(CFLAGS)" ) + CRLF ) + FWrite( nCfg, "VERBOSE=YES" + CRLF ) + FWrite( nCfg, "DELTMP=YES" + CRLF ) + FClose( nCfg ) + + ENDIF + +RETURN NIL + + + +*------------------------- +FUNCTION BuildGccCfgFile() +*------------------------- + LOCAL cCfg + LOCAL nCfg + LOCAL cDir := s_cHarbourDir +// LOCAL cBhc := Alltrim( Strtran( ReplaceMacros( '$(HB_DIR)' ), '\', '/' ) ) + +// cDir := Strtran( cDir, '/', '\' ) + + cCfg := s_cHarbourDir + '\bin\'+s_cHarbourCFG + + IF !File( cCfg ) .or. s_lForce + + nCfg := FCreate( cCfg ) + + if nCfg = F_ERROR + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := cCfg + " nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := cCfg + " no pode ser criado." + ELSE // english + s_cAlertMsg := cCfg + " cannot be created." + ENDIF + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + endif + + FWrite( nCfg, "CC=gcc" + CRLF ) + FWrite( nCfg, "CFLAGS= -c -D__EXPORT__ " + ReplaceMacros( "-I" + s_cHarbourDir + "/include $(C_USR) -L" + s_cHarbourDir + "/lib" ) + if(s_lmingw ," -mno-cygwin ","" )+ CRLF ) + FWrite( nCfg, "VERBOSE=YES" + CRLF ) + FWrite( nCfg, "DELTMP=YES" + CRLF ) + FClose( nCfg ) + ENDIF + +RETURN NIL + +*-------------------------- +FUNCTION BuildGccCfgFileL() +*-------------------------- + LOCAL cCfg := '/etc/'+s_cHarbourCFG + LOCAL nCfg + + IF !File( cCfg ) .or. s_lForce + + nCfg := FCreate( cCfg ) + + if nCfg = F_ERROR + IF s_nLang = 1 // brazilian portuguese + s_cAlertMsg := cCfg + " nÆo pode ser criado." + ELSEIF s_nLang = 3 // spanish + s_cAlertMsg := cCfg + " no pode ser criado." + ELSE // english + s_cAlertMsg := cCfg + " cannot be created." + ENDIF + Alert( s_cAlertMsg+" FERROR ("+Ltrim(Str(FError()))+")" ) + RETURN NIL + endif + + FWrite( nCfg, "CC=gcc" + CRLF ) + FWrite( nCfg, "CFLAGS= -c -I/usr/include/harbour" + CRLF ) + FWrite( nCfg, "VERBOSE=YES" + CRLF ) + FWrite( nCfg, "DELTMP=YES" + CRLF ) + FClose( nCfg ) + ENDIF + +RETURN NIL + +*------------------------------ +FUNCTION FindHarbourCfg( cCfg ) +*------------------------------ + + LOCAL cPath AS STRING := '' + LOCAL lFound AS LOGICAL := .F. + LOCAL cEnv AS STRING + LOCAL aEnv as Array of String + LOCAL lLinux := s_lLinux + LOCAL nPos + + IF ! lLinux .OR. s_lOs2 + cEnv := Gete( "PATH" ) + ";" + Curdir() + aEnv := ListAsArray2( cEnv, ";" ) + + FOR nPos := 1 TO Len( aEnv ) + + IF File( aEnv[ nPos ] + '\'+s_cHarbourCFG ) + cPath := aEnv[ nPos ] + lFound := .T. + EXIT + ENDIF + + NEXT + + ELSE + + IF File( '/etc/'+s_cHarbourCFG ) + lFound := .T. + cPath := '/etc/'+s_cHarbourCFG + ENDIF + + IF !lFound + + IF File( '/usr/local/etc/'+s_cHarbourCFG ) + lFound := .T. + cPath := '/usr/local/etc/'+s_cHarbourCFG + ENDIF + + ENDIF + + ENDIF + + cCfg := cPath + +RETURN lFound + +*--------------------------- +FUNCTION TestforPrg( cFile ) +*--------------------------- + + LOCAL aFiles AS ARRAY := {} + LOCAL cPath AS STRING := '' + LOCAL cTest AS STRING := "" + LOCAL cDrive AS STRING := "" + LOCAL cExt AS STRING := "" + LOCAL cItem AS STRING := "" + LOCAL aDir AS ARRAY + LOCAL nPos AS NUMERIC + LOCAL nFiles AS NUMERIC + + hb_FNAMESPLIT( cFile, @cPath, @cTest, @cExt, @cDrive ) + + cExt := Substr( cExt, 2 ) + aDir := Directory( cTest + '.*' ) + + FOR nPos := 1 TO 7 + cItem := cTest + "." + Extenprg( cExt, nPos ) + AAdd( aFiles, cItem ) + NEXT + + FOR nFiles := 1 TO Len( aFiles ) + nPos := AScan( aDir, { | a | a[ 1 ] == aFiles[ nFiles ] } ) + + IF nPos > 0 + AAdd( s_aPrgs, aFiles[ nFiles ] ) + ENDIF + + NEXT + +RETURN NIL + +*------------------- +FUNCTION GetGccDir() +*------------------- + + LOCAL cPath AS STRING := '' + LOCAL cEnv AS STRING + LOCAL aEnv AS Array of string + LOCAL nPos as Numeric + + IF s_lLinux + cPath := "." + ELSE + cEnv := Gete( "PATH" ) + aEnv := ListAsArray2( cEnv, ";" ) + + FOR nPos := 1 TO Len( aEnv ) + + IF File( aEnv[ nPos ] + '\gcc.exe' ) .OR. File( Upper( aEnv[ nPos ] ) + '\GCC.EXE' ) + cPath := aEnv[ nPos ] + cPath := Left( cPath, Rat( '\', cPath ) - 1 ) + EXIT + ENDIF + + NEXT + + ENDIF + +RETURN cPath + +*------------------------------------------------------------- +FUNCTION ConvertParams( cFile, aFile, p1, p2, p3, p4, p5, p6 ) +*------------------------------------------------------------- + + LOCAL cParam := "" + + IF ! Empty( cFile ) + + IF Left( cFile, 1 ) $ "- /?" .OR. "credits" $ cFile + cParam += cFile+" " + ELSE + cFile := cFile + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + IF ! Empty( p1 ) + + IF Left( p1, 1 ) $ "- /?" .OR. "credits" $ p1 + cParam += p1+" " + ELSE + cFile := p1 + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + IF ! Empty( p2 ) + + IF Left( p2, 1 ) $ "- /" + cParam += p2+" " + ELSE + cFile := p2 + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + IF ! Empty( p3 ) + + IF Left( p3, 1 ) $ "- /" + cParam += p3+" " + ELSE + cFile := p3 + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + IF ! Empty( p4 ) + + IF Left( p4, 1 ) $ "- /" + cParam += p4+" " + ELSE + cFile := p4 + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + IF ! Empty( p5 ) + + IF Left( p5, 1 ) $ "- /" + cParam += p5+" " + ELSE + cFile := p5 + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + IF ! Empty( p6 ) + + IF Left( p6, 1 ) $ "- /" + cParam += p6+" " + ELSE + cFile := p6 + AAdd( aFile, cFile ) + ENDIF + + ENDIF + + cParam := Strtran( cParam, "/", "-" ) + cParam := Strtran( cParam, "-elx", "-ELX" ) + cParam := Strtran( cParam, "-el", "-ELX" ) + cParam := Strtran( cParam, "-ex", "-EX" ) + cParam := Strtran( cParam, "-e", "-EX" ) + cParam := Strtran( cParam, "-i", "-I" ) + cParam := Strtran( cParam, "-p", "-P" ) + cParam := Strtran( cParam, "-b", "-B" ) + cParam := Strtran( cParam, "-gl", "-GL" ) + cParam := Strtran( cParam, "-g", "-G" ) + cParam := Strtran( cParam, "-v", "-V" ) + cParam := Strtran( cParam, "-m", "-M" ) + cParam := Strtran( cParam, "-pc", "-PC" ) + cParam := Strtran( cParam, "-f", "-F" ) + cParam := Strtran( cParam, "-r", "-R" ) + cParam := Strtran( cParam, "-nr", "-NR" ) // cancel recursive search + cParam := Strtran( cParam, "-l", "-L" ) + cParam := Strtran( cParam, "-c", "-C" ) // compile after create. + + IF "-EX" $ cParam .OR. "-ELX" $ cParam + IF "-ELX" $ cParam + s_lLibrary := .T. + ENDIF + ENDIF + + IF "-L" $ cParam + s_cDefLang := Substr( cParam, At( "-L", cParam ) + 2, 2 ) + ENDIF RETURN cParam -FUNCTION ShowHelp() - - LOCAL cOs := Upper( Os() ) - - ? aLangMessages[ 1 ] - ? "Copyright 2000,2001,2002 Luiz Rafael Culik " - ? "" - ? aLangMessages[ 2 ] - ? "" - ? aLangMessages[ 3 ] - ? aLangMessages[ 4 ] - ? aLangMessages[ 5 ] - ? aLangMessages[ 6 ] - ? aLangMessages[ 7 ] - ? aLangMessages[ 8 ] - - IF At( "OS/2", cOs ) > 0 - - ? aLangMessages[ 9 ] - ? aLangMessages[ 10 ] - ? aLangMessages[ 13 ] - - ELSEIF At( 'LINUX', Upper( cOs ) ) > 0 - - ? aLangMessages[ 9 ] - ? aLangMessages[ 12 ] - ? aLangMessages[ 14 ] - - ELSE - - ? aLangMessages[ 11 ] - ? aLangMessages[ 12 ] - ? aLangMessages[ 13 ] - - ENDIF - - ? aLangMessages[ 15 ] - ? aLangMessages[ 16 ] - ? aLangMessages[ 17 ] - ? aLangMessages[ 18 ] - ? aLangMessages[ 19 ] - ? aLangMessages[ 20 ] - ? aLangMessages[ 21 ] - ? aLangMessages[ 22 ] - ? aLangMessages[ 23 ] - ? aLangMessages[ 24 ] - ? aLangMessages[ 25 ] - ? aLangMessages[ 26 ] - /* - ?? "Harbour Make Utility" - ? "Copyright 2000,2001,2002 Luiz Rafael Culik " - ? "" - ? "Syntax: hbmake cFile [options]" - ? "" - ? "Options: /e[x] Create a new Makefile. If /ex is" - ? " used it creates a new make file in extended mode" - ? " /el[x] Create a new Makefile. If /elx is" - ? " used it creates a new make file to build a library in extended mode" - ? " /D Define a macro" - ? " /p Print all commands and depencies" - IF At( "OS/2", cOs ) > 0 - ? " /b Use BCC as C compiler" - ? " /g+ Use GCC as C compiler" - ? " /gl Use GCC as C compiler in Linux" - ELSEIF At( 'LINUX', Upper( cOs ) ) > 0 - ? " /b Use BCC as C compiler" - ? " /g Use GCC as C compiler" - ? " /gl+ Use GCC as C compiler in Linux" - ELSE - ? " /b+ Use BCC as C compiler" - ? " /g Use GCC as C compiler" - ? " /gl Use GCC as C compiler in Linux" - ENDIF - - ? " /v Use MSVC as C compiler" - ? " /f Force recompiltion of all files" - ? " /i Ignore errors returned by command" - ? " /r Recurse Source Directory" - - ? " Note: /p and /D can be used together" - ? " Note: /r and /e[x]/el[x] can be used together" - ? " Options with + are the default values" - ? " -D switch can accept multiple macros on the same line" - ? " or use one macro per -D switch" - */ -RETURN Nil - +*------------------------------------ FUNCTION ProcessParameters( cParams ) +*------------------------------------ - LOCAL aDef + LOCAL aDef + + // Force to recompile all sources + IF "-F" $ cParams + s_lForce := .T. + cParams := StrTran( cParams, "-F", "" ) + ENDIF - IF At( "-F", cParams ) > 0 - lForce := .T. - cParams := Strtran( cParams, "-F", "" ) + // Recursive source search + IF "-R" $ cParams + s_lRecursive := .T. + cParams := StrTran( cParams, "-R", "" ) + ENDIF - ENDIF + // cancel -R + IF "-NR" $ cParams + s_lRecursive := .F. + s_lCancelRecursive := .T. + cParams := StrTran( cParams, "-NR", "" ) + ENDIF - IF At( "-B", cParams ) > 0 + // Use BCC as default C/C++ + IF "-B" $ cParams + s_lBcc := .T. + s_lGcc := .F. + s_lMSVcc := .F. + s_lPocc := .F. + s_lMinGW := .F. + cParams := Strtran( cParams, "-B", "" ) + ENDIF - lBcc := .T. - lGcc := .F. - lVcc := .F. - cParams := Strtran( cParams, "-B", "" ) + // Use GCC as default C/C++ at Linux + IF "-GL" $ cParams + s_lBcc := .F. + s_lGcc := .T. + s_lMSVcc := .F. + s_lPocc := .F. + s_lLinux := .T. + s_lMinGW := .F. + cParams := Strtran( cParams, "-GL", "" ) + ENDIF - ENDIF + // Use GCC as default C/C++ at Windows + IF "-G" $ cParams + s_lBcc := .F. + s_lGcc := .T. + s_lMSVcc := .F. + s_lPocc := .F. + s_lMinGW := .F. + cParams := Strtran( cParams, "-G", "" ) + ENDIF - IF At( "-GL", cParams ) > 0 + // Use MS-VC as default C/C++ + IF "-V" $ cParams + s_lBcc := .F. + s_lGcc := .F. + s_lMSVcc := .T. + s_lPocc := .F. + cParams := Strtran( cParams, "-V", "" ) + ENDIF - lBcc := .F. - lGcc := .T. - lVcc := .F. - lLinux := .T. - cParams := Strtran( cParams, "-GL", "" ) + // Use Pelles C as default C/C++ + IF "-PC" $ cParams + s_lBcc := .F. + s_lGcc := .F. + s_lMSVcc := .F. + s_lPocc := .T. + s_lMinGW := .F. + cParams := Strtran( cParams, "-PC", "" ) + ENDIF - ENDIF + // compile only the module + IF "-M" $ cParams + s_lBcc := .F. + s_lGcc := .T. + s_lMSVcc := .F. + s_lPocc := .F. + s_lMinGW := .T. + cParams := Strtran( cParams, "-M", "" ) + ENDIF - IF At( "-G", cParams ) > 0 + // Ignore warnings + IF "-I" $ cParams + s_lIgnoreErrors := .T. + cParams := Strtran( cParams, "-I", "" ) + ENDIF - lBcc := .F. - lGcc := .T. - lVcc := .F. - cParams := Strtran( cParams, "-G", "" ) + // Print all commands and dependencies + IF "-P" $ cParams + s_lPrint := .T. + cParams := Strtran( cParams, "-P", "" ) + ENDIF - ENDIF + // Define a macro. + IF "-D" $ cParams + cParams := "-D" + Strtran( cParams, "-D", ";" ) + cParams := Strtran( cParams, "-D;", "-D" ) + aDef := ListAsArray2( Alltrim( Substr( cParams, 3 ) ), ";" ) + AEval( aDef, { | xDef | IIF( At( '=', xDef ) > 0, GetParaDefines( xDef ), ) } ) + ENDIF - IF At( "-V", cParams ) > 0 + // Build a Library + IF "-EL" $ cParams .OR. "-ELX" $ cParams - lBcc := .F. - lGcc := .F. - lVcc := .T. - cParams := Strtran( cParams, "-V", "" ) + IF At( "-ELX", cParams ) > 0 + cParams := Strtran( cParams, "-ELX", "" ) + ELSE + cParams := Strtran( cParams, "-EL", "" ) + ENDIF - ENDIF + s_lEdit := .T. + s_lExtended := .T. + s_lLibrary := .T. + s_cMakeFileName := "makelib.lnk" - IF At( "-I", cParams ) > 0 + ENDIF - lIgnoreErrors := .T. - cParams := Strtran( cParams, "-I", "" ) + // Build an application + IF "-E" $ cParams .OR. "-EX" $ cParams - ENDIF + IF "-EX" $ cParams + cParams := Strtran( cParams, "-EX", "" ) + ELSE + cParams := Strtran( cParams, "-E", "" ) + ENDIF - IF At( "-R", cParams ) > 0 + s_lEdit := .T. + s_lExtended := .T. - lRecurse := .T. - cParams := Strtran( cParams, "-R", "" ) + ENDIF - ENDIF - - IF At( "-P", cParams ) > 0 - - lPrint := .t. - cParams := Strtran( cParams, "-P", "" ) - - ENDIF - - IF At( "-D", cParams ) > 0 - - cParams := "-D" + Strtran( cParams, "-D", ";" ) - cParams := Strtran( cParams, "-D;", "-D" ) - - adef := Listasarray2( Alltrim( Substr( cParams, 3 ) ), ";" ) - Aeval( aDef, { | xDef | If( At( '=', xDef ) > 0, GetParaDefines( xDef ), ) } ) - - ENDIF - - IF At( "-EL", cParams ) > 0 .or. At( "-ELX", cParams ) > 0 - - IF At( "-ELX", cParams ) > 0 - - cParams := Strtran( cParams, "-ELX", "" ) - - ELSE - - cParams := Strtran( cParams, "-EL", "" ) - - ENDIF - - lExtended := .T. - lLibrary := .T. - lEditMode := .T. - - ENDIF - - IF At( "-E", cParams ) > 0 .or. At( "-EX", cParams ) > 0 - - IF At( "-EX", cParams ) > 0 - - cParams := Strtran( cParams, "-EX", "" ) - - ELSE - - cParams := Strtran( cParams, "-E", "" ) - - ENDIF - - lExtended := .T. - lEditMode := .T. - - ENDIF - -RETURN Nil +RETURN NIL +*----------------------------- FUNCTION WriteMakeFileHeader() +*----------------------------- +/* + TODO: + FWrite( s_nMakeFileHandle, "#" + CRLF ) + FWrite( s_nMakeFileHandle, "# "+HbMake_Id() + CRLF ) + FWrite( s_nMakeFileHandle, "# "+HbMake_copyright() + CRLF ) + FWrite( s_nMakeFileHandle, "# "+Version() + CRLF ) + FWrite( s_nMakeFileHandle, "# "+HB_Compiler() + CRLF ) + FWrite( s_nMakeFileHandle, "# "+OS() + CRLF ) + FWrite( s_nMakeFileHandle, "# Makefile created at: " + dtoc( date() ) + " - " + time() + CRLF ) + FWrite( s_nMakeFileHandle, "#" + CRLF ) + FWrite( s_nMakeFileHandle, CRLF ) +*/ - Fwrite( nLinkHandle, "#BCC" + CRLF ) - Fwrite( nLinkHandle, "VERSION=BCB.01" + CRLF ) - Fwrite( nLinkHandle, "!ifndef BCB" + CRLF ) - Fwrite( nLinkHandle, "BCB = $(MAKEDIR)" + CRLF ) - Fwrite( nLinkHandle, "!endif" + CRLF ) - Fwrite( nLinkHandle, CRLF ) - Fwrite( nLinkHandle, "!ifndef BHC" + CRLF ) - Fwrite( nLinkHandle, "BHC = $(HMAKEDIR)" + CRLF ) - Fwrite( nLinkHandle, "!endif" + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) - Fwrite( nLinkHandle, "RECURSE="+if(lRecurse," YES "," NO ") + CRLF ) - Fwrite( nLinkHandle, " " + CRLF ) +IF s_lMSVcc + FWrite( s_nMakeFileHandle, "#MSVC" + CRLF ) +ELSEIF s_lPocc + FWrite( s_nMakeFileHandle, "#POCC" + CRLF ) +ELSEIF s_lGcc + FWrite( s_nMakeFileHandle, "#GCC" + CRLF ) +ELSE + FWrite( s_nMakeFileHandle, "#BCC" + CRLF ) + FWrite( s_nMakeFileHandle, "VERSION=BCB.01" + CRLF ) +ENDIF -RETURN nil + FWrite( s_nMakeFileHandle, "!ifndef CC_DIR" + CRLF ) + FWrite( s_nMakeFileHandle, "CC_DIR = $(MAKE_DIR)" + CRLF ) + FWrite( s_nMakeFileHandle, "!endif" + CRLF ) + FWrite( s_nMakeFileHandle, CRLF ) + FWrite( s_nMakeFileHandle, "!ifndef HB_DIR" + CRLF ) + FWrite( s_nMakeFileHandle, "HB_DIR = $(HARBOUR_DIR)" + CRLF ) + FWrite( s_nMakeFileHandle, "!endif" + CRLF ) + FWrite( s_nMakeFileHandle, " " + CRLF ) +// FWrite( s_nMakeFileHandle, "RECURSE=" + IIF( s_lRecursive, " YES ", " NO " ) + CRLF ) +// FWrite( s_nMakeFileHandle, " " + CRLF ) + +RETURN NIL + +*------------------------------- FUNCTION BuildLangArray( cLang ) +*------------------------------- +LOCAL aLang := Array( 67 ) - LOCAL aLang := {} + DEFAULT cLang TO "EN" - DEFAULT cLang TO "EN" + AFill( aLang, "" ) + + aLang[1] := HbMake_Id() // Hbmake identification. + + IF cLang == "EN" // English + + aLang[2] := "Syntax: hbmake .bc [options] - Example: hbmake hello.bc /ex" + aLang[3] := "Options: /e[x] Create a new Makefile. If /ex is used it create a" + aLang[4] := " new make file in extended mode." + aLang[5] := " /el[x] Create a new Makefile. If /elx is used it create a" + aLang[6] := " new make file to build a LIB in extended mode." + aLang[7] := " /D Define a macro." + aLang[8] := " /p Print all commands and depedencies." + aLang[9] := " /b Use Borland C/C++ as C compiler" + aLang[10] := " /g+ Use GNU C/C++ as C compiler" + aLang[11] := " /b+ Use Borland C/C++ as C compiler" + aLang[12] := " /g Use GNU C/C++ as C compiler" + aLang[13] := " /gl Use GNU C/C++ as C compiler in Linux" + aLang[14] := " /gl+ Use GNU C/C++ as C compiler in Linux" + aLang[15] := " /v Use MS-Visual C/C++ as C compiler" + aLang[16] := " /f Force recompiltion of all files" + aLang[17] := " /i Ignore errors returned by command" + aLang[18] := " /r /nr Activate recursive mode. /nr Deactivate recursive mode." + aLang[19] := " Note: /p and /D can be used together" + aLang[20] := " /r and /e[x]/el[x] can be used together" + aLang[21] := " Options with + are the default values" + aLang[22] := " -D switch can accept multiple macros on the same line" + aLang[23] := " or use one macro per -D switch" + aLang[24] := " /l[LANGID] Specify the language to be used on hbmake" + aLang[25] := " LANGID= (EN/PT/ES). On Windows, the default will be the S.O." + aLang[26] := " language. On OS/2, FreeBSD and LINUX will be English." + aLang[27] := "Enviroment options" + aLang[28] := "Select the OS" + aLang[29] := "Select the C Compiler" + aLang[30] := "Graph Lib" + aLang[31] := "Harbour Options" + aLang[32] := "Automatic memvar declaration /a" + aLang[33] := "Variables are assumed M-> /v" + aLang[34] := "Debug info /b" + aLang[35] := "Suppress line number information /l" + aLang[36] := "Generate pre-processed output /p" + aLang[37] := "compile module only /m" + aLang[38] := "User Defines " + aLang[39] := "User include Path" + aLang[40] := "Use External Libs" + aLang[41] := "-Select -Continue process Sel/Unsel All" + aLang[42] := "Warning level /w" + aLang[43] := "Numbers of source files per line on makefile" + aLang[44] := "Use Multi Thread Library" + aLang[45] := "Executable file name" + aLang[46] := "Warning Level /w" + aLang[47] := "-Next -Prev -Sel <"+chr(24)+chr(25)+">-Change Sel -Open Box" + /* Messages Start Here */ + aLang[48] := "3rd Party Rdd" + aLang[49] := "What OS you Use" + aLang[50] := "What C compiler you has" + aLang[51] := "This app use Graphical libraries" + aLang[52] := "Do you use 3rd Party Rdd" + aLang[53] := "Compress this app" + aLang[54] := "Compress the app after Linked (use upx ?)" + aLang[55] := "Your app will be linked to user harbour.dll" + aLang[56] := "Where the .obj/.o files will be generates" + aLang[57] := "Inform executable name (without .exe extention)" + /* More messages for LIB build */ + aLang[58] := "Inform the lib name (without extension)" + /* More Harbour options for LIB build */ + aLang[59] := "Lib name:" + aLang[60] := "Obj dir files:" + aLang[61] := "Install the lib at the Harbour lib folder" + aLang[62] := " /pc Use Pelles C/C++ as C compiler" + aLang[63] := " /m Use MinGW (GCC) as C compiler" + aLang[64] := " /credits" + + aLang[65] := "User Libs: " + aLang[66] := "Errorlog Editor:" + aLang[67] := "Inform the log error editor for your choice." + + ELSEIF cLang == "ES" // Spanish + + aLang[2] := "Sintaxe: hbmake .bc [opciones] - Exemplo: hbmake hello.bc /ex" + aLang[3] := "Opciones: /e[x] Crea un Makefile nuevo. Si se usa /ex se crea un nuevo" + aLang[4] := " makefile en modo extendido." + aLang[5] := " /el[x] Crea un Makefile nuevo. Si se usa /elx se crea un nuevo" + aLang[6] := " makefile para construir una LIB en modo extendido." + aLang[7] := " /D Define una macro." + aLang[8] := " /p Imprime todos los comandos y dependencias." + aLang[9] := " /b Usa Borland C/C++ como compilador C" + aLang[10] := " /g+ Usa GNU C/C++ como compilador C" + aLang[11] := " /b+ Usa Borland C/C++ como compilador C" + aLang[12] := " /g Usa GNU C/C++ como compilador C" + aLang[13] := " /gl Usa GNU C/C++ como compilador C en Linux" + aLang[14] := " /gl+ Usa GNU C/C++ como compilador C en Linux" + aLang[15] := " /v Usa MS-Visual C/C++ como compilador C" + aLang[16] := " /f Forza la recompilaci¢n de todos los archivos" + aLang[17] := " /i Ignora los errores devueltos por el comando" + aLang[18] := " /r /nr Activa modo recursivo. /nr Desactivar modo recursivo." + aLang[19] := " Nota: /p y /D pueden ser usados juntos" + aLang[20] := " /r y /e[x]/el[x] pueden ser usados juntos" + aLang[21] := " Las opciones con + son los valores por omisi¢n" + aLang[22] := " El parametro -D puede aceptar multiplas macros en la misma" + aLang[23] := " linea ou use una macro por parametro -D" + aLang[24] := " /l[LANGID] especifica una linguagem a ser utilizada por" + aLang[25] := " hbmake. LANGID = (EN/PT/ES). En sistemas Windows, Lo padr¢n" + aLang[26] := " es la linguagem de SO. En OS/2, FreeBSD y LINUX ser n Ingl‚s." + aLang[27] := "Opciones de Ambiente" + aLang[28] := "Seleccione SO" + aLang[29] := "Seleccione Compilador C" + aLang[30] := "Lib Grafica" + aLang[31] := "Opciones de lo Harbour" + aLang[32] := "Declaraci¢n automatica de memvar /a" + aLang[33] := "Variables ser n assumidas M-> /v " + aLang[34] := "Info. Debug /b" + aLang[35] := "Suprime info del n£mero de linea /l" + aLang[36] := "Gera salida pre-processada /p" + aLang[37] := "Compila solamente lo modulo /m" + aLang[38] := "Define del usuarios:" + aLang[39] := "Path includes del usuario:" + aLang[40] := "Usar libs externas" + aLang[41] := "-Seleccionar -Continuar proceso Selec/Deselec todo." + aLang[42] := "Nivel del aviso de lo compilador /w" + aLang[43] := "Cuantos PRGs por linea no makefile:" + aLang[44] := "Usar la libreria Multi Thread" + aLang[45] := "Nombre del ejecutable" + aLang[46] := "Nivel de Avisos /w" + aLang[47] := "-Avanzar -Volver -Selec <"+chr(24)+chr(25)+">-Mudar Selec -Caja" + /* Messages Start Here */ + aLang[48] := "Rdd Terceros" + aLang[49] := "Cual OS usted usa" + aLang[50] := "Cual compilador C usted usa" + aLang[51] := "Esta App usa Lib Grafica o No" + aLang[52] := "Usted usa Rdd de terceros" + aLang[53] := "Comprimir app" + aLang[54] := "Prensar la App despu‚s de enlazada (usar upx) ?" + aLang[55] := "Su aplicacion ser  ligada para usar la harbour.dll" + aLang[56] := "Donde los ficheros *.obj ser n generados" + aLang[57] := "Informe lo nombre de lo executable (sin la extension .exe)" + /* More messages for LIB build */ + aLang[58] := "Informe lo nombre de la lib (sin la extension)" + /* More Harbour options for LIB build */ + aLang[59] := "Nombre de la Lib:" + aLang[60] := "Direct¢rio de los Obj:" + aLang[61] := "Alojar la lib en el direct¢rio lib de Harbour" + aLang[62] := " /pc Usa Pelles C/C++ como compilador C" + aLang[63] := " /m Usa MinGW (GCC) como compilador C" + aLang[64] := " /credits" + aLang[65] := "Libs del usuario: " + aLang[66] := "Editor de errorlog:" + aLang[67] := "Informe lo editor de log de errores de su preferencia." + + ELSEIF cLang == "PT" // Portuguese-Brazil + + aLang[2] := "Sintaxe: hbmake .bc [op‡äes] - Exemplo: hbmake hello.bc /ex" + aLang[3] := "Op‡äes: /e[x] Cria um Makefile novo. Se for usado /ex cria um makefile" + aLang[4] := " em modo extendido." + aLang[5] := " /el[x] Cria um Makefile novo. Se for usado /elx cria um makefile" + aLang[6] := " para construir uma LIB, em modo extendido." + aLang[7] := " /D Define uma macro." + aLang[8] := " /p Imprime todos os comandos e dependˆncias." + aLang[9] := " /b Usa Borland C/C++ como compilador C" + aLang[10] := " /g+ Usa GNU C/C++ como compilador C" + aLang[11] := " /b+ Usa Borland C/C++ como compilador C" + aLang[12] := " /g Usa GNU C/C++ como compilador C" + aLang[13] := " /gl Usa GNU C/C++ como compilador C no Linux" + aLang[14] := " /gl+ Usa GNU C/C++ como compilador C no Linux" + aLang[15] := " /v Usa MS-Visual C/C++ como compilador C" + aLang[16] := " /f For‡a a recompila‡Æo de todos os arquivos." + aLang[17] := " /i Ignora os erros devolvidos pelo comando." + aLang[18] := " /r /nr Ativa modo recursivo. /nr Desativar modo recursivo." + aLang[19] := " Nota: /p e /D podem ser usados juntos" + aLang[20] := " /r e /e[x]/el[x] podem ser usados juntos" + aLang[21] := " As op‡äes com + sÆo os valores padrÆo." + aLang[22] := " O parƒmetro -D pode aceitar m£ltiplas macros na mesma linha" + aLang[23] := " ou use uma macro por parƒmetro -D" + aLang[24] := " /l[LANGID] especifica a linguagem a ser utilizada pelo hbmake," + aLang[25] := " LANGID = (EN/PT/ES). Em Windows, o padrÆo ser  a linguagem" + aLang[26] := " definida no S.O. Em OS/2, FreeBSD e LINUX o padrÆo ser  Inglˆs." + aLang[27] := "Op‡äes de Ambiente" + aLang[28] := "Selecione o SO" + aLang[29] := "Selecione Compilador C" + aLang[30] := "Lib Gr f." + aLang[31] := "Op‡äes do Harbour" + aLang[32] := "Declara‡Æo Autom tica de Memvar /a" + aLang[33] := "Vari veis sÆo assumidas M-> /v" + aLang[34] := "Info. Debug /b" + aLang[35] := "Suprime info de n£mero da linha /l" + aLang[36] := "Gera sa¡da pr‚-processada /p" + aLang[37] := "Compila apenas o m¢dulo /m" + aLang[38] := "User Defines:" + aLang[39] := "User Include Path:" + aLang[40] := "Usa Libs Externas ?" + aLang[41] := "-Seleciona p/ continuar processo -Sel/DeSel. tudo." + aLang[42] := "N¡vel de aviso do compilador /w" + aLang[43] := "Qtd de PRGs por linha, no makefile: " + aLang[44] := "Usar a biblioteca Multi Thread ?" + aLang[45] := "Nome Execut vel:" + aLang[46] := "N¡vel de Warnings /w" + aLang[47] := "-Avan‡a -Volta -Sel. <"+chr(24)+chr(25)+">-Muda Sel. -Abre Box" + /* Messages Start Here */ + aLang[48] := "Rdd Terceiros" + aLang[49] := "Selecione o Sistema Operacional" + aLang[50] := "Selecione o compilador C/C++" + aLang[51] := "Esta aplica‡Æo vai usar Lib Grafica ? Qual ?" + aLang[52] := "Esta aplica‡Æo vai usar Rdd de terceiros ? Qual ?" + aLang[53] := "Comprimir App ?" + aLang[54] := "Comprimir a aplica‡Æo ap¢s linkada (usar upx) ?" + aLang[55] := "Sua aplica‡Æo ser  linkada para usar a harbour.dll ?" + aLang[56] := "Informe a pasta onde os arquivos *.obj serÆo gerados" + aLang[57] := "Informe o nome do execut vel (sem a extensÆo .exe)" + /* More messages for LIB build */ + aLang[58] := "Informe o nome da lib (sem a extensÆo)" + /* More Harbour options for LIB build */ + aLang[59] := "Nome da Lib:" + aLang[60] := "Diret¢rio dos Obj:" + aLang[61] := "Instalar a lib no diret¢rio lib do Harbour" + aLang[62] := " /pc Usa Pelles C/C++ como compilador C" + aLang[63] := " /m Usa MinGW (GCC) como compilador C" + aLang[64] := " /credits" + aLang[65] := "Libs de usu rio: " + aLang[66] := "Editor de errorlog:" + aLang[67] := "Informe o editor de log de erros de sua preferˆncia." + + ENDIF + +RETURN aLang - IF cLang == "EN" +*------------------------------------------ +FUNCTION GetSelFiles( aInFiles, aOutFiles ) +*------------------------------------------ - Aadd( aLang, "Harbour Make Utility" ) - Aadd( alang, "Syntax: hbmake cFile [options]" ) - Aadd( aLang, "Options: /e[x] Create a new Makefile. If /ex is" ) - Aadd( aLang, " used it creates a new make file in extended mode" ) - Aadd( aLang, " /el[x] Create a new Makefile. If /elx is" ) - Aadd( aLang, " used it creates a new make file to build a library in extended mode" ) - Aadd( aLang, " /D Define a macro" ) - Aadd( aLang, " /p Print all commands and depedencies" ) - Aadd( aLang, " /b Use BCC as C compiler" ) - Aadd( aLang, " /g+ Use GCC as C compiler" ) - Aadd( aLang, " /b+ Use BCC as C compiler" ) - Aadd( aLang, " /g Use GCC as C compiler" ) - Aadd( aLang, " /gl Use GCC as C compiler in Linux" ) - Aadd( aLang, " /gl+ Use GCC as C compiler in Linux" ) - Aadd( aLang, " /v Use MSVC as C compiler" ) - Aadd( aLang, " /f Force recompiltion of all files" ) - Aadd( aLang, " /i Ignore errors returned by command" ) - Aadd( aLang, " /r Recurse Source Directory" ) - Aadd( aLang, " Note: /p and /D can be used together" ) - Aadd( aLang, " Note: /r and /e[x]/el[x] can be used together" ) - Aadd( aLang, " Options with + are the default values" ) - Aadd( aLang, " -D switch can accept multiple macros on the same line" ) - Aadd( aLang, " or use one macro per -D switch" ) - Aadd( aLang, " /l[LANGID] Specify the language to be used on hbmake Texts LANGID = (EN/PT/ES) " ) - Aadd( aLang, " On Windows System, the default will be the SO language if is found" ) - Aadd( aLang, " Otherwise, will be English. On OS/2;FreeBSD/LINUX the default is English" ) - Aadd( aLang, "Enviroment options" ) - Aadd( aLang, "Select Os" ) - Aadd( aLang, "Select C Compiler" ) - Aadd( aLang, "Graphic Library" ) - Aadd( aLang, "Harbour Options" ) - Aadd( aLang, "Automatic memvar declaration" ) - Aadd( aLang, "Variables are assumed M->" ) - Aadd( aLang, "Debug info" ) - Aadd( aLang, "Suppress line number information" ) - Aadd( aLang, "Generate pre-processed output" ) - Aadd( aLang, "compile module only" ) - Aadd( aLang, "User Defines " ) - Aadd( aLang, "User include Path" ) - Aadd( aLang, "Use External Libs" ) - Aadd( aLang, "Spacebar to select, Enter to continue process" ) + LOCAL aRet := {} + LOCAL cItem + LOCAL nPos - ELSEIF cLang == "ES" + FOR EACH cItem IN aInFiles - Aadd( aLang, "Harbour Make Utility - Programa Make de Harbour" ) - Aadd( aLang, "Sintaxis: hbmake cArchivo [opciones]" ) - Aadd( aLang, "Opciones: /e[x] Crea un Makefile nuevo. Si se usa /ex" ) - Aadd( aLang, " se crea un nuevo makefile en modo extendido" ) - Aadd( aLang, " /el[x] Crea un Makefile nuevo. Si se usa /elx" ) - Aadd( aLang, " se crea un nuevo makefile para construir una librería en modo extendido" ) - Aadd( aLang, " /D Define una macro" ) - Aadd( aLang, " /p Imprime todos los comandos y dependencias" ) - Aadd( aLang, " /b Usar BCC como compilador C" ) - Aadd( aLang, " /g+ Usar GCC como compilador C" ) - Aadd( aLang, " /b+ Usar BCC como compilador C" ) - Aadd( aLang, " /g Usar GCC como compilador C" ) - Aadd( aLang, " /gl Usar GCC como compilador C en Linux" ) - Aadd( aLang, " /gl+ Usar GCC como compilador C en Linux" ) - Aadd( aLang, " /v Usar MSVC como compilador C" ) - Aadd( aLang, " /f Forzar la recompilación de todos los archivos" ) - Aadd( aLang, " /i Ignorar los errores devueltos por el comando" ) - Aadd( aLang, " /r Recorrer el directorio fuente recursivamente" ) - Aadd( aLang, " Nota: /p y /D pueden ser usados juntos" ) - Aadd( aLang, " Nota: /r y /e[x]/el[x] pueden ser usados juntos" ) - Aadd( aLang, " Las opciones con + son los valores por omisión" ) - Aadd( aLang, " El parámetro -D puede aceptar múltiples macros en la misma línea" ) - Aadd( aLang, " ou use uma macro por parƒmetro -D" ) - Aadd( aLang, " /l[LANGID] especifica a linguagem a ser utilizada nos textos do hbmake LANGID = (EN/PT/ES) " ) - Aadd( aLang, " Em sistemas Windows, O padrÆo e a linguagem do SO se encontrada" ) - Aadd( aLang, " SenÆo, sera Ingles. Em OS/2;FreeBSD/LINUX o padrÆo ‚ Ingles" ) - Aadd( aLang, "Opciones de Ambiente") - Aadd( aLang, "Selecion Os" ) - Aadd( aLang, "Selecion Compilador C" ) - Aadd( aLang, "Lib graphica" ) - Aadd( aLang, "Opciones do Harbour" ) - Aadd( aLang, "Declaracion Automatica de memvar" ) - Aadd( aLang, "Variaveis sÆo assumidas M->" ) - Aadd( aLang, "Info. Debug" ) - Aadd( aLang, "Suprime a info. de numero da linha" ) - Aadd( aLang, "Gene Sa¡da pre-processada" ) - Aadd( aLang, "Compile apenas o modulo " ) - Aadd( aLang, "User Defines " ) - Aadd( aLang, "User include Path" ) - Aadd( aLang, "Usa Libs Externas" ) - Aadd( aLang, "Espa‡o para selecionar, Enter p/ continuar processo" ) + nPos := AScan( aOutFiles, { | x, y | x == Left( cItem, At( ' ', citem ) - 1 ) } ) - ELSEIF cLang == "PT" + IF nPos > 0 + AAdd( aRet, cItem ) + ENDIF - Aadd( aLang, "Harbour Make Utility - Programa Make do Harbour" ) - Aadd( aLang, "Sintaxis: hbmake cArquivo [op‡äes]" ) - Aadd( aLang, "Op‡äes: /e[x] Cria um Makefile novo. Se for usado /ex" ) - Aadd( aLang, " cria um novo makefile em modo extendido" ) - Aadd( aLang, " /el[x] cria un Makefile novo. Se for usado /elx" ) - Aadd( aLang, " cria um novo makefile para construir una Biblioteca em modo extendido" ) - Aadd( aLang, " /D Define uma macro" ) - Aadd( aLang, " /p Imprime todos los comandos e dependˆncias" ) - Aadd( aLang, " /b Usar BCC como compilador C" ) - Aadd( aLang, " /g+ Usar GCC como compilador C" ) - Aadd( aLang, " /b+ Usar BCC como compilador C" ) - Aadd( aLang, " /g Usar GCC como compilador C" ) - Aadd( aLang, " /gl Usar GCC como compilador C en Linux" ) - Aadd( aLang, " /gl+ Usar GCC como compilador C en Linux" ) - Aadd( aLang, " /v Usar MSVC como compilador C" ) - Aadd( aLang, " /f For‡ar a recompila‡Æo de todos os arquivos" ) - Aadd( aLang, " /i Ignora os errores devolvidos pelo comando" ) - Aadd( aLang, " /r Recorrer o diret¢rio fonte recursivamente" ) - Aadd( aLang, " Nota: /p e /D podem ser usados juntos" ) - Aadd( aLang, " Nota: /r e /e[x]/el[x] podem ser usados juntos" ) - Aadd( aLang, " As op‡äes com + sÆo os valores padrÆo" ) - Aadd( aLang, " O parƒmetro -D pode aceitar multiplas macros na mesma linha" ) - Aadd( aLang, " ou use una macro por parƒmetro -D" ) - Aadd( aLang, " /l[LANGID] especifica a linguagem a ser utilizada nos textos do hbmake LANGID = (EN/PT/ES) " ) - Aadd( aLang, " Em sistemas Windows, O padrÆo e a linguagem do SO se encontrada" ) - Aadd( aLang, " SenÆo, sera Ingles. Em OS/2;FreeBSD/LINUX o padrÆo ‚ Ingles" ) - Aadd( aLang, "Op‡äes de Ambiente") - Aadd( aLang, "Sele‡Æo Os" ) - Aadd( aLang, "Sele‡Æo Compilador C" ) - Aadd( aLang, "Lib Graf¡ca" ) - Aadd( aLang, "Op‡äes do Harbour" ) - Aadd( aLang, "Declara‡Æo Autom tica de memvar" ) - Aadd( aLang, "Variaveis sÆo assumidas M->" ) - Aadd( aLang, "Info. Debug" ) - Aadd( aLang, "Suprime a info. de numero da linha" ) - Aadd( aLang, "Gene Sa¡da pre-processada" ) - Aadd( aLang, "Compile apenas o modulo " ) - Aadd( aLang, "User Defines " ) - Aadd( aLang, "User include Path" ) - Aadd( aLang, "Usa Libs Externas" ) - Aadd( aLang, "Espa‡o para selecionar, Enter p/ continuar processo" ) + NEXT - ENDIF +RETURN aRet - RETURN aLang +*--------------------------- +FUNCTION ResetInternalVars() +*--------------------------- + s_lPrint := .F. + s_lEdit := .F. + s_aDefines := {} + s_aBuildOrder := {} + s_aCommands := {} + s_aMacros := {} + s_aPrgs := {} + s_aExtLibs := {} + s_aCFiles := {} + s_aObjs := {} + s_aObjsC := {} + s_lEof := .F. + s_aResources := {} +// s_cMakeFileName := "makefile.lnk" + s_cLinkCommands := "" + +if s_lBcc + s_lGcc := .F. + s_lMSVcc := .F. + s_lPocc := .F. + s_lMinGW := .F. +elseif s_lMSVcc + s_lBcc := .F. + s_lGcc := .F. + s_lPocc := .F. + s_lMinGw := .F. +elseif s_lPocc + s_lBcc := .F. + s_lGcc := .F. + s_lMSVcc := .F. + s_lMinGW := .F. +endif + s_lForce := .F. + s_lLinux := .F. + s_szProject := "" + s_lLibrary := .F. + s_lIgnoreErrors := .F. + s_lExtended := .T. + s_lOs2 := .F. + s_lRecursive := .F. + s_lEditMake := .F. + s_aDir := {} + s_aLangMessages := {} + +RETURN NIL + +*---------------------------------- +FUNCTION OsSpec(GetList,nPos,cSpec) +*---------------------------------- + local oGet := GetList[nPos] + local oControl + oControl := oGet:Control + IF oControl != NIL + cSpec := oControl:GetData( oControl:Value ) +// keyboard chr( K_TAB ) + ENDIF + +RETURN .T. + +*-------------------------- +FUNCTION CheckCompiler(cOS) +*-------------------------- +RETURN ( ("Win32" $ cOS) .or. ("Linux" $ cOS) ) + +*------------------------------ +FUNCTION SetThisLibs(aTempLibs) +*------------------------------ + +Local c := "" +Local n + +for Each n In aTempLibs + c += "-l" + c += StrTran( n, '.a', "" ) + c+= " " +next + +RETURN c + +*---------------- +FUNCTION AsDll(x) +*---------------- +Local y := x + x := !y +RETURN .T. + +*-------------------- +FUNCTION Delete_ppo() +*-------------------- +LOCAL cFile := alltrim(s_cAppName)+".ppo" + + FErase( cFile ) + +RETURN NIL + +*------------------ +FUNCTION ShowHelp() +*------------------ +/* + CLS + + OutStd( s_aLangMessages[ 1 ] + CRLF ) + OutStd( HbMake_Copyright() + CRLF ) + OutStd( CRLF ) + OutStd( s_aLangMessages[ 2 ] + CRLF ) + OutStd( s_aLangMessages[ 3 ] + CRLF ) + OutStd( s_aLangMessages[ 4 ] + CRLF ) + OutStd( s_aLangMessages[ 5 ] + CRLF ) + OutStd( s_aLangMessages[ 6 ] + CRLF ) + OutStd( s_aLangMessages[ 7 ] + CRLF ) + OutStd( s_aLangMessages[ 8 ] + CRLF ) + + IF s_lOS2 + OutStd( s_aLangMessages[ 9 ] + CRLF ) + OutStd( s_aLangMessages[ 10 ] + CRLF ) + OutStd( s_aLangMessages[ 13 ] + CRLF ) + + ELSEIF s_lLinux + OutStd( s_aLangMessages[ 9 ] + CRLF ) + OutStd( s_aLangMessages[ 12 ] + CRLF ) + OutStd( s_aLangMessages[ 14 ] + CRLF ) + + ELSE + OutStd( s_aLangMessages[ 11 ] + CRLF ) + OutStd( s_aLangMessages[ 12 ] + CRLF ) + OutStd( s_aLangMessages[ 13 ] + CRLF ) + ENDIF + + OutStd( s_aLangMessages[ 15 ] + CRLF ) + OutStd( s_aLangMessages[ 62 ] + CRLF ) + OutStd( s_aLangMessages[ 63 ] + CRLF ) + OutStd( s_aLangMessages[ 16 ] + CRLF ) + OutStd( s_aLangMessages[ 17 ] + CRLF ) + OutStd( s_aLangMessages[ 18 ] + CRLF ) + OutStd( s_aLangMessages[ 19 ] + CRLF ) + OutStd( s_aLangMessages[ 20 ] + CRLF ) + OutStd( s_aLangMessages[ 21 ] + CRLF ) + OutStd( s_aLangMessages[ 22 ] + CRLF ) + OutStd( s_aLangMessages[ 23 ] + CRLF ) + + setpos(maxrow()-1,0) + WAIT + setpos(maxrow(),0) + + OutStd( s_aLangMessages[ 24 ] + CRLF ) + OutStd( s_aLangMessages[ 25 ] + CRLF ) + OutStd( s_aLangMessages[ 26 ] + CRLF ) +*/ + OutStd( HbMake_ID() + HB_OSNewLine() +; + HbMake_Copyright() + HB_OSNewLine() +; + HB_OSNewLine() +; + "Syntax: hbmake [switches]" + HB_OSNewLine() +; + "Switches:" + HB_OSNewLine() +; + " -b Use Bcc as the C compiler. This options is default under Win32" + HB_OSNewLine() +; + " -g Use Gcc as the C compiler. This options is default under OS/2" + HB_OSNewLine() +; + " -gl Use Gcc as the C compiler on Linux" + HB_OSNewLine() +; + " -v Use MSVC as the C compiler" + HB_OSNewLine() +; + " -D Define an macro. Multiple macros can be used in an single line" + HB_OSNewLine() +; + " Ex: -DOBJ=c.obj;d.obj" + HB_OSNewLine() +; + " Multiple -D is also supported" + HB_OSNewLine() +; + " -p Print all command and defines" + HB_OSNewLine() +; + " -f Force all files to be rebuild" + HB_OSNewLine() +; + " -e Open the editor mode." + HB_OSNewLine() +; + " -ec create/edit and compile (only for a unique prg)" + HB_OSNewLine() +; + " -ex Open the editor mode in extended mode" + HB_OSNewLine() +; + " -el Open the editor mode for creating libraries." + HB_OSNewLine() +; + " -elx Open the editor mode for creating libraries in extented mode." + HB_OSNewLine() +; + " -i Ignore errors returned by commands" + HB_OSNewLine() +; + " -r Recurse directories for source code" + HB_OSNewLine() +; + HB_OSNewLine() +; + "Note: Linked with " + Version() + HB_OSNewLine() ) + +RETURN NIL + +*------------------- +FUNCTION HbMake_ID() +*------------------- +RETURN ( "HbMake v"+s_cHbMakeVersion+" - Harbour Make Utility") + +*-------------------------- +FUNCTION HbMake_Copyright() +*-------------------------- +RETURN ( "Copyright (C) 2000-2007 Harbour project - http://www.harbour-project.org") + +*--------------------- +FUNCTION ShowCredits() +*--------------------- +local i,aCredits := {} + + CLS + + aadd( aCredits,"Credits:" ) + aadd( aCredits," " ) + aadd( aCredits,"Luiz Rafael Culik " ) + + qqout( HbMake_Id() ) + qout( HbMake_copyright() ) + qout( " ") + + for i := 1 to Len( aCredits ) + qout( aCredits[i] ) + next + + qout(" ") + +RETURN NIL diff --git a/harbour/utils/hbmake/hbmutils.prg b/harbour/utils/hbmake/hbmutils.prg index 21101422f5..7ae9cdd7d3 100644 --- a/harbour/utils/hbmake/hbmutils.prg +++ b/harbour/utils/hbmake/hbmutils.prg @@ -1,392 +1,720 @@ +/* + * $Id$ + */ +/* + * xHarbour Project source code: + * hbmutils.prg - utils for hbmake. + * + * Copyright 2000,2001,2002,2003,2004 Luiz Rafael Culik + * www - http://www.xharbour.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + #include "common.ch" #ifndef __HARBOUR__ -#include 'hbclip.ch' + #include 'hbclip.ch' #else -DECLARE extenprg( cExt AS STRING, nType AS NUMERIC ) AS STRING -declare exten( cExt as string, nType as numeric ) as string -DECLARE GetSourceFiles( lSubdir as logical ) as ARRAY -DECLARE GetDirs( cPat as USUAL ) as Array -DECLARE GetBccDir() as String -DECLARE GetVccDir() as String -DECLARE GetMakeDir() as String -DECLARE HB_ARGV( n as numeric ) as string -declare hbmake_filedate( c as String ) as string -declare listasArray2( cString as String, cSep as String ) as Array + DECLARE ExtenPrg( cExt AS STRING, nType AS NUMERIC ) AS STRING + DECLARE Exten( cExt as string, nType as numeric ) as string + DECLARE GetSourceFiles( lSubDir as logical ) as ARRAY + DECLARE GetDirs( cPat as USUAL ) as Array + DECLARE GetHarbourDir() as String + DECLARE GetBccDir() as String + DECLARE GetVccDir() as String + DECLARE GetMakeDir() as String + DECLARE HB_ARGV( n as numeric ) as string + DECLARE HbMake_FileDate( c as String ) as string + DECLARE GetPoccDir() as String + #endif -Function GetSourceFiles( lSubdir ) - Local adirs AS ARRAY - Local aRet AS ARRAY := {} - Local lLinux := At( 'linux', lower(Os() )) > 0 - Local cdir as String := If( !llinux, '\' + Curdir() + '\', '/' + Curdir() + '/' ) - Local aStru := { cDir } - Local aData AS ARRAY - Local nCounter as numeric := 0 - Local nArrayLen as numeric - Local nDatalen as numeric - Local y as numeric - Local cItem as String - Local cext - Local cpath - Local cdrive - Local nPos - Local xItem +*-------------------------------------------- +FUNCTION GetSourceFiles( lSubDir, lGcc, cOs ) +*-------------------------------------------- - Default lSubdir To .t. + LOCAL aDirs + LOCAL aRet := {} + LOCAL lLinux := AT( 'linux', LOWER( cOs ) ) > 0 .OR. lGcc + LOCAL cDir := IIF( ! lLinux, '\' + CURDIR() + '\', '/' + CURDIR() + '/' ) + LOCAL aStru := { cDir } + LOCAL aData + LOCAL nCounter := 0 + LOCAL nArrayLen + LOCAL nDatalen + LOCAL y + LOCAL cItem + LOCAL cExt + LOCAL cPath + LOCAL cDrive + LOCAL nPos + LOCAL xItem + LOCAL nLen + LOCAL cFile + LOCAL nPadr + DEFAULT lSubDir TO .t. - While ++ nCounter <= Len( aStru ) - If !Empty( adirs := GetDirs( astru[ nCounter ] ) ) // There are elements! - Aeval( aDirs, { | xItem | Aadd( aStru, xItem ) } ) - Endif - Enddo - aDirs := {} + WHILE ++ nCounter <= LEN( aStru ) - Asort( aStru ) - nArrayLen := Len( aStru ) + IF ! EMPTY( aDirs := GetDirs( aStru[ nCounter ], lGcc ) ) // There are elements! + AEVAL( aDirs, { | xItem | AADD( aStru, xItem ) } ) + ENDIF - For nCounter := 1 To nArrayLen - - - If Len( aData := DIR_MULTI(aStru[ nCounter ]+"*.prg |"+aStru[ nCounter ]+"*.c") ) != 0 - - nDataLen := Len( aData ) - - For y := 1 To nDataLen - If At( '.PRG', Upper( adata[ y, 1 ] ) ) > 0 .or. At( '.C', Upper( adata[ y, 1 ] ) ) > 0 - If lSubdir - Aadd( aRet, Strtran( astru[ nCounter ], cDir, '' ) + aData[ y, 1 ] + ; - Str( aData[ y, 2 ], 8 ) + ' ' + ; - Dtoc( aData[ y, 3 ] ) + ' ' + ; - aData[ y, 4 ] ) - Elseif !lsubdir .and. At( If( lLinux, "/", "\" ), Strtran( astru[ nCounter ], cDir, '' ) ) == 0 - Aadd( aRet, Pad( aData[ y, 1 ], 18 ) + ; - Str( aData[ y, 2 ], 8 ) + ' ' + ; - Dtoc( aData[ y, 3 ] ) + ' ' + ; - aData[ y, 4 ] ) - Endif - Endif - Next - Endif - Next + ENDDO - For nCounter := 1 To Len( aret ) + aDirs := {} - xItem := Substr( aret[ nCounter ], Rat( If( llinux, "/", '\' ), aret[ nCounter ] ) + 1 ) + ASort( aStru ) + nArrayLen := LEN( aStru ) - nPos := Ascan( astru, { | x | x := Substr( x, Rat( If( llinux, "/", '\' ), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xitem, At( ".", xitem ) ) } ) - If nPos > 0 - Adel( astru, nPos ) - Asize( astru, Len( astru ) - 1 ) - Endif + FOR nCounter := 1 TO nArrayLen - Next - For nCounter := 1 To Len( aStru ) - hb_FNAMESPLIT( Left( astru[ nCounter ], At( ' ', astru[ nCounter ] ) - 1 ), @cPath, @cItem, @cExt, @cDrive ) - If ( cExt == '.C' ) .or. ( cExt == ".c" ) - Aadd( aret, astru[ nCounter ] ) - Endif - Next + IF LEN( aData := DIR_MULTI( aStru[ nCounter ] + "*.prg |" + aStru[ nCounter ] + "*.c |" + aStru[ nCounter ] + "*.cpp" ) ) != 0 -Return aRet + nDataLen := LEN( aData ) -Function extenprg( cExt, nType ) + nPadr := 12 // maximum Clipper/DOS source file name length with extension. + // if this lenght is greater than 12, then reset nPadr. + FOR y := 1 TO nDataLen + nPadr := Max( AT('.PRG', UPPER( aData[ y, 1 ] ) )+3 , nPadr ) + nPadr := Max( AT('.C', UPPER( aData[ y, 1 ] ) )+1 , nPadr ) + nPadr := Max( AT('.CPP', UPPER( aData[ y, 1 ] ) )+3 , nPadr ) + NEXT - Local aext AS ARRAY := { "C", "c" } - Local nPos AS NUMERIC - Local cTemp AS String := "" - nPos := Ascan( aext, { | a | a == cExt } ) - If nPos > 0 - If nTYpe == 1 - cTemp := Strtran( cExt, aExt[ nPos ], 'prg' ) - Elseif ntype == 2 - cTemp := Strtran( cExt, aExt[ nPos ], 'prG' ) - Elseif ntype == 3 - cTemp := Strtran( cExt, aExt[ nPos ], 'pRg' ) - Elseif ntype == 4 - cTemp := Strtran( cExt, aExt[ nPos ], 'Prg' ) - Elseif ntype == 5 - cTemp := Strtran( cExt, aExt[ nPos ], 'PRg' ) - Elseif ntype == 6 - cTemp := Strtran( cExt, aExt[ nPos ], 'PrG' ) - Elseif ntype == 7 - cTemp := Strtran( cExt, aExt[ nPos ], 'PRG' ) + FOR y := 1 TO nDataLen - Endif - Endif -Return ctemp + IF AT( '.PRG', UPPER( aData[ y, 1 ] ) ) > 0 .OR. AT( '.C', UPPER( aData[ y, 1 ] ) ) > 0 .OR. AT( '.CPP', UPPER( aData[ y, 1 ] ) ) > 0 -Static Function GetDirs( cPattern ) + IF lSubDir - Local aDir := {} - Local lLinux := At( 'linux', lower(Os()) ) > 0 - - Aeval( Directory( cPattern + if(lLinux,"*","*."), "D" ), ; - { | xItem | If( xItem[ 5 ] = "D" .and. ; - ( xItem[ 1 ] != "." .and. xItem[ 1 ] != ".." ), ; - ( Aadd( aDir, cPattern + xItem[ 1 ] + If( llinux, "/", '\' ) ), ; - Outstd( "." ) ), "" ) } ) + nLen := AT( " ", aData[ y, 1 ] ) + 1 -Return ( aDir ) + AADD( aRet, STRTRAN( aStru[ nCounter ], cDir, '' ) +; + PadR(aData[ y,1 ] ,nPadr) + ; // prg name + STR(aData[ y, 2 ] , 8 ) + ' ' + ; // prg size + DTOC(aData[ y, 3 ] ) + ' ' + ; // prg date + aData[ y, 4 ] ) // prg time -Function GetBccDir() + ELSEIF ! lSubDir .AND. AT( IIF( lLinux, "/", "\" ), STRTRAN( aStru[ nCounter ], cDir, '' ) ) == 0 - Local cPath := '' - Local cEnv := Gete( "PATH" ) - Local aEnv := listasarray2( cEnv, ";" ) - Local nPos + AADD( aRet, PadR(aData[ y, 1 ],nPadr) + ; // prg name + STR( aData[ y, 2 ], 8 ) + ' ' + ; // prg size + DTOC( aData[ y, 3 ] ) + ' ' + ; // prg date + aData[ y, 4 ] ) // prg time - For nPos := 1 To Len( aEnv ) - If File( aenv[ nPos ] + '\bcc32.exe' ) .or. File( Upper( aenv[ nPos ] ) + '\BCC32.EXE' ) - cPath := aenv[ nPos ] - cPath := Left( cPath, Rat( '\', cPath ) - 1 ) - Exit - Endif - Next + ENDIF -Return cPath -Function GetVccDir() + ENDIF - Local cPath AS STRING := '' - Local cEnv AS STRING := Gete( "PATH" ) - Local aEnv as array of string := listasarray2( cEnv, ";" ) - Local nPos as numeric + NEXT - For nPos := 1 To Len( aEnv ) - If File( aenv[ nPos ] + '\cl.exe' ) .or. File( Upper( aenv[ nPos ] ) + '\cl.EXE' ) - cPath := aenv[ nPos ] - cPath := Left( cPath, Rat( '\', cPath ) - 1 ) - Exit - Endif - Next + ENDIF -Return cPath + NEXT -Function exten( cExt, nType ) + // For nCounter := 1 To Len( aRet ) + FOR EACH cFile IN aRet - Local aext as array := { 'C', 'c' } - Local nPos as numeric - Local cTemp as string := "" - nPos := Ascan( aext, { | a | a == cExt } ) - If nPos > 0 - If nTYpe == 1 - cTemp := Strtran( cExt, aExt[ nPos ], 'o' ) - Elseif ntype == 2 - cTemp := Strtran( cExt, aExt[ nPos ], 'obj' ) - Endif - Endif -Return ctemp -Function ListAsArray2( cList, cDelimiter ) + xItem := SUBSTR( cFile, RAT( IIF( lLinux, "/", '\' ), cFile ) + 1 ) + nPos := ASCAN( aStru, { | x | x := SUBSTR( x, RAT( IIF( lLinux, "/", '\' ), x ) + 1 ), LEFT( x, AT( ".", x ) ) == LEFT( xitem, AT( ".", xitem ) ) } ) - Local nPos as numeric - Local aList as array := {} // Define an empty array + IF nPos > 0 + ADEL( aStru, nPos ) + ASIZE( aStru, LEN( aStru ) - 1 ) + ENDIF - If cDelimiter = NIL - cDelimiter := "," - Endif - // - Do While ( nPos := At( cDelimiter, cList ) ) != 0 - Aadd( aList, Alltrim( Substr( cList, 1, nPos - 1 ) ) ) // Add a new element - cList := Substr( cList, nPos + 1 ) - Enddo - Aadd( aList, Alltrim( cList ) ) // Add final element - // -Return aList // Return the array + NEXT -Function GetMakeDir() + FOR EACH cFile IN aStru - Local cPath := "" - Local cExe := HB_ARGV( 0 ) + HB_FNAMESPLIT( LEFT( cFile, AT( ' ', cFile ) - 1 ), @cPath, @cItem, @cExt, @cDrive ) + + IF ( cExt == '.C' ) .OR. ( cExt == ".c" ) .OR. ( cExt == '.CPP' ) .OR. ( cExt == ".cpp" ) + AADD( aRet, cFile ) + ENDIF + + NEXT +RETURN aRet + +*------------------------------- +FUNCTION ExtenPrg( cExt, nType ) +*------------------------------- + + LOCAL aExt := { "C", "c" } + LOCAL nPos + LOCAL cTemp := "" + + nPos := ASCAN( aExt, { | a | a == cExt } ) + + IF nPos > 0 + SWITCH nType + CASE 1 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'prg' ) + EXIT + CASE 2 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'prG' ) + EXIT + CASE 3 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'pRg' ) + EXIT + CASE 4 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'Prg' ) + EXIT + CASE 5 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'PRg' ) + EXIT + CASE 6 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'PrG' ) + EXIT + CASE 7 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'PRG' ) + EXIT + END + ENDIF + +RETURN cTemp + +*---------------------------------------- +STATIC FUNCTION GetDirs( cPattern, lGcc ) +*---------------------------------------- + + LOCAL aDir := {} + LOCAL lLinux := AT( 'linux', LOWER( OS() ) ) > 0 .OR. lGcc + + AEVAL( DIRECTORY( cPattern + IIF( lLinux, "*", "*.*" ), "D" ), ; + { | xItem | IIF( xItem[ 5 ] = "D" .AND. ; + ( xItem[ 1 ] != "." .AND. xItem[ 1 ] != ".." ), ; + AADD( aDir, cPattern + xItem[ 1 ] + IIF( lLinux, "/", '\' ) ), ; + ) } ) + +RETURN ( aDir ) + +*----------------------- +FUNCTION GetHarbourDir() +*----------------------- + + LOCAL cPath := '' + LOCAL cEnv := GETE( "PATH" ) + LOCAL lLinux := "LINUX" $ upper(OS()) + LOCAL lUnix := If( "UNIX" $ upper(OS()) .OR. "HP-UX" $ upper(OS()), .T., .F. ) + LOCAL aEnv + LOCAL cCurEnv := "" + LOCAL cBar := iif( lLinux .or. lUnix, "/" , "\" ) + LOCAL HBSTRG := "" + LOCAL cPathUni:= GETE( "PATH_HARBOUR" ) + + hbstrg := IIF ( lLinux .or. lUnix, "harbour" , "harbour.exe" ) - cExe:=strtran(cExe,"/","\") - cPath := Left( cexe, Rat( "\", cexe ) - 1 ) - cPath := Left( cPath, Rat( "\", cPath ) - 1 ) + If lUnix + If cPathUni == Nil + cPathUni := "" + EndIF + cEnv += ":" + cPathUni + EndIf -Return cPath + aEnv := HB_ATokens( cEnv, iif(lLinux .or. lUnix,":",";") ) -Function GetSourceDirMacros() + FOR EACH cCurEnv IN aEnv - Local adirs AS ARRAY - Local lLinux := At( 'linux', lower(Os()) ) > 0 - Local cdir as String := If( llinux, '/' + Curdir() + '/', '\' + Curdir() + '\' ) - Local aStru := { cDir } + IF FILE( cCurEnv + cBar + hbstrg ) .OR. FILE( UPPER( cCurEnv ) + cBar + upper(hbstrg) ) + cPath := cCurEnv + cPath := LEFT( cPath, RAT( cBar, cPath ) - 1 ) + EXIT + ENDIF - Local nCounter as numeric := 0 - Local amacros as Array := {} - While ++ nCounter <= Len( aStru ) - If !Empty( adirs := GetDirs( astru[ nCounter ] ) ) // There are elements! - Aeval( aDirs, { | xItem | Aadd( aStru, xItem ) } ) - Endif - Enddo - For nCounter := 1 To Len( aStru ) - Aadd( amacros, { "SRC" + Strzero( nCounter, 2, 0 ), Strtran( astru[ nCounter ], cDir, '' ), .f. } ) - Next -Return amacros + NEXT -Function hbmake_filedate( cFileName ) +RETURN cPath - Local aFiles := Directory( cFileName ) +*------------------- +FUNCTION GetBccDir() +*------------------- -Return If( Len( aFiles ) == 1, aFiles[ 1, 3 ], Ctod( '' ) ) + LOCAL cPath := '' + LOCAL cEnv := GETE( "PATH" ) + LOCAL aEnv := HB_ATokens( cEnv, ";" ) + LOCAL cCurEnv := "" -Function hbmake_filetime( cFileName ) + FOR EACH cCurEnv IN aEnv - Local aFiles := Directory( cFileName ) + IF FILE( cCurEnv + '\bcc32.exe' ) .OR. FILE( UPPER( cCurEnv ) + '\BCC32.EXE' ) + cPath := cCurEnv + cPath := LEFT( cPath, RAT( '\', cPath ) - 1 ) + EXIT + ENDIF -Return If( Len( aFiles ) == 1, aFiles[ 1, 4 ], '' ) + NEXT -Function TD2JUL( CTIME, DDATE ) +RETURN cPath -Return DDATE - Ctod( '01/01/1900' ) + ( PRB_INT( TTOS( CTIME ) / 100000,, 5 ) ) +*------------------- +FUNCTION GetVccDir() +*------------------- -Function TTOS( CTIME ) + LOCAL cPath := '' + LOCAL cEnv := GETE( "PATH" ) + LOCAL aEnv := HB_ATokens( cEnv, ";" ) + LOCAL cCurEnv := "" -Return ( Val( Substr( CTIME, 7, 2 ) ) ) + ; - ( Val( Substr( CTIME, 4, 2 ) ) * 60 ) + ; - ( Val( Substr( CTIME, 1, 2 ) ) * 3600 ) + FOR EACH cCurEnv IN aEnv -Function PRB_INT( SOMENUMBER, length, NUM_DECIMALS ) + IF FILE( cCurEnv + '\cl.exe' ) .OR. FILE( UPPER( cCurEnv ) + '\cl.EXE' ) + cPath := cCurEnv + cPath := LEFT( cPath, RAT( '\', cPath ) - 1 ) + EXIT + ENDIF - Local NEGATIVE := ( SOMENUMBER < 0 ) - Local SOMESTRING - Local dotat + NEXT - Default NUM_DECIMALS To 0 - Default length To 19 +RETURN cPath - If NEGATIVE - SOMENUMBER := Abs( SOMENUMBER ) - Endif +*-------------------- +FUNCTION GetPoccDir() +*-------------------- - SOMENUMBER += .0000000000000005 + LOCAL cPath := '' + LOCAL cEnv := GETE( "PATH" ) + LOCAL aEnv := HB_ATokens( cEnv, ";" ) + LOCAL cCurEnv := "" - SOMESTRING := Alltrim( Str( SOMENUMBER ) ) + FOR EACH cCurEnv IN aEnv - dotat := At( '.', somestring ) + IF FILE( cCurEnv + '\pocc.exe' ) .OR. FILE( UPPER( cCurEnv ) + '\POCC.EXE' ) + cPath := cCurEnv + cPath := LEFT( cPath, RAT( '\', cPath ) - 1 ) + EXIT + ENDIF - Do Case - Case NUM_DECIMALS == 0 - If dotat > 0 - somestring := Left( somestring, dotat - 1 ) - Endif - Case NUM_DECIMALS > 0 - If dotat > 0 - somestring := Left( somestring, dotat + num_decimals ) - Endif - Endcase + NEXT - If NEGATIVE - SOMESTRING := '-' + SOMESTRING - Endif +RETURN cPath -Return Val( SOMESTRING ) -Function exte( cExt, nType ) +*---------------------------- +FUNCTION Exten( cExt, nType ) +*---------------------------- - Local aext := { 'prg', 'prG', 'pRg', 'Prg', 'PRg', 'PrG', 'PRG' } - Local nPos - Local cTemp := "" - nPos := Ascan( aext, { | a | a == cExt } ) - If nPos > 0 - If nTYpe == 1 - cTemp := Strtran( cExt, aExt[ nPos ], 'c' ) - Elseif ntype == 2 - cTemp := Strtran( cExt, aExt[ nPos ], 'obj' ) - Elseif ntype == 3 - cTemp := Strtran( cExt, aExt[ nPos ], 'o' ) + LOCAL aExt := { 'C', 'c', "CPP", "cpp" } + LOCAL nPos + LOCAL cTemp := "" - Endif - Endif -Return ctemp -Procedure ATTENTION( CSTRING, NLINENUM, CCOLOR ) + nPos := ASCAN( aExt, { | a | a == cExt } ) + IF nPos > 0 - Local COLDCOLOR + SWITCH nType + CASE 1 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'o' ) + EXIT - Default NLINENUM To 24 - Default CCOLOR To 'GR+/R' + CASE 2 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'obj' ) + EXIT - COLDCOLOR := Setcolor( CCOLOR ) + END - CSTRING := ' ' + Alltrim( CSTRING ) + ' ' + ENDIF - Devpos( NLINENUM, c( CSTRING ) ) +RETURN cTemp - Devout( CSTRING ) +*-------------------- +FUNCTION GetMakeDir() +*-------------------- - Setcolor( COLDCOLOR ) + LOCAL cPath := "" + LOCAL cExe := HB_ARGV( 0 ) -Return + cExe := STRTRAN( cExe, "/", "\" ) + cPath := LEFT( cexe, RAT( "\", cexe ) - 1 ) + cPath := LEFT( cPath, RAT( "\", cPath ) - 1 ) -Function c( CSTRING ) +RETURN cPath -Return Max( ( Maxcol() / 2 ) - Int( Len( CSTRING ) / 2 ), 0 ) +*---------------------------- +FUNCTION GetSourceDirMacros() +*---------------------------- -Function ReadLN( leof ) + LOCAL aDirs + LOCAL lLinux := AT( 'linux', LOWER( OS() ) ) > 0 + LOCAL cDir := IIF( lLinux, '/' + CURDIR() + '/', '\' + CURDIR() + '\' ) + LOCAL aStru := { cDir } - Local cBuffer := "" - cBuffer := FT_FREADLN() - cBuffer := Strtran( cBuffer, Chr( 13 ), '' ) - cBuffer := Strtran( cBuffer, Chr( 10 ), '' ) - FT_FSKIP( 1 ) - leof := ft_FEOF() -Return cBuffer + LOCAL nCounter := 0 + LOCAL aMacros := {} -Function GetinstaledLibs( clibs, lGcc ) + WHILE ++ nCounter <= LEN( aStru ) - Local adeflib := { 'lang' + If( lgcc, '.a', '.lib' ), 'vm' + If( lgcc, '.a', '.lib' ), 'rtl' + If( lgcc, '.a', '.lib' ), 'rdd' + If( lgcc, '.a', '.lib' ), 'macro' + If( lgcc, '.a', '.lib' ), 'pp' + If( lgcc, '.a', '.lib' ), 'dbfntx' + If( lgcc, '.a', '.lib' ), 'dbfcdx' + If( lgcc, '.a', '.lib' ), 'common' + If( lgcc, '.a', '.lib' ), 'gtwin' + If( lgcc, '.a', '.lib' ), 'debug' + If( lgcc, '.a', '.lib' ), 'gtpca' + If( lgcc, '.a', '.lib' ), 'gtdos' + If( lgcc, '.a', '.lib' ), 'gtsln' + If( lgcc, '.a', '.lib' ), 'gtstd' + If( lgcc, '.a', '.lib' ), 'zlib1' + If( lgcc, '.a', '.lib' ), 'ziparchive' + If( lgcc, '.a', '.lib' ), 'rddads' + If( lgcc, '.a', '.lib' ), 'ace32' + If( lgcc, '.a', '.lib' ), 'libnf' + If( lgcc, '.a', '.lib' ), 'libct' + If( lgcc, '.a', '.lib' ), 'htmllib' + If( lgcc, '.a', '.lib' ), 'libgt' + If( lgcc, '.a', '.lib' ), 'libmisc' + If( lgcc, '.a', '.lib' ), 'mysql' + If( lgcc, '.a', '.lib' ), 'libmysql' + If( lgcc, '.a', '.lib' ), 'mysqlclient' + If( lgcc, '.a', '.lib' ), 'samples' + If( lgcc, '.a', '.lib' ), 'pdflib' + If( lgcc, '.a', '.lib' ), 'nulsys' + If( lgcc, '.a', '.lib' ), 'gtcgi' + If( lgcc, '.a', '.lib' ) } - Local aReturnLibs := {} - Local aLibs := Directory( clibs ) - Local nPos - Local nCount - Local citem - if lgcc - aeval(aLibs,{|x,y| citem:=x[1] ,if(left(citem,3)=="lib", alibs[y,1]:=substr(cItem,4),)}) - endif + IF ! EMPTY( aDirs := GetDirs( aStru[ nCounter ], lLinux ) ) // There are elements! + AEVAL( aDirs, { | xItem | AADD( aStru, xItem ) } ) + ENDIF - For ncount := 1 To Len( alibs ) - citem := Lower( alibs[ ncount, 1 ] ) - npos := Ascan( adeflib, { | a | Lower( a ) == citem } ) - If npos == 0 - Aadd( aReturnLibs, alibs[ ncount, 1 ] ) - Endif - Next - -Return aReturnLibs -Function Getlibs( lgcc ,cDir) - Local lLinux:=at('linux',lower(os()))>0 - Local ainstaledlibs := Getinstaledlibs( If( !llinux, if(!lgcc, cDir+"\*.lib",cDir+"\*.a") , '/usr/lib/harbour/*.a' ),lGcc ) - Local aLibsDesc := { { "Harbour Ct3 library - Libct", 'ct' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Misc library - Libmisc", 'misc' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour html library - Htmllib", 'html' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Nanfor library - Libnf", 'nf' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Gt library - Libgt", 'nf' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Zip library Zlib1", 'zlib1.lib ziparchive' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Hbole library Hbole", 'hbole' + If( lgcc, '.a', '.lib' ) + ' ole2' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Mysql library - MySql", 'mysql' + If( lgcc, '.a', '.lib' ) + ' libmysql' + If( lgcc, '.a', '.lib' ) + ' mysqlclient' + If( lgcc, '.a', '.lib' ) }, ; - { "Harbour Samples library - Samples", 'samples' + If( lgcc, '.a', '.lib' ) } } - Aeval( ainstaledlibs, { | x | Aadd( aLibsDesc, { "User - " + x +" Library", x } ) } ) -Return aLibsDesc + ENDDO -*+ EOF: HBMUTILS.PRG + FOR nCounter := 1 TO LEN( aStru ) + AADD( aMacros, { "SRC" + STRZERO( nCounter, 2, 0 ), STRTRAN( aStru[ nCounter ], cDir, '' ), .f. } ) + NEXT + +RETURN aMacros + +*------------------------------------ +FUNCTION HbMake_FileDate( cFileName ) +*------------------------------------ + + LOCAL aFiles := DIRECTORY( cFileName ) + +RETURN IIF( LEN( aFiles ) == 1, aFiles[ 1, 3 ], CTOD( '' ) ) + +*------------------------------------ +FUNCTION HbMake_FileTime( cFileName ) +*------------------------------------ + + LOCAL aFiles := DIRECTORY( cFileName ) + +RETURN IIF( LEN( aFiles ) == 1, aFiles[ 1, 4 ], '' ) + +*------------------------------ +FUNCTION TD2JUL( CTIME, DDATE ) +*------------------------------ +RETURN DDATE - CTOD( '01/01/1900' ) + ( PRB_INT( TTOS( CTIME ) / 100000,, 5 ) ) + +*--------------------- +STATIC FUNCTION TTOS( CTIME ) +*--------------------- + +RETURN ( VAL( SUBSTR( CTIME, 7, 2 ) ) ) + ; + ( VAL( SUBSTR( CTIME, 4, 2 ) ) * 60 ) + ; + ( VAL( SUBSTR( CTIME, 1, 2 ) ) * 3600 ) + +*--------------------------------------------------- +FUNCTION PRB_INT( SOMENUMBER, length, NUM_DECIMALS ) +*--------------------------------------------------- + + LOCAL NEGATIVE := ( SOMENUMBER < 0 ) + LOCAL SOMESTRING + LOCAL dotat + + DEFAULT NUM_DECIMALS TO 0 + DEFAULT length TO 19 + + IF NEGATIVE + SOMENUMBER := ABS( SOMENUMBER ) + ENDIF + + SOMENUMBER += .0000000000000005 + + SOMESTRING := ALLTRIM( STR( SOMENUMBER ) ) + + dotat := AT( '.', somestring ) + + DO CASE + CASE NUM_DECIMALS == 0 + IF dotat > 0 + somestring := LEFT( somestring, dotat - 1 ) + ENDIF + + CASE NUM_DECIMALS > 0 + IF dotat > 0 + somestring := LEFT( somestring, dotat + num_decimals ) + ENDIF + + ENDCASE + + IF NEGATIVE + SOMESTRING := '-' + SOMESTRING + ENDIF + +RETURN VAL( SOMESTRING ) + +*--------------------------- +FUNCTION Exte( cExt, nType ) +*--------------------------- + + LOCAL aExt := { 'prg', 'prG', 'pRg', 'Prg', 'PRg', 'PrG', 'PRG' } + LOCAL nPos + LOCAL cTemp := "" + + nPos := ASCAN( aExt, { | a | a == cExt } ) + IF nPos > 0 + IF nType == 1 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'c' ) + ELSEIF nType == 2 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'obj' ) + ELSEIF nType == 3 + cTemp := STRTRAN( cExt, aExt[ nPos ], 'o' ) + ENDIF + + ENDIF + +RETURN cTemp + +*----------------------------------------------- +PROCEDURE ATTENTION( CSTRING, NLINENUM, CCOLOR ) +*----------------------------------------------- + + LOCAL COLDCOLOR + + DEFAULT NLINENUM TO 24 + DEFAULT CCOLOR TO 'GR+/R' + + COLDCOLOR := SETCOLOR( CCOLOR ) + + CSTRING := ' ' + ALLTRIM( CSTRING ) + ' ' + + DEVPOS( NLINENUM, c( CSTRING ) ) + + DEVOUT( CSTRING ) + + SETCOLOR( COLDCOLOR ) + +RETURN + +*-------------------- +FUNCTION c( CSTRING ) +*-------------------- + +RETURN MAX( ( MAXCOL() / 2 ) - INT( LEN( CSTRING ) / 2 ), 0 ) + +*---------------------- +FUNCTION ReadLN( lEof ) +*---------------------- + + LOCAL cBuffer := "" + cBuffer := FT_FREADLN() + cBuffer := STRTRAN( cBuffer, CHR( 13 ), '' ) + cBuffer := STRTRAN( cBuffer, CHR( 10 ), '' ) + FT_FSKIP( 1 ) + lEof := ft_FEOF() + +RETURN cBuffer + +*-------------------------------------- +FUNCTION GetInstaledLibs( clibs, lGcc ) +*-------------------------------------- + + LOCAL cSuffix := IIF( lGCC, ".a", ".lib" ) + LOCAL aReturnLibs := {} + LOCAL aLibs := DIRECTORY( clibs ) + LOCAL nPos + LOCAL nCount + LOCAL cItem + LOCAL aDefLib := {} + + + aadd(aDefLib,'ace32'+ cSuffix) + aadd(aDefLib,'bcc640'+ cSuffix) + aadd(aDefLib,'bcc640mt'+ cSuffix) + aadd(aDefLib,'codepage'+ cSuffix) + aadd(aDefLib,'common'+ cSuffix) + aadd(aDefLib,'ct'+cSuffix) + aadd(aDefLib,'ctmt'+cSuffix) + aadd(aDefLib,'dbfdbt'+ cSuffix) + aadd(aDefLib,'dbfdbtmt'+ cSuffix) + aadd(aDefLib,'dbfcdx'+ cSuffix) + aadd(aDefLib,'dbfcdxmt'+ cSuffix) + aadd(aDefLib,'dbffpt'+ cSuffix) + aadd(aDefLib,'dbffptmt'+ cSuffix) + aadd(aDefLib,'dbfntx'+ cSuffix) + aadd(aDefLib,'dbfntxmt'+ cSuffix) + aadd(aDefLib,'debug'+ cSuffix) + aadd(aDefLib,'gtcgi'+ cSuffix) + aadd(aDefLib,'gtdos'+ cSuffix) + aadd(aDefLib,'gtpca'+ cSuffix) + aadd(aDefLib,'gtnul'+ cSuffix) + aadd(aDefLib,'gtsln'+ cSuffix) + aadd(aDefLib,'gtstd'+ cSuffix) + aadd(aDefLib,'gtwin'+ cSuffix) + aadd(aDefLib,'gtwvt'+ cSuffix) + aadd(aDefLib,'hbct'+cSuffix) + aadd(aDefLib,'hbctmt'+cSuffix) + aadd(aDefLib,'hbodbc'+ cSuffix) + aadd(aDefLib,'hbodbcmt'+ cSuffix) + aadd(aDefLib,'hbpg'+ cSuffix) + aadd(aDefLib,'hbtip'+cSuffix) + aadd(aDefLib,'hbtipmt'+cSuffix) + aadd(aDefLib,'hbzip'+ cSuffix) + aadd(aDefLib,'html'+ cSuffix) + aadd(aDefLib,'lang'+ cSuffix) + aadd(aDefLib,'libmisc'+ cSuffix) + aadd(aDefLib,'libnf'+ cSuffix) + aadd(aDefLib,'libgt'+ cSuffix) + aadd(aDefLib,'libmysql'+ cSuffix) + aadd(aDefLib,'macro'+ cSuffix) + aadd(aDefLib,'macromt'+ cSuffix) + aadd(aDefLib,'mysql'+ cSuffix) + aadd(aDefLib,'mysqlclient'+ cSuffix) + aadd(aDefLib,'nulsys'+ cSuffix) + aadd(aDefLib,'pdflib'+ cSuffix) + aadd(aDefLib,'optcon'+ cSuffix) + aadd(aDefLib,'optconmt'+ cSuffix) + aadd(aDefLib,'optgui'+ cSuffix) + aadd(aDefLib,'optguimt'+ cSuffix) + aadd(aDefLib,'pp'+ cSuffix) + aadd(aDefLib,'ppmt'+ cSuffix) + aadd(aDefLib,'rdd'+ cSuffix) + aadd(aDefLib,'rddads'+ cSuffix) + aadd(aDefLib,'rddmt'+ cSuffix) + aadd(aDefLib,'rtl'+ cSuffix) + aadd(aDefLib,'rtlmt'+ cSuffix) + aadd(aDefLib,'samples'+ cSuffix) + aadd(aDefLib,'samplesmt'+ cSuffix) + aadd(aDefLib,'tip'+cSuffix) + aadd(aDefLib,'tipmt'+cSuffix) + aadd(aDefLib,'vm'+ cSuffix) + aadd(aDefLib,'vmmt'+ cSuffix) + aadd(aDefLib,'ziparchive'+ cSuffix) + + + IF lGcc + AEval( aLibs, { | x, y | cItem := x[1], IIF( Left( cItem, 3 ) == "lib", aLibs[ y, 1 ] := SubStr( cItem, 4 ), ) } ) + ENDIF + + FOR nCount := 1 TO LEN( aLibs ) + + cItem := Lower( aLibs[ nCount, 1 ] ) + + nPos := AScan( aDefLib, { | a | Lower( a ) == cItem } ) + IF nPos == 0 + AAdd( aReturnLibs, aLibs[ nCount, 1 ] ) + ENDIF + + NEXT + +RETURN aReturnLibs + +*----------------------------- +FUNCTION GetLibs( lGcc, cDir ) +*----------------------------- + + LOCAL lLinux := AT( 'linux', LOWER( OS() ) ) > 0 + LOCAL cEnv := GETENV( "HB_LIB_INSTALL" ) + LOCAL aInstaledLibs := GetInstaledLibs( IIF( ! lLinux, IIF( ! lGcc, cDir + "\*.lib", cDir + "\*.a" ), '/usr/lib/harbour/*.a' ), lGcc ) + LOCAL cExt := iif(lGcc,".a",".lib") + + + LOCAL aLibsDesc := { { "Harbour Misc lib - "+iif( lGcc, "misc.a", "libmisc.lib" ) , iif( lGcc, 'misc.a', 'libmisc.lib' ) },; + { "Harbour Html lib - html" + cExt , 'html' +cExt },; + { "Harbour NanFor lib - "+iif( lGcc, "nf.a", "libnf.lib" ) , iif( lGcc, 'nf.a', 'libnf.lib' ) },; + { "Harbour GT lib - gt"+cExt , 'gt' + cExt },; + { "Harbour Zip lib - "+iif( IsWin(),"hbzip","ziparchive")+cExt , IIF( ISWIN(),'hbzip','ziparchive') + cExt + iif( lLinux, ' stdc++.a z.a', ' ' ) },; + { "Harbour Ole lib - hbole"+ cExt , 'hbole' + cExt + ' ole2' + cExt },; + { "Harbour MySql lib - mysql"+ cExt , 'mysql' + cExt },; + { "Harbour PostGreSql lib - libhbpg"+cExt , 'libhbpg' + cExt },; + { "Harbour Samples lib - samples"+cExt , 'samples' + cExt } } + + + AEVAL( aInstaledLibs, { | x | AAdd( aLibsDesc, { padr("Harbour contrib",20)+"lib - " + padr(x,15), x } ) } ) + +RETURN aLibsDesc + +*----------------------------------------- FUNCTION DIR_MULTI( cFileMaskList, cAttr ) - LOCAL aList := ListasArray2( cFileMaskList, "|" ) - AEval( aList, {|tmp, tmp1| aList[ tmp1 ] := DIRECTORY( tmp, cAttr ) }) - RETURN ArrayAJoin(alist) -FUNCTION ArrayAJoin( array ) - LOCAL tmp - LOCAL nLenArray := Len( array ) - LOCAL nLen - LOCAL nPos := Len( array[ 1 ] ) + 1 +*----------------------------------------- - nLen := 0 - FOR tmp := 1 TO nLenArray - nLen += Len( array[ tmp ] ) - NEXT + LOCAL aList := listasarray2( cFileMaskList, "|" ) + AEVAL( aList, { | tmp, tmp1 | aList[ tmp1 ] := DIRECTORY( tmp, cAttr ) } ) - ASize( array[ 1 ], nLen ) +RETURN ArrayAJoin( alist ) - FOR tmp := 2 TO nLenArray - ACopy( array[ tmp ], array[ 1 ], , , nPos ) - nPos += Len( array[ tmp ] ) - NEXT +*---------------------------- +FUNCTION ArrayAJoin( aArray ) +*---------------------------- - RETURN array[ 1 ] + LOCAL tmp + LOCAL nLenArray := LEN( aArray ) + LOCAL nLen + LOCAL nPos := LEN( aArray[ 1 ] ) + 1 + + nLen := 0 + + FOR tmp := 1 TO nLenArray + nLen += LEN( aArray[ tmp ] ) + NEXT + + ASIZE( aArray[ 1 ], nLen ) + + FOR tmp := 2 TO nLenArray + ACOPY( aArray[ tmp ], aArray[ 1 ],,, nPos ) + nPos += LEN( aArray[ tmp ] ) + NEXT +RETURN aArray[ 1 ] + +*----------------------------------------- +FUNCTION ListAsArray2( cList, cDelimiter ) +*----------------------------------------- + + LOCAL nPos + LOCAL aList := {} // Define an empty array + + IF cDelimiter = NIL + cDelimiter := "," + ENDIF + // + DO WHILE ( nPos := AT( cDelimiter, cList ) ) != 0 + AADD( aList, ALLTRIM( SUBSTR( cList, 1, nPos - 1 ) ) ) // Add a new element + cList := SUBSTR( cList, nPos + 1 ) + + ENDDO + AADD( aList, ALLTRIM( cList ) ) // Add final element + // +RETURN aList // Return the array + +*-------------------- +FUNCTION CreateLink() +*-------------------- + + LOCAL nHandle := FCreate("hbtemp.c") + + FWrite( nHandle, '#include "hbapi.h"' + HB_OsNewLine()) + FWrite( nHandle, 'extern HB_FUNC( HB_GT_CRS );' + HB_OsNewLine()) + FWrite( nHandle, 'void hb_lnk_ForceLink_build( void )' + HB_OsNewLine()) + FWrite( nHandle, '{' + HB_OsNewLine()) + FWrite( nHandle, ' HB_FUNCNAME( HB_GT_CRS )();' + HB_OsNewLine()) + FWrite( nHandle, '}' + HB_OsNewLine()) + FClose( nHandle ) + + +RETURN NIL + +*---------------------- +STATIC FUNCTION ISWIN() +*----------------------- +RETURN "WINDOWS" $ Upper( OS() ) + +// EOF: HBMUTILS.PRG diff --git a/harbour/utils/hbmake/pickarry.prg b/harbour/utils/hbmake/pickarry.prg index 88f0c17923..c552763d76 100644 --- a/harbour/utils/hbmake/pickarry.prg +++ b/harbour/utils/hbmake/pickarry.prg @@ -1,143 +1,264 @@ /* * $Id$ */ + * xHarbour Project source code: + * hbmake.prg xHarbour make utility main file + * + * Copyright 2000,2001,2002,2003,2004 Luiz Rafael Culik + * www - http://www.xharbour.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ -*+²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² -*+ -*+ Source Module => D:\SRC\PBMAKE\PICKARRY.PRG -*+ -*+ PBMake is a Clipper, C, ASM, Xbase++ make engine. -*+ -*+ Copyright(C) 1996-1999 by Phil Barnett. -*+ -*+ This program is free software; you can redistribute it and/or modify it -*+ under the terms of the GNU General Public License as published by the -*+ Free Software Foundation; either version 2 of the License, or (at your -*+ option) any later version. -*+ -*+ This program is distributed in the hope that it will be useful, but -*+ WITHOUT ANY WARRANTY; without even the implied warranty of -*+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -*+ General Public License for more details. -*+ -*+ You should have received a copy of the GNU General Public License along -*+ with this program; if not, write to the Free Software Foundation, Inc., -*+ 675 Mass Ave, Cambridge, MA 02139, USA. -*+ -*+ You can contact me at: -*+ -*+ Phil Barnett -*+ Box 944 -*+ Plymouth, Florida 32768 -*+ -*+ or -*+ -*+ philb@iag.net -*+ -*+ -*+ Functions: Function PICKARRY() -*+ Function Keys() -*+ -*+ Reformatted by Click! 2.03 on Mar-30-1999 at 11:19 pm -*+ -*+²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² -static someitems +STATIC someitems +STATIC lAdd := .F. +STATIC cMarkChar := '*' // 'û' // character showed when is pressed to select prgs/libs. -*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± -*+ -*+ Function PICKARRY() -*+ -*+ Called from ( makelink.prg ) 1 - function makelink() -*+ -*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± -*+ -function PICKARRY( T, L, b, r, IN_ARRAY, OUT_ARRAY ) +#include "common.ch" +#include "achoice.ch" -local nChoice := 1 -local x -local NEW_ARRAY := {} -local NUM_ELEMS := len( IN_ARRAY ) -local PAD_LEN := ( r - 1 ) - ( L + 1 ) -local lIsChecked -someitems := 0 +FUNCTION PICKARRY( T, L, b, r, IN_ARRAY, OUT_ARRAY, aDefault, lAllowAll, cTitle, lLib ) -putscreen() +LOCAL nChoice := 1 +LOCAL x +LOCAL NEW_ARRAY := {} +LOCAL NUM_ELEMS := Len( IN_ARRAY ) +LOCAL PAD_LEN := ( r - 1 ) - ( L + 1 ) +LOCAL lIsChecked := .f. +LOCAL aItems := IN_ARRAY +LOCAL aTemp +LOCAL cItem +LOCAL cItem1 +LOCAL cTemp +LOCAL cOldColor := Setcolor() -@ T - 1, L - 1 clear to b + 1, r + 1 -@ T - 1, L - 1 to b + 1, r + 1 double +DEFAULT lAllowAll TO .F. +DEFAULT cTitle to "" +DEFAULT lLib to .F. -for x := 1 to NUM_ELEMS - IN_ARRAY[ X ] := padr( ' ' + IN_ARRAY[ X ], PAD_LEN ) - OUT_ARRAY[ X ] := ' ' + OUT_ARRAY[ X ] -next -do while nChoice != 0 - nChoice := achoice( T, L , b , r , IN_ARRAY, , 'keys' , nChoice, 1 ) + SOMEITEMS := 0 - if nChoice > 0 + PutScreen() - lIsChecked := substr( IN_ARRAY[ nChoice ], 2, 1 ) == 'û' + Setcolor( 'gr+/rb,b+/w,w+/b,w/b+,w/b,w+/b' ) - IN_ARRAY[ nChoice ] := stuff( IN_ARRAY[ nChoice ], 2, 1, if( lIsChecked, ' ', 'û' ) ) - OUT_ARRAY[ nChoice ] := stuff( OUT_ARRAY[ nChoice ], 1, 1, if( lIsChecked, ' ', 'û' ) ) + @ T - 2, L - 1 CLEAR TO b + 1, r + 1 + @ T - 2, L say cTitle + @ T - 1, L - 1 TO b + 1, r + 1 double - if lIsChecked - SOMEITEMS -- - else - SOMEITEMS ++ - endif + FOR x := 1 TO NUM_ELEMS + IN_ARRAY[ X ] := Padr( ' ' + IN_ARRAY[ X ], PAD_LEN ) + OUT_ARRAY[ X ] := ' ' + OUT_ARRAY[ X ] + NEXT - nChoice ++ + //aTemp :=GetFiles(aitems) - endif + IF Len( aDefault ) > 0 -enddo -for x := 1 to NUM_ELEMS - if left( OUT_ARRAY[ X ], 1 ) == 'û' - aadd( NEW_ARRAY, substr( OUT_ARRAY[ X ], 2 ) ) - endif - IN_ARRAY[ X ] := substr( IN_ARRAY[ X ], 4 ) -next + FOR EACH cItem IN aDefault -asize( OUT_ARRAY, len( NEW_ARRAY ) ) -acopy( NEW_ARRAY, OUT_ARRAY ) + if !lLib + x := AScan( IN_ARRAY, { | a, y | SubStr( a, 4, At(' ', alltrim(a) ) - 1 ) == cItem } ) + else + x := AScan( IN_ARRAY, { | a, y | alltrim(cItem) IN a } ) + endif -getscreen() + IF x != 0 -return len( NEW_ARRAY ) + IN_ARRAY[ x ] := Stuff( IN_ARRAY[ x ], 2, 1, If( lIsChecked, ' ', cMarkChar ) ) + OUT_ARRAY[ x ] := Stuff( OUT_ARRAY[ x ], 1, 1, If( lIsChecked, ' ', cMarkChar ) ) + SOMEITEMS ++ -*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± -*+ -*+ Function Keys() -*+ -*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± -*+ -function Keys( MODE ) + ELSE -local RETVAL := 2 -local THEKEY := lastkey() + cItem := SubStr( cItem, Rat( '\', cItem ) - 1 ) -if MODE = 1 - keyboard chr( 30 ) -elseif MODE = 2 - keyboard chr( 31 ) -elseif MODE = 3 - if THEKEY = 32 - RETVAL := 1 - elseif THEKEY = 27 - RETVAL := 0 - elseif THEKEY = 13 .and. SOMEITEMS < 1 - RETVAL := 1 - keyboard chr( 13 ) - elseif THEKEY = 13 - keyboard chr( 24 ) - RETVAL := 0 - endif -endif + if !lLib + x := AScan( aTemp, { | a, y | SubStr( a, 4, At( ' ', a ) - 1 ) == cItem } ) + else + x := AScan( IN_ARRAY, { | a, y | alltrim(cItem) IN a } ) + endif -return ( RETVAL ) + IF x != 0 + IN_ARRAY[ x ] := Stuff( IN_ARRAY[ x ], 2, 1, If( lIsChecked, ' ', cMarkChar ) ) + OUT_ARRAY[ x ] := Stuff( OUT_ARRAY[ x ], 1, 1, If( lIsChecked, ' ', cMarkChar ) ) + SOMEITEMS ++ + ENDIF -*+ EOF: PICKARRY.PRG + ENDIF + NEXT + ENDIF + + + Clear TypeAhead + + + WHILE nChoice != 0 + + @T,L CLEAR TO b, r + + nChoice := AChoice( T, L, b, r, IN_ARRAY,, 'keys', nChoice, 1 ) + + IF nChoice > 0 + + if lAllowAll + + if lAdd // only if F5 was pressed + + For nChoice := 1 to NUM_ELEMS + + lIsChecked := Substr( IN_ARRAY[ nChoice ], 2, 1 ) == cMarkChar + + IN_ARRAY[ nChoice ] := Stuff( IN_ARRAY[ nChoice ], 2, 1, If( lIsChecked, ' ', cMarkChar ) ) + OUT_ARRAY[ nChoice ] := Stuff( OUT_ARRAY[ nChoice ], 1, 1, If( lIsChecked, ' ', cMarkChar ) ) + + IF lIsChecked + SOMEITEMS -- + ELSE + SOMEITEMS ++ + ENDIF + lAdd := .F. + Next + + else + + lIsChecked := Substr( IN_ARRAY[ nChoice ], 2, 1 ) == cMarkChar + + IN_ARRAY[ nChoice ] := Stuff( IN_ARRAY[ nChoice ], 2, 1, If( lIsChecked, ' ', cMarkChar ) ) + OUT_ARRAY[ nChoice ] := Stuff( OUT_ARRAY[ nChoice ], 1, 1, If( lIsChecked, ' ', cMarkChar ) ) + + IF lIsChecked + SOMEITEMS -- + ELSE + SOMEITEMS ++ + ENDIF + + nChoice ++ + + endif + + else + + lIsChecked := Substr( IN_ARRAY[ nChoice ], 2, 1 ) == cMarkChar + + IN_ARRAY[ nChoice ] := Stuff( IN_ARRAY[ nChoice ], 2, 1, If( lIsChecked, ' ', cMarkChar ) ) + OUT_ARRAY[ nChoice ] := Stuff( OUT_ARRAY[ nChoice ], 1, 1, If( lIsChecked, ' ', cMarkChar ) ) + + IF lIsChecked + SOMEITEMS -- + ELSE + SOMEITEMS ++ + ENDIF + + endif + + ENDIF + + ENDDO + + FOR x := 1 TO NUM_ELEMS + IF Left( OUT_ARRAY[ X ], 1 ) == cMarkChar + AAdd( NEW_ARRAY, Substr( OUT_ARRAY[ X ], 2 ) ) + ENDIF + IN_ARRAY[ X ] := Substr( IN_ARRAY[ X ], 4 ) + NEXT + + ASize( OUT_ARRAY, Len( NEW_ARRAY ) ) + ACopy( NEW_ARRAY, OUT_ARRAY ) + + GetScreen() + SetColor( coldColor ) + +RETURN Len( NEW_ARRAY ) + +*-------------------- +FUNCTION Keys( MODE ) +*-------------------- +LOCAL RETVAL := AC_CONT +LOCAL THEKEY := Lastkey() + + + IF MODE = AC_HITTOP + KEYBOARD Chr( 30 ) + + ELSEIF MODE = AC_HITBOTTOM + KEYBOARD Chr( 31 ) + + ELSEIF MODE = AC_EXCEPT + + IF THEKEY = 32 // space bar to select/unselect + RETVAL := AC_SELECT + ELSEIF THEKEY == -4 // F5 (select all itens) + lAdd := !lAdd + RETVAL := AC_SELECT + ELSEIF THEKEY = 27 + RETVAL := AC_ABORT + ELSEIF THEKEY = 13 .AND. SOMEITEMS < 1 + RETVAL := AC_ABORT + KEYBOARD CHR( 13 ) + ELSEIF THEKEY = 13 + KEYBOARD CHR( 24 ) + RETVAL := AC_ABORT + ENDIF + + ENDIF + +RETURN ( RETVAL ) + +*------------------------------ +STATIC FUNCTION GetFiles( aIn ) +*------------------------------- + +LOCAL aRet := {} +LOCAL cItem := "" + + FOR EACH cItem IN aIn + + cItem := Substr( cItem, 1, At( ' ', cItem ) - 1 ) + + AAdd( aRet, Substr( cItem, 1, At( ' ', cItem ) ) ) + NEXT + +RETURN aRet diff --git a/harbour/utils/hbmake/radios.prg b/harbour/utils/hbmake/radios.prg index 0d6b3db872..c79f7b8558 100644 --- a/harbour/utils/hbmake/radios.prg +++ b/harbour/utils/hbmake/radios.prg @@ -1,8 +1,6 @@ - /* * $Id$ */ - /* * Harbour Project source code: * radios.Prg radios gets for hbmake @@ -64,8 +62,7 @@ LOCAL nRow := Row(), nCol := Col() LOCAL nGets := Len(aChoices) LOCAL nGet LOCAL nStartGet := Len(aGetList) + 1 - - default bvalid to {||.t.} + default bvalid to {||.t.} // For each element in aChoices FOR nGet := 1 To nGets @@ -78,8 +75,8 @@ LOCAL nStartGet := Len(aGetList) + 1 oGet := GetNew(nRow++,ncol+4,t(aChoices[nGet]),cvar) Aadd(aGetList, oGet) - oGet:cargo := Array(RADIO_NUM_IVARS) - oGet:PostBlock := bValid + oGet:cargo := Array(RADIO_NUM_IVARS) + oGet:PostBlock:=bValid oGet:radioGsb := bVar oGet:radioGets := Array(nGets) diff --git a/harbour/utils/hbmake/readline.c b/harbour/utils/hbmake/readline.c new file mode 100644 index 0000000000..863fc99927 --- /dev/null +++ b/harbour/utils/hbmake/readline.c @@ -0,0 +1,251 @@ +/* + * $Id$ + */ + +/* + * xHarbour Project source code: + * Text file reading functions + * + * Copyright 2003 Marcelo Lombardo - lombardo@uol.com.br + * http://www.xharbour.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include + +#include "hbapi.h" +#include "hbapifs.h" +#include "hb_io.h" +#include "hbset.h" +#include "hbapiitm.h" +#include "hbapierr.h" + +#define READING_BLOCK 4096 + +BYTE * hb_fsReadLine( FHANDLE hFileHandle, LONG *plBuffLen, char ** Term, int * iTermSizes, USHORT iTerms, BOOL * bFound, BOOL *bEOF ) +{ + USHORT uiPosTerm = 0, iPos, uiPosition; + USHORT nTries; + LONG lRead = 0, lOffset, lSize; + BYTE * pBuff; + + HB_TRACE(HB_TR_DEBUG, ("hb_fsReadLine(%p, %ld, %p, %p, %hu, %i, %i)", hFileHandle, *plBuffLen, Term, iTermSizes, iTerms, *bFound, *bEOF )); + + *bFound = 0; + *bEOF = 0; + nTries = 0; + lOffset = 0; + lSize = *plBuffLen; + + if( *plBuffLen < 10 ) + { + *plBuffLen = READING_BLOCK; + } + + pBuff = (BYTE*) hb_xgrab( *plBuffLen ); + + do + { + if(nTries>0) + { + /* pBuff can be enlarged to hold the line as needed.. */ + lSize = ( *plBuffLen * ( nTries + 1 ) ) + 1; + pBuff = (BYTE *) hb_xrealloc( pBuff, lSize ); + lOffset += lRead; + } + + /* read from file */ + lRead = hb_fsReadLarge( hFileHandle, pBuff + lOffset, lSize-lOffset ); + + /* scan the read buffer */ + + if (lRead>0) + { + for( iPos=0; iPos 0 ); + + return( pBuff ); +} + +/* PRG level fReadLine( , <@buffer>, [], [] ) */ + +HB_FUNC( HB_FREADLINE ) +{ + PHB_ITEM pTerm1; + PHB_ITEM Opt = hb_itemNew( NULL ); + FHANDLE hFileHandle = (FHANDLE) hb_parnl( 1 ); + char ** Term; + BYTE * pBuffer; + int * iTermSizes; + LONG lSize = hb_parnl(4); + USHORT i, iTerms; + BOOL bFound, bEOF; + + if( ( !ISBYREF( 2 ) ) || ( !ISNUM( 1 ) ) ) + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, "FREADLINE", 4, hb_paramError(1), hb_paramError(2), hb_paramError(3), hb_paramError(4) ); + return; + } + + if( ISARRAY( 3 ) || ISCHAR( 3 ) ) + { + if( ISARRAY( 3 ) ) + { + pTerm1 = hb_param( 3, HB_IT_ARRAY ); + iTerms = (int) hb_arrayLen(pTerm1); + + if( iTerms <= 0 ) + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, "FREADLINE", 4, + hb_paramError(1), hb_paramError(2), + hb_paramError(3), hb_paramError(4) ); + return; + } + + Term = (char**) hb_xgrab( sizeof(char*) * iTerms ); + iTermSizes = (int *) hb_xgrab( sizeof(int) * iTerms ); + + hb_itemClear( Opt ); + + for(i=0;i + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + */ + +#include "hbclass.ch" +#include "common.ch" + +#define EOL hb_osnewline() +#define CRLF hb_osnewline() +Static lEof := .F. + +*------------ +CLASS THBMAKE +*------------ + +EXPORT: +DATA aDefines Init {} +DATA aBuildOrder Init {} +DATA aCommands Init {} +DATA aMacros Init {} +DATA aPrgs Init {} +DATA aExtLibs Init {} +DATA aCs Init {} +DATA aObjs Init {} +DATA aObjsc Init {} +DATA aRes Init {} +DATA nLinkHandle +DATA cLinkcomm Init '' +DATA lCompress Init .F. +DATA lForce Init .F. +DATA lLinux Init .F. +DATA szProject Init "" +DATA lLibrary Init .F. +DATA lInstallLib Init .F. +DATA lIgnoreErrors Init .F. +DATA lExtended Init .T. +DATA lOs2 Init .F. +DATA lRecurse Init .F. +DATA aDir +DATA lEditMode Init .F. +DATA aDir +DATA aLangMessages init {} +DATA cDefLang +DATA lFwh init .F. +DATA lxFwh init .F. +DATA lCw init .F. +DATA lMini init .F. +DATA lHwgui init .F. +DATA lGui Init .F. +DATA lGtwvt init .F. +DATA lGtwvw init .F. +DATA lMWvW init .F. +DATA lXWT init .F. +DATA lxHGtk init .F. +DATA lWhoo init .F. +DATA lWhat32 init .F. +DATA lRddAds init .F. +DATA lMediator init .F. +DATA cMakefile init "" +DATA lExternalLib init .F. +DATA cObj init "" +DATA cUserdef init "" +DATA cUserInclude init "" +DATA cUserLib init "" +DATA lGenppo init .f. +DATA lCompMod init .f. +DATA lAutomemvar init .f. +DATA lvarismemvar init .f. +DATA ldebug init .f. +DATA lSupressline init .f. +DATA StartPath init "" +DATA cFmc init "" +DATA cMedpath init "" +DATA cAppLibName init "" +DATA cOs init "" +DATA cTopfile init "" +DATA aOut init {} +DATA cFilesToAdd init 5 +DATA lMT init .F. +DATA cWarningLevel init 0 +DATA cTopModule init "" +DATA cRes init "" +DATA cMacro init "" +DATA lGenCsource init .f. // Ath added 31-05-2006 +DATA cShell init "" +DATA cEditor init "" + +METHOD New() +METHOD ReadMakefile(cFile) +METHOD ReplaceMacros( cMacros ) +METHOD FindMacro( cMacro, cRead ) + +ENDCLASS + +*------------------------- +METHOD New() CLASS THbMake +*------------------------- + + ::cObj := "obj" + Space( 40 ) + ::cUserdef := Space( 200 ) + ::cUserInclude := Space( 200 ) + ::cUserLib := Space( 200 ) + ::cFMC := Space( 200 ) + ::cAppLibName := Space( 20 ) + ::cTopModule := Space( 20 ) + ::cEditor := "" + +return self + + +*--------------------------------------- +METHOD ReadMakefile(cFile) CLASS THbMake +*--------------------------------------- + + LOCAL cBuffer := {} + LOCAL cMacro := ::cMacro + LOCAL cDep := "#DEPENDS" + LOCAL cOpt := "#OPTS" + LOCAL cCom := "#COMMANDS" + LOCAL cBuild := "#BUILD" + LOCAL cTemp := "" + LOCAL cTemp1 := '' + LOCAL aTemp := {} + LOCAL lMacrosec := .f. + LOCAL lBuildSec := .f. + LOCAL lComSec := .f. + LOCAL aTemp1 := {} + LOCAL cCfg := "" + LOCAL lCfgFound := .F. + LOCAL aTempCFiles := {} + Local nHandle + Local cObjitem + Local cRes := "" + Local cItem + LOCAL lLinux := At( 'linux', Lower( Os() ) ) > 0 + Local lExtended := .T., szProject + LOCAL lPrgObjRule := .F. + + nHandle := FT_FUSE( cFile ) + IF nHandle < 0 + RETURN self + ENDIF + cBuffer := Trim( Substr( ReadLN( @lEof ), 1 ) ) + ::lLibrary :=.f. + + WHILE !leof + + IF At( cMacro, cBuffer ) > 0 + + lMacroSec := .T. + lBuildSec := .f. + lComSec := .f. + + ELSEIF At( cBuild, cBuffer ) > 0 + + lMacroSec := .f. + lBuildSec := .T. + lComSec := .f. + + ELSEIF At( cCom, cBuffer ) > 0 + + lBuildSec := .f. + lComSec := .t. + lMacroSec := .f. + + ELSE + + ? "Invalid Make File" + Fclose( nHandle ) + RETURN Nil + + ENDIF + + cTemp := Trim( Substr( ReadLN( @lEof ), 1 ) ) + + IF At( "//", ctemp ) > 0 + + WHILE At( "//", ctemp ) > 0 + + ctemp := Strtran( ctemp, " //", "" ) + cTemp += Trim( Substr( ReadLN( @lEof ), 1 ) ) + + ENDDO + + ctemp := Strtran( ctemp, " //", "" ) + + ENDIF + aTemp := ListasArray2( Alltrim( cTemp ), "=" ) + + IF lmacrosec + + IF Alltrim( Left( ctemp, 7 ) ) <> '!ifndef' .and. Alltrim( Left( ctemp, 6 ) ) <> "!endif" .and. Alltrim( Left( ctemp, 7 ) ) <> '!iffile' .and. Alltrim( Left( ctemp, 7 ) ) <> '!stdout' .and. Alltrim( Left( ctemp, 6 ) ) <> '!ifdef' + + IF Len( aTemp ) > 1 + + IF At( "$", aTemp[ 2 ] ) > 0 + + Aadd( ::aMacros, { aTemp[ 1 ], ::replacemacros( aTemp[ 2 ] ) } ) + + ELSE + + Aadd( ::aMacros, { aTemp[ 1 ], aTemp[ 2 ] } ) +// tracelog(aTemp[ 1 ], aTemp[ 2 ]) + + ENDIF + + ENDIF + + IF aTemp[ 1 ] == "PROJECT" + ::cAppLibName := aTemp[ 2 ] + ::cAppLibName := strtran(::cAppLibName ,"$(PR)","") + ::cAppLibName := strtran(::cAppLibName ,".exe","") + ::cAppLibName := strtran(::cAppLibName ,".lib","") + ENDIF + + IF aTemp[ 1 ] == "LIBFILES" + ::lRddAds := "rddads" $ aTemp[ 2 ] + ENDIF + + IF aTemp[ 1 ] == "C4W" + ::cFMC:= aTemp[2] + ::lCw :=.t. + endif + + IF aTemp[ 1 ] == "FWH" + ::cFMC:= aTemp[2] + ::lFwh :=.t. + endif + + IF aTemp[ 1 ] == "MINIGUI" + ::cFMC:= aTemp[2] + ::lmini :=.t. + endif + + IF aTemp[ 1 ] == "HWGUI" + ::cFMC:= aTemp[2] + ::lHwGui :=.t. + endif + + IF aTemp[ 1 ] == "GTWVT" + ::cFMC:= "" + ::lGtwvt :=.t. + endif + + IF aTemp[ 1 ] == "GTWVW" + ::cFMC:= "" + ::lGtwvw :=.t. + endif + IF aTemp[ 1 ] == "MWVW" + ::cFMC:= "" + ::lGtwvw :=.t. + ::lMWvW :=.t. + endif + + IF aTemp[ 1 ] == "XWT" + ::cFMC:= "" + ::lXWT :=.t. + endif + + IF aTemp[ 1 ] == "WHOO" + ::cFMC:= aTemp[2] + ::lWhoo :=.t. + endif + + IF aTemp[ 1 ] == "WHAT32" + ::cFMC:= aTemp[2] + ::lWhat32 :=.t. + endif + + IF aTemp[ 1 ] == "XHGTK" + ::cFMC:= aTemp[2] + ::lxHGtk :=.t. + endif + + IF aTemp[ 1 ] == "MEDIATOR" + ::cMedpath:= aTemp[2] + ::lmEDIATOR :=.t. + endif + + IF aTemp[ 1 ] == "COMPRESS" + ::lCompress := "YES" $ aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "SHELL" + ::cShell := aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "EXTERNALLIB" + ::lExternalLib := "YES" $ aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "XFWH" + ::lxFwh := "YES" $ aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "FILESTOADD" + ::cFilesToAdd := Val( aTemp[ 2 ] ) + endif + + IF aTemp[ 1 ] == "MT" + ::lMt := "YES" $ aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "GUI" + ::lGUI := "YES" $ aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "WARNINGLEVEL" + ::cWarningLevel := Val( aTemp[ 2 ] ) + endif + + + IF aTemp[ 1 ] == "OBJFILES" + cObjitem := substr( atemp[ 2 ],1,at(")",atemp[ 2 ])) + + ::cObj := ::replacemacros(cObjItem) + + ::aObjs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + + IF aTemp[ 1 ] == "OBJCFILES" + + aTemp1 := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + IF Len( atemp1 ) == 1 + + IF !Empty( atemp[ 1 ] ) + + ::aObjsC := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + ELSE + ::aObjsC := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + + ENDIF + + IF aTemp[ 1 ] == "PRGFILES" + + ::aPrgs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + lExtended := .T. + + ENDIF + + IF aTemp[ 1 ] == "PRGFILE" + + ::aPrgs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + + IF atemp[ 1 ] == "CFILES" + + IF lExtended + + aTempCFiles := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + IF ( Len( aTempCFiles ) == 1 ) + + IF !Empty( aTempCFiles[ 1 ] ) + + ::aCs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + + ELSE + + ::aCs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + + ELSE + + ::aCs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + ENDIF + + ENDIF + + IF aTemp[ 1 ] == "EXTLIBFILES" + ::aExtLibs := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + ENDIF + + + IF atemp[ 1 ] == "RESFILES" + + ::aRes := Listasarray2( ::replacemacros( atemp[ 2 ] ), " " ) + + FOR EACH cItem in :: aRes + ::cRes += cItem +" " + NEXT + + ENDIF + + IF aTemp[ 1 ] == "RECURSE" + + ::lRecurse := AT( "YES" , aTemp[ 2 ] ) > 0 + + ENDIF + + IF aTemp[ 1 ] == "LIBRARY" + + ::lLibrary := AT( "YES", aTemp[ 2 ] ) > 0 + + ENDIF + + IF aTemp[ 1 ] == "INSTALLLIB" + + ::lInstallLib := AT( "YES", aTemp[ 2 ] ) > 0 + + ENDIF + + IF aTemp[ 1 ] == "HARBOURFLAGS" + + ::lGenppo := AT( "-p" , aTemp[ 2 ] ) > 0 + ::lCompMod := AT( "-m" , aTemp[ 2 ] ) > 0 + ::lAutomemvar := AT( "-a" , aTemp[ 2 ] ) > 0 + ::lvarismemvar := AT( "-v" , aTemp[ 2 ] ) > 0 + ::ldebug := AT( "-b" , aTemp[ 2 ] ) > 0 + ::lSupressline := AT( "-l" , aTemp[ 2 ] ) > 0 + aTemp[ 2 ] := strtran(aTemp[ 2 ],"-p","") + aTemp[ 2 ] := strtran(aTemp[ 2 ],"-m","") + aTemp[ 2 ] := strtran(aTemp[ 2 ],"-a","") + aTemp[ 2 ] := strtran(aTemp[ 2 ],"-v","") + aTemp[ 2 ] := strtran(aTemp[ 2 ],"-b","") + aTemp[ 2 ] := strtran(aTemp[ 2 ],"-l","") + aTemp[ 2 ] := Alltrim( aTemp[ 2 ] ) + + endif + + IF aTemp[ 1 ] == "USERDEFINE" + ::cUserDef := aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "USERINCLUDE" + ::cUserInclude := aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "USERLIBS" + ::cUserLib := aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "TOPMODULE" + ::cTopModule := aTemp[ 2 ] + endif + + IF aTemp[ 1 ] == "EDITOR" + ::cEditor := aTemp[ 2 ] + endif + + ENDIF + + ENDIF + + IF lbuildSec + + szProject := cTemp + ::aBuildOrder := Listasarray2( cTemp, ":" ) + + + ENDIF + + IF lComSec // Ath added 31-05-2006 + + IF lPrgObjRule + ::lGenCsource := "-go3" $ LOWER(cTemp) + lPrgObjRule := .F. + ENDIF + IF aTemp[ 1 ] == ".prg.obj:" .OR. aTemp[ 1 ] == ".prg.o:" + lPrgObjRule := .T. + ENDIF + + ENDIF // end Ath added 31-05-2006 + + IF cTemp = "#BUILD" + + cBuffer := cTemp + + ELSEIF cTemp == "#COMMANDS" + + cbuffer := cTemp + + ENDIF + + ENDDO + + qout( nhandle) + Fclose( nHandle ) +RETURN self + +*-------------------------------------------- +METHOD ReplaceMacros( cMacros ) CLass THBMAKE +*-------------------------------------------- + + LOCAL nCount := 0 + LOCAL aTempMacros := {} + LOCAL aLocalMacros := {} + + aTempMacros := Listasarray2( cMacros, " " ) + + AEval( aTempMacros, { | xMacro | If( At( "$", xMacro ) > 0, ; + IF( At( ";", xMacro ) > 0, ( aLocalMacros := Listasarray2( xMacro, ";" ), ; + Aeval( aLocalMacros, { | x | ::FindMacro( x, @cMacros ) } ) ), ; + ::FindMacro( xMacro, @cMacros ) ), ) } ) + +RETURN cMacros + +*---------------------------------------------- +METHOD FindMacro( cMacro, cRead ) CLASS THBMAKE +*---------------------------------------------- + + LOCAL nPos + LOCAL cTemp + LOCAL aLocalMacros := {} + + cMacro := Substr( cMacro, 1, At( ")", cMacro ) ) + + IF At( "-", cMacro ) > 0 + + cMacro := Substr( cMacro, 3 ) + + ENDIF + + IF At( ";", cMacro ) > 0 + + cMacro := Substr( cMacro, At( ";", cMacro ) + 1 ) + + ENDIF + + nPos := Ascan( ::aMacros, { | x | "$(" + Alltrim( x[ 1 ] ) + ")" == cMacro } ) + + IF nPos = 0 + + cTemp := Strtran( cMacro, "$(", "" ) + cTemp := Strtran( cTemp, ")", "" ) + + IF !Empty( cTemp ) + + cRead := Alltrim( Strtran( cRead, cMacro, Gete( cTemp ) ) ) + + ENDIF + + ELSE + + cRead := Alltrim( Strtran( cRead, cMacro, ::aMacros[ nPos, 2 ] ) ) + + ENDIF + +RETURN cRead