From: Przemyslaw C. <dr...@ac...> - 2009-03-25 20:51:46
|
Hi Phil, I see that you are using static Harbour functions inside #pragma begindump C code and then preprocess generated .c files with sed to convert declarations from HB_FUNC_EXTERN() to HB_FUNC_STATIC(). It effectively blocks using hbcmp directly to compile .prg files to .o ones so it's still necessary to define HB_INC_INSTALL and HB_LIB_INSTALL. It will be much easier to use only [x]hbcmp and [x]hbcc/[x]hblnk just like in xHGtk without setting any external variables. Probably only one simple variable HB_PREF will be enough to give support for Harbour and xHarbour compilation (also cross compilation). I.e. compile configuration can look like: # by default build Harbour platform native binaries # for xHarbour use HB_PREF=xhb # you can also set prefix for cross compilation, f.e.: # HB_PREF=hbw # Harbour Win32 cross build binaries (MinGW32) # HB_PREF=xhbw # xHarbour Win32 cross build binaries (MinGW32) ifeq ($(HB_PREF),) HB_PREF=hb endif OBJ_DIR = obj-$(HB_PREF) LIB_DIR = lib-$(HB_PREF) PRG_RULE = $(HB_PREF)cmp $(PRGFLAGS) -o$@ $< CC_RULE = $(HB_PREF)cc -c $(CFLAGS) -o$@ $< $(OBJ_DIR)/%.o: %.prg $(PRG_RULE) $(OBJ_DIR)/%.o: %.c $(CC_RULE) You can also make small trick to increase a little bit the compilation speed by reducing number of calls to pkg-config. Instead of: GTK_CFLAGS = `pkg-config --cflags gtk+-2.0` you can use: GTK_CFLAGS := $(shell pkg-config --cflags gtk+-2.0) It should cause that pkg-config will be executed only once in the above line instead of calling it in each rule. But to use [x]hb* scripts only (or hbmk2 in the future) it's necessary to resolve the problem with static Harbour functions inside #pragma {begin,end}dump in .prg files and eliminate sed. I do not like it but I cannot give you any reasonable alternative so I'll add to Harbour some very simple support for detecting such functions though it will work in a little bit different way then in xHarbour. It will only look for static functions used also in .prg code and will make some basic tokenization to eliminate comments, strings and operate only on whole words. However it will not know anything about C syntax and C preprocessing so it will not work correctly for code like: #if 0 HB_FUNC_STATIC( MYFUNC ) #else HB_FUNC( MYFUNC ) #endif { hb_retc( "MyFunc" ); } but for xbgtk and probably 99% of other cases it's enough. Seems that it's better/safer solution then external updating of generated .c files. There is still open the question about localization of final libraries in make install but I think we can resolve it by adding new switch to hb* scripts, f.e. --hblibdir so they can be used just like pkg-config: HB_LIB_INSTALL := $(shell hbmk --hblibdir) HB_INC_INSTALL := $(shell hbmk --hbincdir) You can easy add it also to xhb* scripts. It should help in creating really simple make files which should work also in other systems supported by [x]hb* scripts, f.e. in SunOS without any explicit support for them. [x]hb* scripts will make the whole job. HTH, best regards, Przemek |