diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 33da06af00..316be8fdff 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,25 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-24 21:35 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * include/hbapi.h + * source/pp/hbpp.c + * source/vm/cmdarg.c + * source/main/harbour.c + + Added hb_verHB_ARCH(), hb_verHB_COMP() to + retrieve build time HB_ARCHITECTURE and HB_COMPILER + settings. + + * include/hbver.ch + * source/rtl/version.c + + Added new hb_version() information: + hb_version( HB_VERSION_BUILD_ARCH ) + hb_version( HB_VERSION_BUILD_COMP ) + + * utils/hbmk2/hbmk2.prg + + Using above hb_version() values to find out the exact + build time architecture/compiler instead of guessing. + 2009-02-24 18:49 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/vm/fm.c ! Fixed compilation error in dlmalloc with pocc64. diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 3ca21aca2d..1d3beaca75 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -1028,6 +1028,8 @@ extern HB_EXPORT const char * hb_verSvnLastEntry( void ); /* retrieves a stat extern HB_EXPORT const char * hb_verFlagsC( void ); /* retrieves a static buffer containing build time C compiler flags in HB_USER_CFLAGS envvar */ extern HB_EXPORT const char * hb_verFlagsL( void ); /* retrieves a static buffer containing build time linker flags in HB_USER_LDFLAGS envvar */ extern HB_EXPORT const char * hb_verFlagsPRG( void ); /* retrieves a static buffer containing build time Harbour compiler flags in HB_USER_PRGFLAGS envvar */ +extern HB_EXPORT const char * hb_verHB_ARCH( void ); /* retrieves a static buffer containing build time HB_ARCHITECTURE setting */ +extern HB_EXPORT const char * hb_verHB_COMP( void ); /* retrieves a static buffer containing build time HB_COMPILER setting */ extern HB_EXPORT BOOL hb_iswinnt( void ); /* return .T. if OS == Windows NT, 2000, XP */ extern HB_EXPORT BOOL hb_iswince( void ); /* return .T. if OS is Windows CE or Windows Mobile */ diff --git a/harbour/include/hbver.ch b/harbour/include/hbver.ch index f592640b19..33cc684c4b 100644 --- a/harbour/include/hbver.ch +++ b/harbour/include/hbver.ch @@ -70,6 +70,8 @@ #define HB_VERSION_BUILD_DATE_STR 11 #define HB_VERSION_BUILD_DATE 12 #define HB_VERSION_BUILD_TIME 13 +#define HB_VERSION_BUILD_ARCH 22 +#define HB_VERSION_BUILD_COMP 23 /* Last. Please continue from here. */ #define HB_VERSION_FLAG_PRG 14 #define HB_VERSION_FLAG_C 15 #define HB_VERSION_FLAG_LINKER 16 diff --git a/harbour/source/main/harbour.c b/harbour/source/main/harbour.c index ddc51bbb7a..feb3573d39 100644 --- a/harbour/source/main/harbour.c +++ b/harbour/source/main/harbour.c @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * + * * * Copyright 2007 Przemyslaw Czerpak * www - http://www.harbour-project.org @@ -610,6 +610,26 @@ const char * hb_verFlagsPRG( void ) #endif } +/* build time Harbour architecture setting */ +const char * hb_verHB_ARCH( void ) +{ +#ifdef HB_ARCHITECTURE + return HB_ARCHITECTURE; +#else + return ""; +#endif +} + +/* build time Harbour compiler setting */ +const char * hb_verHB_COMP( void ) +{ +#ifdef HB_COMPILER + return HB_COMPILER; +#else + return ""; +#endif +} + int main( int argc, char * argv[] ) { int iResult; diff --git a/harbour/source/pp/hbpp.c b/harbour/source/pp/hbpp.c index b7d5d61642..7a1d2e769c 100644 --- a/harbour/source/pp/hbpp.c +++ b/harbour/source/pp/hbpp.c @@ -367,19 +367,19 @@ static int hb_pp_generateVerInfo( char * szVerFile, int iSVNID, char * szChangeL " */\n\n" ); if( iSVNID ) - fprintf( fout, "\n#define HB_VER_SVNID %d\n", iSVNID ); + fprintf( fout, "\n#define HB_VER_SVNID %d\n", iSVNID ); if( szChangeLogID ) { pszEscaped = hb_pp_escapeString( szChangeLogID ); - fprintf( fout, "\n#define HB_VER_CHLID \"%s\"\n", pszEscaped ); + fprintf( fout, "\n#define HB_VER_CHLID \"%s\"\n", pszEscaped ); hb_xfree( pszEscaped ); } if( szLastEntry ) { pszEscaped = hb_pp_escapeString( szLastEntry ); - fprintf( fout, "\n#define HB_VER_LENTRY \"%s\"\n", pszEscaped ); + fprintf( fout, "\n#define HB_VER_LENTRY \"%s\"\n", pszEscaped ); hb_xfree( pszEscaped ); } @@ -396,7 +396,7 @@ static int hb_pp_generateVerInfo( char * szVerFile, int iSVNID, char * szChangeL if( pszEnv ) { pszEscaped = hb_pp_escapeString( pszEnv ); - fprintf( fout, "\n#define HB_VER_HB_USER_LDFLAGS \"%s\"\n", pszEscaped ); + fprintf( fout, "\n#define HB_VER_HB_USER_LDFLAGS \"%s\"\n", pszEscaped ); hb_xfree( pszEscaped ); hb_xfree( pszEnv ); } @@ -410,6 +410,24 @@ static int hb_pp_generateVerInfo( char * szVerFile, int iSVNID, char * szChangeL hb_xfree( pszEnv ); } + pszEnv = hb_getenv( "HB_ARCHITECTURE" ); + if( pszEnv ) + { + pszEscaped = hb_pp_escapeString( pszEnv ); + fprintf( fout, "\n#define HB_ARCHITECTURE \"%s\"\n", pszEscaped ); + hb_xfree( pszEscaped ); + hb_xfree( pszEnv ); + } + + pszEnv = hb_getenv( "HB_COMPILER" ); + if( pszEnv ) + { + pszEscaped = hb_pp_escapeString( pszEnv ); + fprintf( fout, "\n#define HB_COMPILER \"%s\"\n", pszEscaped ); + hb_xfree( pszEscaped ); + hb_xfree( pszEnv ); + } + fclose( fout ); } diff --git a/harbour/source/rtl/version.c b/harbour/source/rtl/version.c index e5f413a9ae..3dcdc6cd7f 100644 --- a/harbour/source/rtl/version.c +++ b/harbour/source/rtl/version.c @@ -80,6 +80,8 @@ HB_FUNC( HB_VERSION ) case HB_VERSION_CHANGELOG_ID: hb_retc_const( hb_verSvnChangeLogID() ); break; case HB_VERSION_PCODE_VER: hb_retni( HB_PCODE_VER ); break; case HB_VERSION_PCODE_VER_STR: hb_retc_buffer( hb_verPCode() ); break; + case HB_VERSION_BUILD_ARCH: hb_retc_const( hb_verHB_ARCH() ); break; + case HB_VERSION_BUILD_COMP: hb_retc_const( hb_verHB_COMP() ); break; case HB_VERSION_BUILD_DATE_STR: hb_retc_buffer( hb_verBuildDate() ); break; case HB_VERSION_BUILD_DATE: { diff --git a/harbour/source/vm/cmdarg.c b/harbour/source/vm/cmdarg.c index 52c90bb799..33836bfcc7 100644 --- a/harbour/source/vm/cmdarg.c +++ b/harbour/source/vm/cmdarg.c @@ -603,3 +603,23 @@ const char * hb_verFlagsPRG( void ) return ""; #endif } + +/* build time Harbour architecture setting */ +const char * hb_verHB_ARCH( void ) +{ +#ifdef HB_ARCHITECTURE + return HB_ARCHITECTURE; +#else + return ""; +#endif +} + +/* build time Harbour compiler setting */ +const char * hb_verHB_COMP( void ) +{ +#ifdef HB_COMPILER + return HB_COMPILER; +#else + return ""; +#endif +} diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 09f46c8f8e..74ded0eb72 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -241,7 +241,6 @@ FUNCTION Main( ... ) LOCAL fhnd LOCAL lNOHBP LOCAL lSysLoc - LOCAL cSelfCOMP LOCAL cPrefix LOCAL cPostfix @@ -253,6 +252,7 @@ FUNCTION Main( ... ) LOCAL cDir, cName, cExt + LOCAL cSelfCOMP := hb_Version( HB_VERSION_BUILD_COMP ) LOCAL cSelfFlagPRG := hb_Version( HB_VERSION_FLAG_PRG ) LOCAL cSelfFlagC := hb_Version( HB_VERSION_FLAG_C ) LOCAL cSelfFlagL := hb_Version( HB_VERSION_FLAG_LINKER ) @@ -347,23 +347,7 @@ FUNCTION Main( ... ) t_cARCH := "dos" EXIT OTHERWISE -#if defined( __PLATFORM__BSD ) - t_cARCH := "bsd" -#elif defined( __PLATFORM__DARWIN ) - t_cARCH := "darwin" -#elif defined( __PLATFORM__DOS ) - t_cARCH := "dos" -#elif defined( __PLATFORM__HPUX ) - t_cARCH := "hpux" -#elif defined( __PLATFORM__LINUX ) - t_cARCH := "linux" -#elif defined( __PLATFORM__OS2 ) - t_cARCH := "os2" -#elif defined( __PLATFORM__SUNOS ) - t_cARCH := "sunos" -#elif defined( __PLATFORM__WINDOWS ) - t_cARCH := "win" -#endif + t_cARCH := hb_Version( HB_VERSION_BUILD_ARCH ) ENDSWITCH IF ! Empty( t_cARCH ) IF t_lInfo @@ -446,13 +430,11 @@ FUNCTION Main( ... ) IF Len( aCOMPSUP ) == 1 t_cCOMP := aCOMPSUP[ 1 ] ELSEIF t_cARCH == "linux" .OR. t_cCOMP == "bld" - t_cCOMP := SelfCOMP() + t_cCOMP := cSelfCOMP IF AScan( aCOMPSUP, {|tmp| tmp == t_cCOMP } ) == 0 t_cCOMP := NIL ENDIF ELSEIF ! Empty( aCOMPDET ) - /* Which compiler was used to compile ourselves? */ - cSelfCOMP := SelfCOMP() /* Skip it for msvc, as it creates problems for other compilers. */ IF !( cSelfCOMP $ "msvc|msvc64" ) /* Look for this compiler first */ @@ -1780,26 +1762,6 @@ STATIC FUNCTION SetupForGT( cGT, /* @ */ s_cGT, /* @ */ s_lGUI ) RETURN .F. -STATIC FUNCTION SelfCOMP() - LOCAL cCompiler := hb_Compiler() - - /* Order is significant */ - IF "Microsoft Visual C" $ cCompiler ; RETURN iif( "(64-bit)" $ cCompiler, "msvc64", "msvc" ) - ELSEIF "Borland" $ cCompiler ; RETURN "bcc32" - ELSEIF "CodeGear" $ cCompiler ; RETURN "bcc32" - ELSEIF "DJGPP" $ cCompiler ; RETURN "djgpp" - ELSEIF "MinGW" $ cCompiler ; RETURN "mingw" - ELSEIF "GNU C++" $ cCompiler ; RETURN iif( t_cARCH == "linux", "gpp", "gcc" ) - ELSEIF "GNU C" $ cCompiler ; RETURN "gcc" - ELSEIF "Watcom C++" $ cCompiler ; RETURN "owatcom" - ELSEIF "Watcom C" $ cCompiler ; RETURN "owatcom" - ELSEIF "Pelles ISO C" $ cCompiler ; RETURN iif( "(64-bit)" $ cCompiler, "pocc64", "pocc" ) - ELSEIF "Digital Mars" $ cCompiler ; RETURN "dmc" - ELSEIF "(XCC)" $ cCompiler ; RETURN "xcc" - ENDIF - - RETURN "" - STATIC FUNCTION FindInPath( cFileName ) LOCAL cDir LOCAL cName