From bdfb6a9e9318a9da1df6543a074cd7446091988c Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 21 Dec 2009 07:22:14 +0000 Subject: [PATCH] 2009-12-21 08:21 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbgtcore.h * harbour/include/hbapigt.h * moved declaration of hb_gtSetDefault() from hbgtcore.h to hbapigt.h * harbour/include/hbapi.h * harbour/src/vm/hvm.c + added new function hb_vmSetDefaultGT() * harbour/bin/hb-func.sh * harbour/utils/hbmk2/hbmk2.prg * use hb_vmSetDefaultGT() to set default GT * removed extern declarations for functions defined in hbapi.h * harbour/src/vm/dynlibhb.c + added support for HB_LIBLOAD()/HB_LIBFREE() in DJGPP 2.04 builds * harbour/config/global.mk * use 8.3 names for harbour dynamic libraries in all DOS builds * harbour/config/dos/djgpp.mk + added support for dynamic libraries (DXE) in DJGPP builds. DXE is sth similar to DLL in Windows and can be used with DJGPP 2.04. I had to make some modifications in DXE header files to make it working so it will not work in default DJGPP installation. I'll document these modifications in the future. * harbour/config/dos/watcom.mk * enable creating of harbour dynamic libraries only when HB_BUILD_DLL is explictly set by user to 'yes'. In DOS DJGPP and OpenWatcom builds DLLs support is not functional yet. * harbour/config/dyn.mk * added an option to create harbour dynamic libraries from static ones instead of .o|.obj files. It's necessary for DXE3GEN which internally calls LD which has some limited on maximum size of passed parameters. TODO: make HB_DYN_LIBS definition common for dyn.mk and lib.mk --- harbour/ChangeLog | 39 ++++++++++++++++++ harbour/bin/hb-func.sh | 6 +-- harbour/config/dos/djgpp.mk | 50 +++++++++++++++-------- harbour/config/dos/watcom.mk | 51 +++++++++++++----------- harbour/config/dyn.mk | 74 +++++++++++++++++++++++++---------- harbour/config/global.mk | 2 +- harbour/include/hbapi.h | 1 + harbour/include/hbapigt.h | 1 + harbour/include/hbgtcore.h | 1 - harbour/src/vm/dynlibhb.c | 4 +- harbour/src/vm/hvm.c | 5 +++ harbour/utils/hbmk2/hbmk2.prg | 7 +--- 12 files changed, 167 insertions(+), 74 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d4c3b7cd46..c44bf4003a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,45 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-21 08:21 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbgtcore.h + * harbour/include/hbapigt.h + * moved declaration of hb_gtSetDefault() from hbgtcore.h to hbapigt.h + + * harbour/include/hbapi.h + * harbour/src/vm/hvm.c + + added new function hb_vmSetDefaultGT() + + * harbour/bin/hb-func.sh + * harbour/utils/hbmk2/hbmk2.prg + * use hb_vmSetDefaultGT() to set default GT + * removed extern declarations for functions defined in hbapi.h + + * harbour/src/vm/dynlibhb.c + + added support for HB_LIBLOAD()/HB_LIBFREE() in DJGPP 2.04 builds + + * harbour/config/global.mk + * use 8.3 names for harbour dynamic libraries in all DOS builds + + * harbour/config/dos/djgpp.mk + + added support for dynamic libraries (DXE) in DJGPP builds. + DXE is sth similar to DLL in Windows and can be used with + DJGPP 2.04. I had to make some modifications in DXE header + files to make it working so it will not work in default DJGPP + installation. I'll document these modifications in the future. + + * harbour/config/dos/watcom.mk + * enable creating of harbour dynamic libraries only when HB_BUILD_DLL + is explictly set by user to 'yes'. In DOS DJGPP and OpenWatcom builds + DLLs support is not functional yet. + + * harbour/config/dyn.mk + * added an option to create harbour dynamic libraries from static + ones instead of .o|.obj files. It's necessary for DXE3GEN which + internally calls LD which has some limited on maximum size of passed + parameters. + TODO: make HB_DYN_LIBS definition common for dyn.mk and lib.mk + 2009-12-21 02:49 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/hbqt.ch * contrib/hbxbp/xbp.ch diff --git a/harbour/bin/hb-func.sh b/harbour/bin/hb-func.sh index 540926126c..3b6191179b 100755 --- a/harbour/bin/hb-func.sh +++ b/harbour/bin/hb-func.sh @@ -736,13 +736,9 @@ hb_lnk_request() gt="\${HB_GT_REQ%% *}" if [ -n "\$gt" ] || [ -n "\${HB_MAIN_FUNC}" ]; then echo "#include \\"hbinit.h\\"" - echo "HB_EXTERN_BEGIN" - echo "extern \${HB_LNK_ATTR} const char * hb_gt_szNameDefault;" - echo "extern \${HB_LNK_ATTR} void hb_vmSetLinkedMain( const char * szMain );" - echo "HB_EXTERN_END" echo "HB_CALL_ON_STARTUP_BEGIN( hb_lnk_SetDefault_build )" if [ -n "\$gt" ]; then - echo " hb_gt_szNameDefault = \\"\$gt\\";" + echo " hb_vmSetDefaultGT( \\"\$gt\\" );" fi if [ -n "\${HB_MAIN_FUNC}" ]; then if [ \${HB_MAIN_FUNC} != \${HB_MAIN_FUNC/x/y} ]; then diff --git a/harbour/config/dos/djgpp.mk b/harbour/config/dos/djgpp.mk index 7f3ea3ff4b..315c72fdc2 100644 --- a/harbour/config/dos/djgpp.mk +++ b/harbour/config/dos/djgpp.mk @@ -11,6 +11,7 @@ endif OBJ_EXT := .o LIB_PREF := lib LIB_EXT := .a +DYN_EXT := .dxe CC := $(HB_CCPATH)$(HB_CCPREFIX)$(HB_CMP)$(HB_CCPOSTFIX) CC_IN := -c @@ -38,6 +39,9 @@ endif ifneq ($(filter $(HB_BUILD_STRIP),all bin),) LDSTRIP := -s DYSTRIP := -s +else + LDSTRIP := + DYSTRIP := endif SYSLIBPATHS := @@ -100,22 +104,34 @@ AR_RULE = $(create_library) LD_RULE = $(link_exe_file) -#DY := $(CC) -#DFLAGS += -Wl,-shared $(LIBPATHS) -#DY_OUT := -o$(subst x,x, ) -#DLIBS := $(foreach lib,$(HB_USER_LIBS) $(SYSLIBS),-l$(lib)) -# -## NOTE: The empty line directly before 'endef' HAVE TO exist! -#define dyn_object -# @$(ECHO) $(ECHOQUOTE)INPUT($(subst \,/,$(file)))$(ECHOQUOTE) >> __dyn__.tmp -# -#endef -#define create_dynlib -# $(if $(wildcard __dyn__.tmp),@$(RM) __dyn__.tmp,) -# $(foreach file,$^,$(dyn_object)) -# $(DY) $(DFLAGS) $(HB_USER_DFLAGS) $(DY_OUT)$(DYN_DIR)/$@ __dyn__.tmp $(DLIBS) $(DYSTRIP) -#endef -# -#DY_RULE = $(create_dynlib) +ifeq ($(HB_BUILD_DLL),yes) + + DY := dxe3gen + DFLAGS += $(LIBPATHS) + DY_OUT := -o$(subst x,x, ) + DLIBS := $(foreach lib,$(HB_USER_LIBS) $(SYSLIBS),-l$(lib)) + + # due to limited size of ld parameter list use libraries directly + HB_DYN_FROM_LIBS := yes + DFLAGS += --whole-archive + DLIBS := + + # NOTE: The empty line directly before 'endef' HAVE TO exist! + define dyn_object + @$(ECHO) $(ECHOQUOTE)$(subst \,/,$(file))$(ECHOQUOTE) >> __dyn__.tmp + + endef + define create_dynlib + @$(ECHO) $(ECHOQUOTE)$(DFLAGS) $(HB_USER_DFLAGS)$(ECHOQUOTE) > __dyn__.tmp + @$(ECHO) $(ECHOQUOTE)$(DY_OUT)$(DYN_DIR)/$@$(ECHOQUOTE) >> __dyn__.tmp + @$(ECHO) $(ECHOQUOTE)-Y $(IMP_FILE) -U $(DYSTRIP)$(ECHOQUOTE) >> __dyn__.tmp + $(foreach file,$^,$(dyn_object)) + @$(ECHO) $(ECHOQUOTE)$(DLIBS)$(ECHOQUOTE) >> __dyn__.tmp + $(DY) @__dyn__.tmp + endef + + DY_RULE = $(create_dynlib) + +endif # HB_BUILD_DLL include $(TOP)$(ROOT)config/rules.mk diff --git a/harbour/config/dos/watcom.mk b/harbour/config/dos/watcom.mk index 9a56bd4f11..52d6b275cc 100644 --- a/harbour/config/dos/watcom.mk +++ b/harbour/config/dos/watcom.mk @@ -7,6 +7,7 @@ OBJ_EXT := .obj LIB_PREF := LIB_EXT := .lib +DYN_EXT := .dll ifeq ($(HB_BUILD_MODE),cpp) CC := wpp386 @@ -70,32 +71,36 @@ ifneq ($(HB_LINKING_RTL),) endif endif -DY := $(LD) -DFLAGS += OP quiet SYS cwdllr -DY_OUT := -DLIBS := $(foreach lib,$(HB_USER_LIBS),$(lib)) -DLIBS += $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib)) -DLIBS += $(foreach lib,$(SYSLIBS),$(lib)) -DLIBS := $(strip $(DLIBS)) +ifeq ($(HB_BUILD_DLL),yes) -ifneq ($(DLIBS),) - comma := , - DLIBS_COMMA := LIB $(subst $(subst x,x, ),$(comma) ,$(DLIBS)) -else - DLIBS_COMMA := -endif + DY := $(LD) + DFLAGS += OP quiet SYS cwdllr + DY_OUT := + DLIBS := $(foreach lib,$(HB_USER_LIBS),$(lib)) + DLIBS += $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib)) + DLIBS += $(foreach lib,$(SYSLIBS),$(lib)) + DLIBS := $(strip $(DLIBS)) -# NOTE: The empty line directly before 'endef' HAVE TO exist! -define dyn_object - @$(ECHO) $(ECHOQUOTE)FILE '$(file)'$(ECHOQUOTE) >> __dyn__.tmp + ifneq ($(DLIBS),) + comma := , + DLIBS_COMMA := LIB $(subst $(subst x,x, ),$(comma) ,$(DLIBS)) + else + DLIBS_COMMA := + endif -endef -define create_dynlib - $(if $(wildcard __dyn__.tmp),@$(RM) __dyn__.tmp,) - $(foreach file,$^,$(dyn_object)) - $(DY) $(DFLAGS) $(HB_USER_DFLAGS) NAME '$(subst /,$(DIRSEP),$(DYN_DIR)/$@)' OP implib='$(IMP_FILE)' @__dyn__.tmp $(DLIBS_COMMA) -endef + # NOTE: The empty line directly before 'endef' HAVE TO exist! + define dyn_object + @$(ECHO) $(ECHOQUOTE)FILE '$(file)'$(ECHOQUOTE) >> __dyn__.tmp -DY_RULE = $(create_dynlib) + endef + define create_dynlib + $(if $(wildcard __dyn__.tmp),@$(RM) __dyn__.tmp,) + $(foreach file,$^,$(dyn_object)) + $(DY) $(DFLAGS) $(HB_USER_DFLAGS) NAME '$(subst /,$(DIRSEP),$(DYN_DIR)/$@)' OP implib='$(IMP_FILE)' @__dyn__.tmp $(DLIBS_COMMA) + endef + + DY_RULE = $(create_dynlib) + +endif # HB_BUILD_DLL include $(TOP)$(ROOT)config/common/watcom.mk diff --git a/harbour/config/dyn.mk b/harbour/config/dyn.mk index 051490a135..e5922743ae 100644 --- a/harbour/config/dyn.mk +++ b/harbour/config/dyn.mk @@ -19,33 +19,63 @@ endif -include $(TOP)$(ROOT)config/$(HB_PLATFORM)/libs.mk -# We're linking them directly to Harbour dynlib now. -#ifneq ($(HB_HAS_PCRE_LOCAL),) -# SYSLIBS += hbpcre -#endif -#ifneq ($(HB_HAS_ZLIB_LOCAL),) -# SYSLIBS += hbzlib -#endif - include $(TOP)$(ROOT)config/$(HB_PLATFORM)/$(HB_COMPILER).mk include $(TOP)$(ROOT)config/c.mk include $(TOP)$(ROOT)config/prg.mk -HB_LIBS_TPL = \ - hbextern \ - hbdebug \ - $(_HB_VM) \ +ifeq ($(HB_LINKING_VMMT),yes) + _HB_VM := hbvmmt +else + _HB_VM := hbvm +endif + +HB_DYN_LIBS := \ + hbcommon \ + hbpp \ hbrtl \ + hbmacro \ hblang \ hbcpage \ - $(HB_GT_LIBS) \ - $(_HB_RDD) \ - hbrtl \ + hbextern \ + hbrdd \ + rddntx \ + rddnsx \ + rddcdx \ + rddfpt \ + hbsix \ + hbhsx \ + hbusrrdd \ + gtcgi \ + gtpca \ + gtstd \ + gtwvt \ + gtgui \ + gtwin \ + gtos2 \ + gttrm \ + gtcrs \ + gtsln \ + gtxwc \ $(_HB_VM) \ - hbmacro \ - hbcplr \ - hbpp \ - hbcommon + hbmaindllh + +ifneq ($(HB_HAS_PCRE_LOCAL),) + HB_DYN_LIBS += hbpcre +endif +ifneq ($(HB_HAS_ZLIB_LOCAL),) + HB_DYN_LIBS += hbzlib +endif + +# hbcplr \ +# hbdebug \ + +ifneq ($(HB_HAS_PCRE_LOCAL),) + HB_DYN_LIBS += hbpcre +endif +ifneq ($(HB_HAS_ZLIB_LOCAL),) + HB_DYN_LIBS += hbzlib +endif + DYN_FILE := IMP_FILE := @@ -63,7 +93,11 @@ ifneq ($(IMP_DIR),) IMP_FILE := $(IMP_DIR)/$(IMP_NAME) endif -ALL_OBJS := $(subst /,$(DIRSEP),$(foreach dir,$(DYNDIRLIST),$(wildcard $(TOP)$(ROOT)$(dir)/$(OBJ_DIR)/*$(OBJ_DYN_POSTFIX)$(OBJ_EXT)))) +ifeq ($(HB_DYN_FROM_LIBS),yes) + ALL_OBJS := $(subst /,$(DIRSEP),$(foreach lib,$(HB_DYN_LIBS),$(wildcard $(LIB_DIR)/$(LIB_PREF)$(lib)$(LIB_EXT)))) +else + ALL_OBJS := $(subst /,$(DIRSEP),$(foreach dir,$(DYNDIRLIST),$(wildcard $(TOP)$(ROOT)$(dir)/$(OBJ_DIR)/*$(OBJ_DYN_POSTFIX)$(OBJ_EXT)))) +endif first:: dirbase descend diff --git a/harbour/config/global.mk b/harbour/config/global.mk index c920e4249c..e67f213154 100644 --- a/harbour/config/global.mk +++ b/harbour/config/global.mk @@ -1354,7 +1354,7 @@ ifeq ($(HB_INIT_DONE),) endif endif - ifeq ($(HB_PLATFORM)-$(HB_COMPILER),dos-watcom) + ifeq ($(HB_PLATFORM),dos) HB_DYNLIB_BASE_ST := harbour HB_DYNLIB_BASE_MT := harbourm HB_DYNLIB_ST := $(HB_DYNLIB_BASE_ST) diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 39e896017f..4cce18b11e 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -1123,6 +1123,7 @@ extern void * hb_i18n_alloc( void * cargo ); #endif /* _HB_API_INTERNAL_ || _HB_I18N_INTERNAL_ */ extern HB_EXPORT void hb_vmSetLinkedMain( const char * szMain ); +extern HB_EXPORT void hb_vmSetDefaultGT( const char * szGtName ); /* misc */ extern HB_EXPORT const char * hb_verCPU( void ); /* retrieves a constant string with CPU architecture */ diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index e921076c48..c45e2ddf7c 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -156,6 +156,7 @@ typedef struct extern void hb_gtIsGtRef( void * ); extern HB_EXPORT void hb_gtStartupInit( void ); +extern HB_EXPORT void hb_gtSetDefault( const char * szGtName ); extern HB_EXPORT void * hb_gtAlloc( void * hGT ); extern HB_EXPORT void hb_gtRelease( void * hGT ); extern HB_EXPORT void hb_gtAttach( void * hGT ); diff --git a/harbour/include/hbgtcore.h b/harbour/include/hbgtcore.h index b2395e7b50..0b3d8e7798 100644 --- a/harbour/include/hbgtcore.h +++ b/harbour/include/hbgtcore.h @@ -590,7 +590,6 @@ extern void hb_gt_gcMark( void ); #define HB_GTSUPER_GFXTEXT(g,t,l,s,c,h,w) (HB_GTSUPERTABLE(g))->GfxText(g,t,l,s,c,h,w) #define HB_GTSUPER_WHOCARES(g,p) (HB_GTSUPERTABLE(g))->WhoCares(g,p) -extern HB_EXPORT void hb_gtSetDefault( const char * szGtName ); extern HB_EXPORT BOOL hb_gtRegister( const HB_GT_INIT * gtInit ); extern HB_EXPORT PHB_GT hb_gtLoad( const char * szGtName, PHB_GT pGT, PHB_GT_FUNCS pSuperTable ); diff --git a/harbour/src/vm/dynlibhb.c b/harbour/src/vm/dynlibhb.c index b865e87cf5..1c2ac4e441 100644 --- a/harbour/src/vm/dynlibhb.c +++ b/harbour/src/vm/dynlibhb.c @@ -68,7 +68,9 @@ #if !defined( HB_HAS_DLFCN ) && \ ( ( defined( HB_OS_LINUX ) && !defined( __WATCOMC__ ) ) || \ defined( HB_OS_SUNOS ) || defined( HB_OS_DARWIN ) || \ - defined( HB_OS_BSD ) || defined( HB_OS_BEOS ) ) + defined( HB_OS_BSD ) || defined( HB_OS_BEOS ) || \ + ( defined( __DJGPP__ ) && \ + ( __DJGPP__ > 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ >= 4 ) ) ) ) # define HB_HAS_DLFCN #endif diff --git a/harbour/src/vm/hvm.c b/harbour/src/vm/hvm.c index cb8c782ec0..1a0a9efde3 100644 --- a/harbour/src/vm/hvm.c +++ b/harbour/src/vm/hvm.c @@ -11514,6 +11514,11 @@ void hb_vmSetLinkedMain( const char * szMain ) s_vm_pszLinkedMain = szMain; } +void hb_vmSetDefaultGT( const char * szGtName ) +{ + hb_gtSetDefault( szGtName ); +} + /* Force linking default language and codepage modules */ HB_CODEPAGE_REQUEST( HB_CODEPAGE_DEFAULT ) HB_LANG_REQUEST( HB_LANG_DEFAULT ) diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 3749770d34..0f579d5701 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -3700,11 +3700,6 @@ FUNCTION hbmk( aArgs, /* @ */ lPause ) 'HB_CALL_ON_STARTUP_BEGIN( _hb_hbmk_setdef_ )' + Chr( 10 ) ELSE cFile += '#include "hbinit.h"' + Chr( 10 ) +; - '' + Chr( 10 ) +; - 'HB_EXTERN_BEGIN' + Chr( 10 ) +; - 'extern ' + tmp + ' void hb_vmSetLinkedMain( const char * szMain );' + Chr( 10 ) +; - 'extern ' + tmp + ' void hb_gtSetDefault( const char * szGtName );' + Chr( 10 ) +; - 'HB_EXTERN_END' + Chr( 10 ) +; '' + Chr( 10 ) +; 'HB_CALL_ON_STARTUP_BEGIN( _hb_hbmk_setdef_ )' + Chr( 10 ) ENDIF @@ -3713,7 +3708,7 @@ FUNCTION hbmk( aArgs, /* @ */ lPause ) hbmk[ _HBMK_nHBMODE ] == _HBMODE_XHB cFile += ' s_defaultGT = "' + Upper( SubStr( hbmk[ _HBMK_cGT ], 3 ) ) + '";' + Chr( 10 ) ELSE - cFile += ' hb_gtSetDefault( "' + Upper( SubStr( hbmk[ _HBMK_cGT ], 3 ) ) + '" );' + Chr( 10 ) + cFile += ' hb_vmSetDefaultGT( "' + Upper( SubStr( hbmk[ _HBMK_cGT ], 3 ) ) + '" );' + Chr( 10 ) ENDIF ENDIF IF l_cMAIN != NIL