diff --git a/harbour/source/compiler/gencobj.c b/harbour/source/compiler/gencobj.c index a4095876c8..f34ad65805 100644 --- a/harbour/source/compiler/gencobj.c +++ b/harbour/source/compiler/gencobj.c @@ -55,7 +55,7 @@ void hb_compGenCObj( PHB_FNAME pFileName ) char * pszCfg; char * pszEnv; BOOL bVerbose = FALSE; /* Don't show C compiler messages (default). */ - BOOL bDelTmp = FALSE; /* Delete intermediate C file (default). */ + BOOL bDelTmp = TRUE; /* Delete intermediate C file (default). */ int iSuccess; /* First pass: build the C output */ @@ -181,9 +181,9 @@ void hb_compGenCObj( PHB_FNAME pFileName ) if( hb_comp_pOutPath->szPath ) pOut->szPath = hb_comp_pOutPath->szPath; -#if defined(__MSDOS__) || defined(__WIN32__) || defined(_Windows) +#if defined(__BORLANDC__) || defined(_MSC_VER) pOut->szExtension = ".obj"; -#elif defined( OS_UNIX_COMPATIBLE ) +#else pOut->szExtension = ".o"; /* Don't know if we can hardcode it for Un*x */ #endif hb_fsFNameMerge( pszTemp, pOut ); @@ -286,4 +286,4 @@ static char * hb_searchpath( const char * pszFile, char * pszEnv, char * pszCfg sprintf( pszCfg, "%s", "" ); return ( char * ) pszCfg; -} \ No newline at end of file +} diff --git a/harbour/utils/hbmake/hbmake.prg b/harbour/utils/hbmake/hbmake.prg index b72aedff7b..581dd2370c 100644 --- a/harbour/utils/hbmake/hbmake.prg +++ b/harbour/utils/hbmake/hbmake.prg @@ -198,6 +198,7 @@ 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 @@ -316,7 +317,7 @@ While !leof If lbuildSec szProject:=cTemp aBuildOrder := listasarray2( ctemp, ":" ) - // ? cTemp + if !llibrary SetBuild() @@ -341,6 +342,8 @@ Enddo BuildBorCfgFile() elseif lVcc BuildMSCCfgFile() + elseif lGcc .and. !lLinux + BuildGccCfgFile() endif endif @@ -552,7 +555,7 @@ Next if !lLinux Fclose( nLinkhandle ) Endif -outstd(cLinkComm) + Return nil *+北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北北 @@ -574,6 +577,7 @@ Local cErrText:="" Local aOrder := listasarray2( aBuildOrder[ 2 ], " " ) Local lEnd:=.f. Local xItem +Local lLinux:=at('linux',lower(os()))>0 For nCount := 1 To Len( aOrder ) if !lExtended @@ -600,6 +604,7 @@ For nCount := 1 To Len( aOrder ) cComm += " > test.out" outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) cErrText := memoread( 'test.out' ) lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText @@ -647,11 +652,17 @@ For nCount := 1 To Len( aOrder ) If nPos > 0 - cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) + 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( " ") - // ? cComm + outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) ccomm := cold Endif @@ -680,10 +691,17 @@ else /****** Extended mode *****/ nPos := Ascan( aObjsc, { | 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" + aobjsc[ nPos ] ) + + 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" outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) cErrText := memoread( 'test.out' ) lEnd := 'Error' $ cErrText @@ -724,12 +742,17 @@ endif nPos := ascan( aobjs, { | 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" + aObjs[ nPos ] ) + 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( " ") - // ? cComm + outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) cErrText := memoread( 'test.out' ) lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText @@ -817,30 +840,15 @@ Outstd( "HBMAKE Version ", Version(), "CopyRight (c) 2000-2001 The Harbour Proje Outstd( "" + CRLF ) Outstd( "Macros:" + CRLF ) aeval(aMacros,{|xItem| Outstd( " " + xItem[ 1 ] + " = " + xItem[ 2 ] + CRLF )}) -/* -For nPos := 1 To Len( aMacros ) - Outstd( " " + aMacros[ nPos, 1 ] + " = " + aMacros[ nPos, 2 ] + CRLF ) -Next*/ Outstd( "Implicit Rules:" + CRLF ) aeval(aCommands,{|xItem| Outstd( " " + xItem[ 1 ] + hb_osnewline() + " " + xItem[ 2 ] + CRLF )}) -/* -For nPos := 1 To Len( aCommands ) - Outstd( " " + aCommands[ nPos, 1 ] + hb_osnewline() + " " + aCommands[ nPos, 2 ] + CRLF ) -Next -*/ Outstd( "" + CRLF ) Outstd( "Targets:" ) Outstd( " " + szProject + ":" + CRLF ) Outstd( " " + "Flags :" + CRLF ) Outstd( " " + "Dependents :" ) aeval(acs,{|xItem| Outstd( xitem + " ")}) -/*For nPos := 1 To Len( aCs ) - Outstd( acs[ nPos ] + " ") -Next*/ aeval(aobjs,{|xItem| Outstd( xitem + " ")}) -/*For nPos := 1 To Len( aobjs ) - Outstd( aobjs[ nPos ] + " ") -Next*/ Outstd( " " + CRLF ) Outstd( " commands:" + aBuildOrder[ Len( aBuildOrder ) ] ) Outstd( " " + CRLF ) @@ -886,10 +894,10 @@ 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 -lgtstd -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -lcommon" +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 -lgtstd -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -lcommon -lm" - +local cLibs := "" local citem:="" Local cExt:="" Local cDrive:="" @@ -897,6 +905,8 @@ local cPath:="" Local cTest:="" Local cUserdef:=space(40) Local cUserInclude:=space(40) +Local aLibs,aLibsin:={},aLibsout:={} +local lExternalLib:=.f. nLinkHandle := Fcreate( cFile ) WriteMakeFileHeader() @@ -931,6 +941,7 @@ ATTENTION( "Harbour Options", 5 ) @ 8, 40 Get lCompMod checkbox caption "compile module only" @ 9, 1 Say "User Defines " get cUserDef pict "@s15" @ 9, 40 Say "User include Path" get cUserInclude pict "@s15" +@ 10,1 get lExternalLib checkbox "Use External Libs" Read if !empty(cUserDef) cDefHarOpts+= " -D"+alltrim(cUserDef) +" " @@ -950,12 +961,12 @@ if !empty(cobjDir) endif endif amacros:=GetSourceDirMacros(lGcc,cos) -if lGcc +if lLinux cObjDir:=alltrim(cObjDir) if !empty(cObjDir) cObjDir+='/' endif -cTest:=upper(cObjDir)+'/' +cTest:=cObjDir+'/' else cObjDir:=alltrim(cObjDir) if !empty(cObjDir) @@ -1062,7 +1073,13 @@ 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( 10, 15, 19, 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),)}) @@ -1235,6 +1252,43 @@ Fwrite( nLinkHandle, "RESDEPEN = $(RESFILES)" + CRLF ) if lRddads cDefBccLibs+=" rddads.lib ace32.lib" endif + if Len(alibsout)>0 .and. lExternalLib + if lvcc .or. lbcc + nPos:=ascan(aLibsout,{|z| at("html",lower(z))>0 } ) + if npos>0 + cLibs+=aLibsout[npos]+" "+cDefBccLibs + adel(alibsout,nPos) + asize(alibsout,len(alibsout)-1) + endif + aeval(alibsout,{ |cLib| cLibs+=" "+cLib}) + clibs+= " "+cDefBccLibs + cDefBccLibs:=cLibs + endif + if lGcc + nPos:=ascan(aLibsout,{|z| at("html",lower(z))>0 } ) + if npos>0 + if cOs=="Linux" + cLibs+="-l"+strtran(aLibsout[npos],'.a',"")+" "+cDeflibGccLibs + elseif cOs=="OS/2" + cLibs+="-l"+strtran(aLibsout[npos],'.a',"")+" "+cgcclibsos2 + else + cLibs+="-l"+strtran(aLibsout[npos],'.a',"")+" "+cDefGccLibs + endif + adel(alibsout,nPos) + asize(alibsout,len(alibsout)-1) + aeval(alibsout,{ |cLib| cLibs+=" -l"+strtran(cLib,'.a',"")}) + if cOs=="Linux" + clibs+= " "+cDeflibGccLibs + cDeflibGccLibs:=cLibc + elseif cOs=="OS/2" + clibs+= " "+cgcclibsos2 + cgcclibsos2:=cLibs + else + clibs+= " "+cDefGccLibs + cDefGccLibs:=cLibs + endif + endif + ENDIF if lBcc .or. lVcc If lFwh Fwrite( nLinkHandle, "LIBFILES = $(FWH)\lib\fiveh.lib $(FWH)\lib\fivehc.lib " + cDefBccLibs + CRLF ) @@ -1386,6 +1440,7 @@ if !lextended 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 @@ -1429,8 +1484,9 @@ if !lextended cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) cComm := Strtran( cComm, "$**", aCtocompile[ nFiles ] ) outstd( " ") - // ? cComm + outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) ccomm := cold Endif @@ -1458,6 +1514,7 @@ else /**************Extended mode ******///// cComm := Strtran( cComm, "$**", acs[ nFiles ] ) cComm += " > test.out" outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) cErrText := memoread( 'test.out' ) lEnd := 'Error' $ cErrText @@ -1497,10 +1554,9 @@ else /**************Extended mode ******///// cComm := Strtran( cComm, "o$*", "o" + aObjs[ nPos ] ) cComm := Strtran( cComm, "$**", aprgs[ nFiles ] ) cComm += " > test.out" - outstd( " ") - - ? cComm + outstd( " ") outstd(cComm) + outstd(hb_osnewline()) ! ( cComm ) cErrText := memoread( 'test.out' ) lEnd := 'C2006' $ cErrText .or. 'No code generated' $ cErrText @@ -2024,7 +2080,7 @@ Fclose( nLinkhandle ) if lLinux cLinkComm += " || rm -f " +cLib endif -outstd(cLinkComm) + Return nil @@ -2140,6 +2196,22 @@ If !file(GetMakeDir() +'\bin\harbour.cfg') 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 findHarbourcfg(cCfg) Local cPath AS STRING := '' @@ -2152,7 +2224,6 @@ 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 ] @@ -2171,7 +2242,9 @@ else endif endif cCfg:=cPath +?' findHarbourcfg',ccfg,lfound Return lFound + function TestforPrg(cFile) Local aFiles AS ARRAY :={} Local cPath AS STRING :='' diff --git a/harbour/utils/hbmake/hbmutils.prg b/harbour/utils/hbmake/hbmutils.prg index a1387f21ee..2e041915c4 100644 --- a/harbour/utils/hbmake/hbmutils.prg +++ b/harbour/utils/hbmake/hbmutils.prg @@ -1,689 +1,363 @@ - - #include "common.ch" - #ifndef __HARBOUR__ - #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 filedate( c as String ) as string - declare listasArray2( cString as String, cSep as String ) as Array - #endif - - - -Function GetSourceFiles( lSubdir,lgcc ,cOs) - - +Function GetSourceFiles( lSubdir ) Local adirs AS ARRAY - Local aRet AS ARRAY := {} - - Local lLinux:=at('linux',lower(os()))>0 - - Local cdir := If( at('Linux',cOs)==0, '\' + Curdir() + '\', '/' + Curdir() + '/' ) - + Local lLinux := At( 'linux', 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 - Default lSubdir To .t. - default lGcc to .f. - - While ++ nCounter <= Len( aStru ) - If !Empty( adirs := GetDirs( astru[ nCounter ] ) ) // There are elements! - - Aeval( aDirs, { | xItem | Aadd( aStru, xItem +if(lGcc,"/","\")) } ) - + Aeval( aDirs, { | xItem | Aadd( aStru, xItem ) } ) Endif - Enddo - aDirs := {} - - Asort( aStru ) - nArrayLen := Len( aStru ) - - For nCounter := 1 To nArrayLen + If Len( aData := Directory( aStru[ nCounter ] + "*.*" ) ) != 0 - -/* If Len( aData := Directory( aStru[ nCounter ] + "*.prg") ) != 0*/ - 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, '' ) + Pad( aData[ y, 1 ], 13 ) + ; Str( aData[ y, 2 ], 8 ) + ' ' + ; Dtoc( aData[ y, 3 ] ) + ' ' + ; aData[ y, 4 ] ) - - Elseif !lsubdir .and. At( If( lGcc, "/", "\" ), Strtran( astru[ nCounter ], cDir, '' ) ) == 0 - - Aadd( aRet, Pad( aData[ y, 1 ], 13 ) + ; - Str( aData[ y, 2 ], 8 ) + ' ' + ; + Elseif !lsubdir .and. At( If( lLinux, "/", "\" ), Strtran( astru[ nCounter ], cDir, '' ) ) == 0 + Aadd( aRet, Pad( aData[ y, 1 ], 13 ) + ; + Str( aData[ y, 2 ], 8 ) + ' ' + ; Dtoc( aData[ y, 3 ] ) + ' ' + ; aData[ y, 4 ] ) - Endif - - Next - Endif -/* - If Len( aData := Directory( aStru[ nCounter ] + "*.c" ) ) != 0 - - nDataLen := Len( aData ) - For y := 1 To nDataLen - If lSubdir - Aadd( aRet, Strtran( astru[ nCounter ], cDir, '' ) + Pad( aData[ y, 1 ], 13 ) + ; - Str( aData[ y, 2 ], 8 ) + ' ' + ; - Dtoc( aData[ y, 3 ] ) + ' ' + ; - aData[ y, 4 ] ) - - Elseif !lsubdir .and. At( If( lGcc, "/", "\" ), Strtran( astru[ nCounter ], cDir, '' ) ) == 0 - - Aadd( aRet, Pad( aData[ y, 1 ], 13 ) + ; - Str( aData[ y, 2 ], 8 ) + ' ' + ; - Dtoc( aData[ y, 3 ] ) + ' ' + ; - aData[ y, 4 ] ) Endif Next - Endif - */ Next - For nCounter := 1 To Len( aret ) - xItem := Substr( aret[ nCounter ], Rat( If( lGcc, "/", '\' ), aret[ nCounter ] ) + 1 ) - - nPos := Ascan( astru, { | x | x := Substr( x, Rat( if(lGcc,"/",'\'), x ) + 1 ), Left( x, At( ".", x ) ) == Left( xitem, At( ".", xitem ) ) } ) + xItem := Substr( aret[ nCounter ], Rat( If( llinux, "/", '\' ), aret[ nCounter ] ) + 1 ) + 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 - - 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 Return aRet - - Function extenprg( cExt, nType ) - - 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' ) - - Endif - Endif - Return ctemp - - Static Function GetDirs( cPattern ) Local aDir := {} Local lLinux := At( 'linux', Os() ) > 0 Aeval( Directory( cPattern + "*.", "D" ), ; - { | xItem | If( xItem[ 5 ] = "D" .and. if(!llinux , xItem[ 1 ] != "." .and. xItem[ 1 ] != ".." ,), ; - ( Aadd( aDir, cPattern + xItem[ 1 ] ) ; - ), "" ) } ) /* + If( llinux, "\", '/' )*/ -Return ( aDir ) - - - -Static Function GetDirsl( cPattern ) - - - - Local aDir := {} - qout(cPattern) - Aeval( Directory( cPattern+"*.*", "D" ), ; - { | xItem | If( xItem[ 5 ] == "D" , ; - Aadd( aDir, cPattern + xItem[ 1 ] ), "" ) } ) - - + { | xItem | If( xItem[ 5 ] = "D" .and. ; + ( xItem[ 1 ] != "." .and. xItem[ 1 ] != ".." ), ; + ( Aadd( aDir, cPattern + xItem[ 1 ] + If( llinux, "/", '\' ) ), ; + Outstd( "." ) ), "" ) } ) Return ( aDir ) - - Function GetBccDir() - - Local cPath := '' - Local cEnv := Gete( "PATH" ) - Local aEnv := listasarray2( cEnv, ";" ) - Local nPos - - 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 - - Return cPath - Function GetVccDir() - - Local cPath AS STRING := '' - Local cEnv AS STRING := Gete( "PATH" ) - Local aEnv as array of string := listasarray2( cEnv, ";" ) - Local nPos as numeric - - 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 - - Return cPath - - Function exten( cExt, nType ) - - 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 ) - - Local nPos as numeric - Local aList as array := {} // 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 GetMakeDir() - - Local cPath := "" - Local cExe := HB_ARGV( 0 ) - - - + + cExe:=strtran(cExe,"/","\") cPath := Left( cexe, Rat( "\", cexe ) - 1 ) - cPath := Left( cPath, Rat( "\", cPath ) - 1 ) - - Return cPath - - -Function GetSourceDirMacros(lgcc,cOs) - - +Function GetSourceDirMacros() Local adirs AS ARRAY - - Local lLinux:=At("linux",lower(os()))>0 - - Local cdir := If( at('linux',lower(os()))>0, '/' + Curdir() + '/', '\' + Curdir() + '\' ) - + Local lLinux := At( 'linux', Os() ) > 0 + Local cdir as String := If( llinux, '/' + Curdir() + '/', '\' + Curdir() + '\' ) Local aStru := { cDir } - - - Local nCounter := 0 - - Local amacros := {} - - - + 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+if(lGcc,"/","\") ) } ) - /**/ + Aeval( aDirs, { | xItem | Aadd( aStru, xItem ) } ) Endif - Enddo - -/* else - - While ++ nCounter <= Len( aStru ) - - If !Empty( adirs := GetDirsl( astru[ nCounter ] ) ) // There are elements! - - Aeval( aDirs, { | xItem | Aadd( aStru, xItem+"/" ) } ) - - Endif - - Enddo - - - endif*/ - For nCounter := 1 To Len( aStru ) - - Aadd( amacros, { "SRC" + Strzero( nCounter, 2, 0 ), Strtran( astru[ nCounter ], cDir, '' ),.f. } ) - + Aadd( amacros, { "SRC" + Strzero( nCounter, 2, 0 ), Strtran( astru[ nCounter ], cDir, '' ), .f. } ) Next - Return amacros - - Function filedate( cFileName ) - - Local aFiles := Directory( cFileName ) - - Return If( Len( aFiles ) == 1, aFiles[ 1, 3 ], Ctod( '' ) ) - - Function filetime( cFileName ) - - Local aFiles := Directory( cFileName ) - - Return If( Len( aFiles ) == 1, aFiles[ 1, 4 ], '' ) - - Function TD2JUL( CTIME, DDATE ) - - Return DDATE - Ctod( '01/01/1900' ) + ( PRB_INT( TTOS( CTIME ) / 100000,, 5 ) ) - - 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 DIR_MULTI( cFileMaskList, cAttr ) - LOCAL aList := ListasArray2( cFileMaskList, "|" ) - AEval( aList, {|tmp, tmp1| aList[ tmp1 ] := DIRECTORY( tmp, cAttr ) }) - RETURN ArrayAJoin(alist) +Function GetinstaledLibs( clibs, lGcc ) -function ArrayAJoin(c) -local aResult:={} -local aCurArray -local nPos -for nPos:=1 to len(c) - aCurArray:=c[nPos] - aeval(aCurArray,{|a| aadd(aresult,a)}) -next -return aresult + 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 + + 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, '', '.lib' ) }, ; + { "Harbour Misc library - Libmisc", 'misc' + If( lgcc, '', '.lib' ) }, ; + { "Harbour html library - Htmllib", 'html' + If( lgcc, '', '.lib' ) }, ; + { "Harbour Nanfor library - Libnf", 'nf' + If( lgcc, '', '.lib' ) }, ; + { "Harbour Gt library - Libgt", 'nf' + If( lgcc, '', '.lib' ) }, ; + { "Harbour Zip library Zlib1", 'zlib1.lib ziparchive' + If( lgcc, '', '.lib' ) }, ; + { "Harbour Hbole library Hbole", 'hbole' + If( lgcc, '', '.lib' ) + ' ole2' + If( lgcc, '', '.lib' ) }, ; + { "Harbour Mysql library - MySql", 'mysql' + If( lgcc, '', '.lib' ) + ' libmysql' + If( lgcc, '', '.lib' ) + ' mysqlclient' + If( lgcc, '.a', '.lib' ) }, ; + { "Harbour Samples library - Samples", 'samples' + If( lgcc, '', '.lib' ) } } + Aeval( ainstaledlibs, { | x | Aadd( aLibsDesc, { "User - " + x +" Library", x } ) } ) +Return aLibsDesc *+ EOF: HBMUTILS.PRG -