From eee8faf179c9b43c78b454b9b8a10ec4b8e48be4 Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Sun, 20 Jun 1999 01:43:59 +0000 Subject: [PATCH] See ChangeLog: 19990620-02:40 --- harbour/ChangeLog | 44 +++++++++++++++++++++++ harbour/config/bin.cf | 7 ++++ harbour/config/dos/dir.cf | 3 +- harbour/config/dos/djgpp.cf | 25 ++++++++++--- harbour/config/dos/global.cf | 31 ++++++++++++---- harbour/config/dos/install.cf | 2 +- harbour/config/dos/watcom.cf | 60 +++++++++++++++++++++++++++++++ harbour/config/lib.cf | 8 +++++ harbour/config/linux/gcc.cf | 2 +- harbour/config/rules.cf | 25 ++++++++++--- harbour/include/hbpp.h | 27 ++++++++++++++ harbour/source/compiler/harbour.l | 14 ++++++++ harbour/source/compiler/harbour.y | 6 ++-- harbour/source/hbpp/harb.h | 18 ++-------- 14 files changed, 235 insertions(+), 37 deletions(-) create mode 100644 harbour/config/dos/watcom.cf create mode 100644 harbour/include/hbpp.h diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6fa4e2ed3d..778bf48ec7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,47 @@ +19990620-02:40 Ryszard Glab + +* config/bin.cf +* config/lib.cfg +* config/rules.cf +* config/linux/gcc.cf +* config/win32/gcc.cf +* config/win32/msvc.cf +* config/dos/dir.cf +* config/dos/djgpp.cf +* config/dos/global.cf +* config/dos/install.cf ++ config/dos/watcom.cf + * added support for other compilers not compatible with gcc + (there were gcc switches hardcoded into common rules) + New compiler: Watcom C/C++ 10.0 + * changed rules for DJGPP - the Makefile can be used now to + create harbour with DJGPP. The makedos.env and makefile.dos + are obsolete now. + * cleared the use of '\' and '/' in make rules for DOS environment + * the make looks now for COMSPEC variable to locate the command.com + in DOS environment + * changed the rule for creating DJGPP library (archive) to use + script file instead of command line - there is a limit of 128 + characters that can be placed into command line in DOS + ++ include/hbpp.h + + new file with definition shared by the preprocessor and harbour.y + (needed to match the declaration of AddDefine function) + +* source/hbpp/harb.h + * changed to include the new hbpp.h file + +* source/compiler/harbour.y + * changed the declaration of yy_create_buffer to make it compatible + with C++ compilers + * added inclusion of hbpp.h (to keep C++ compilers happy with + AaddDefine function) + +* source/compiler/harbour.l + + added #pragma to suppress warnings of unreachable code when + compiled with Watcom C++ compiler + + 19990619-14:35 CET Matteo Baccan * makefile.vc, source/hbpp/hbpp.c, source/hbpp/hbppint.c, source/rtl/environ.c, source/rtl/files.c, source/rtl/gt/gtwin.c, diff --git a/harbour/config/bin.cf b/harbour/config/bin.cf index 81cb4cc9f5..4fe5190d58 100644 --- a/harbour/config/bin.cf +++ b/harbour/config/bin.cf @@ -6,7 +6,14 @@ include $(TOP)$(ROOT)config/global.cf include $(TOP)$(ROOT)config/c.cf EXE_NAME = $(C_MAIN:.c=$(EXE_EXT)) + +_EXE_ARCH = $(notdir $(ARCH_DIR)) +ifeq ($(_EXE_ARCH),) +# ARCH_DIR ends with a slash EXE_ARCH = $(ARCH_DIR)$(EXE_NAME) +else +EXE_ARCH = $(ARCH_DIR)/$(EXE_NAME) +endif ALL_OBJS = $(ALL_C_OBJS) $(ALL_PRG_OBJS) diff --git a/harbour/config/dos/dir.cf b/harbour/config/dos/dir.cf index b4862d5292..da1d1d470b 100644 --- a/harbour/config/dos/dir.cf +++ b/harbour/config/dos/dir.cf @@ -9,6 +9,7 @@ DIR_RULE =\ @echo Done else DIR_LIST = $(subst /,\,$(DIRS)) +DIR_MAKE = $(subst /,\,$(MK)) DIR_RULE =\ - command.com /c FOR %d IN ($(DIR_LIST)) DO $(MK) -C %d $@ + $(COMSPEC) /C FOR %d IN ($(DIR_LIST)) DO $(DIR_MAKE) -C %d $@ endif diff --git a/harbour/config/dos/djgpp.cf b/harbour/config/dos/djgpp.cf index ab91164ce4..2a3204d160 100644 --- a/harbour/config/dos/djgpp.cf +++ b/harbour/config/dos/djgpp.cf @@ -4,12 +4,13 @@ include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf -OBJ_EXT = .obj +OBJ_EXT = .o EXE_EXT = .exe -LIB_PREF = -LIB_EXT = .lib +LIB_PREF = lib +LIB_EXT = .a CC = gcc +CC_IN = -c CC_OUT = -o CPPFLAGS = -DDEBUG -I. -I$(HB_INC_DIR) CFLAGS = -Wall -g @@ -22,8 +23,24 @@ endif LINKLIBS = $(foreach lib, $(LIBS), -l$(lib)) # LINKLIBS += -lm +#Note: The empty line below HAVE TO exist! +define lib_object +echo ADDMOD $(file) >> __lib__.tmp + +endef + +define create_library +echo CREATE $@ > __lib__.tmp +$(foreach file, $^, $(lib_object)) +echo SAVE >> __lib__.tmp +echo END >> __lib__.tmp +$(AR) -M < __lib__.tmp +del __lib__.tmp +endef + AR = ar ARFLAGS = -AR_RULE = $(AR) $(ARFLAGS) r $@ $^ || $(RM) $@ +#AR_RULE = $(AR) $(ARFLAGS) r $@ $^ || $(RM) $@ +AR_RULE = $(create_library) include $(TOP)$(ROOT)config/rules.cf diff --git a/harbour/config/dos/global.cf b/harbour/config/dos/global.cf index 9724dfca42..51b0c0b7d7 100644 --- a/harbour/config/dos/global.cf +++ b/harbour/config/dos/global.cf @@ -2,10 +2,27 @@ # $Id$ # -ARCH_DIR = $(subst /,\,$(ARCH)\) -MK = $(subst /,\,$(subst \~,~,$(MAKE))) +all : first -RM = del /q +ARCH_DIR = $(subst \,/,$(ARCH)) +ARCH_DOS = $(subst /,\,$(ARCH)) +MK = $(subst \,/,$(subst \~,~,$(MAKE))) + +ifeq ($(HB_INC_DIR),) + HB_INC_DIR=$(TOP)$(ROOT)include +endif +ifeq ($(HB_LIB_DIR),) + HB_LIB_DIR=$(TOP)$(ROOT)libs +endif +ifeq ($(HB_BIN_DIR),) + HB_BIN_DIR=$(TOP)$(ROOT)bin +endif + +ifeq ($(COMSPEC),) #location of command.com + COMSPEC = command.com +endif + +RM = del RD = rmdir CP = copy MV = move @@ -13,9 +30,9 @@ MD = md dirbase:: -$(MD) $(HB_ARCHITECTURE) >NUL - -$(MD) $(ARCH_DIR) >NUL - + -$(MD) $(ARCH_DOS) >NUL clean:: - -$(RM) $(ARCH_DIR)\*.* - -$(RD) $(ARCH_DIR) + -echo Y | $(RM) $(ARCH_DOS)\*.* + -$(RD) $(ARCH_DOS) + -$(RD) $(HB_ARCHITECTURE) \ No newline at end of file diff --git a/harbour/config/dos/install.cf b/harbour/config/dos/install.cf index 3e147b8787..baf7508210 100644 --- a/harbour/config/dos/install.cf +++ b/harbour/config/dos/install.cf @@ -6,4 +6,4 @@ include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf INSTALL_LIST = $(subst /,\,$(INSTALL_OBJS)) INSTALL_RULE =\ - command.com /c FOR %f IN ($(INSTALL_LIST)) DO COPY %f $(INSTALL_DIR) + $(COMSPEC) /c FOR %f IN ($(INSTALL_LIST)) DO COPY %f $(subst /,\,$(INSTALL_DIR)) diff --git a/harbour/config/dos/watcom.cf b/harbour/config/dos/watcom.cf new file mode 100644 index 0000000000..0578af2811 --- /dev/null +++ b/harbour/config/dos/watcom.cf @@ -0,0 +1,60 @@ +# +# $Id$ +# + +include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf + +OBJ_EXT = .obj +EXE_EXT = .exe +LIB_PREF = +LIB_EXT = .lib + +$(HB_ARCHITECTURE)_$(HB_COMPILER)_GRANDP = $(subst /,\\,$(GRANDP)) +_HB_INC_DIR = $(subst /,\\,$(HB_INC_DIR)) +_HB_LIB_DIR = $(subst /,\,$(HB_LIB_DIR)) +WATCOM_INCLUDE = $(subst \,\\,$(WATCOM))\\h + +CC = wpp386 +CC_IN = +CC_OUT = -fo= +CPPFLAGS = -d2 -w2 -5r -zq -zt0 -bt=DOS4G +CFLAGS = -i$(WATCOM_INCLUDE) -i$(_HB_INC_DIR) -i. + +#Note: The empty line below HAVE TO exist! +define link_file +echo FILE $(file) >> __link__.tmp + +endef + +define link_exe_file +echo $(LDFLAGS) > __link__.tmp +echo NAME $@ >> __link__.tmp +$(foreach file, $^, $(link_file)) +echo $(LINKLIBS) >> __link__.tmp +$(LD) @__link__.tmp +del __link__.tmp +endef + +LD = wlink +LDFLAGS = debug all OP osn=DOS4G OP stack=16384 +LINKLIBS = LIBP $(_HB_LIB_DIR) LIB $(foreach lib, $(LIBS), $(lib)) +LD_RULE = $(link_exe_file) + +#Note: The empty line below HAVE TO exist! +define lib_object +echo -+$(file) >> __lib__.tmp + +endef + +define create_library +echo $@ > __lib__.tmp +$(foreach file, $^, $(lib_object)) +$(AR) @__lib__.tmp +del __lib__.tmp +endef + +AR = wlib +ARFLAGS = +AR_RULE = $(create_library) + +include $(TOP)$(ROOT)config/rules.cf diff --git a/harbour/config/lib.cf b/harbour/config/lib.cf index baff2cd569..046bc66a35 100644 --- a/harbour/config/lib.cf +++ b/harbour/config/lib.cf @@ -7,7 +7,15 @@ include $(TOP)$(ROOT)config/c.cf include $(TOP)$(ROOT)config/prg.cf LIB_NAME = $(LIB_PREF)$(LIB)$(LIB_EXT) + +_ARCH_DIR = $(notdir $(ARCH_DIR)) +ifeq ($(_ARCH_DIR),) +# ARCH_DIR ends with a slash LIB_ARCH = $(ARCH_DIR)$(LIB_NAME) +else +# there is no slash at the end of ARCH_DIR +LIB_ARCH = $(ARCH_DIR)/$(LIB_NAME) +endif ALL_OBJS = $(ALL_C_OBJS) $(ALL_PRG_OBJS) diff --git a/harbour/config/linux/gcc.cf b/harbour/config/linux/gcc.cf index 26e03c93b5..19e7e6479e 100644 --- a/harbour/config/linux/gcc.cf +++ b/harbour/config/linux/gcc.cf @@ -10,6 +10,7 @@ LIB_PREF = lib LIB_EXT = .a CC = gcc +CC_IN = -c CC_OUT = -o CPPFLAGS = -DDEBUG -I. -I$(HB_INC_DIR) CFLAGS = -Wall -g @@ -21,7 +22,6 @@ LDFLAGS = -L$(HB_LIB_DIR) endif LINKLIBS = $(foreach lib, $(LIBS), -l$(lib)) LINKLIBS += -L/usr/lib -lm -# LINKLIBS += -lm AR = ar ARFLAGS = diff --git a/harbour/config/rules.cf b/harbour/config/rules.cf index 57f34fc361..8570d96665 100644 --- a/harbour/config/rules.cf +++ b/harbour/config/rules.cf @@ -11,12 +11,20 @@ LEX = flex LEX_FLAGS = -i -8 # How to run Harbour. -HB = harbour$(EXE_EXT) +_HB = $(notdir $(HB_BIN_DIR)) +ifeq ($(_HB),) +# there is a slash at the end +HB = $(HB_BIN_DIR)harbour$(EXE_EXT) +else +HB = $(HB_BIN_DIR)/harbour$(EXE_EXT) +endif HB_FLAGS = -n -q -I$(TOP) -I$(HB_INC_DIR) # The rule to link an executable. +ifeq ($(LD_RULE),) +# Use default rule if architecture/compiler specific rule is not defined LD_RULE = $(LD) $(CFLAGS) $(LD_OUT)$@ $^ $(LDFLAGS) $(LINKLIBS) - +endif # Eliminate these rules. @@ -24,14 +32,21 @@ LD_RULE = $(LD) $(CFLAGS) $(LD_OUT)$@ $^ $(LDFLAGS) $(LINKLIBS) %.c : %.l +# Location of source C files +# Some DOS compilers doesn't like '/' in filenames - however the MAKE system +# requires '/' in filenames - this trick allows to solve this conflict +SOURCE_DIR := $($(HB_ARCHITECTURE)_$(HB_COMPILER)_GRANDP) +ifeq ($(SOURCE_DIR),) +SOURCE_DIR = $(GRANDP) +endif # Rule to generate an object file from a C source file in the parent. -%$(OBJ_EXT) : $(GRANDP)%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $? $(CC_OUT)$(subst .c,$(OBJ_EXT),$(subst $(GRANDP),,$?)) +%$(OBJ_EXT) : $(SOURCE_DIR)%.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_IN) $? $(CC_OUT)$(subst .c,$(OBJ_EXT),$(subst $(SOURCE_DIR),,$?)) # Rule to generate an object file from a C source file. %$(OBJ_EXT) : %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $? $(CC_OUT)$(?:.c=$(OBJ_EXT)) + $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_IN) $? $(CC_OUT)$(?:.c=$(OBJ_EXT)) # Rule to generate an executable file from an object file. %$(EXE_EXT) : %$(OBJ_EXT) diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h new file mode 100644 index 0000000000..c6e85df56d --- /dev/null +++ b/harbour/include/hbpp.h @@ -0,0 +1,27 @@ +/* + * $Id$ + * + * Definitions shared by harbour.y and preprocessor + */ + +#ifndef HBPP_H_ +#define HBPP_H_ + +/* ------------------------------------------ */ +typedef struct +{ + char *name; + char *pars; + int npars; + char *value; +} DEFINES; + +typedef struct +{ + int com_or_xcom; + char *name; + char *mpatt; + char *value; +} COMMANDS, TRANSLATES; + +#endif /* HBPP_H_ */ diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index c1978da865..140e986ba8 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -86,6 +86,13 @@ void yy_lex_count_lf( void ) %} +%{ +#ifdef __WATCOMC__ +/* disable warnings for unreachable code */ +#pragma warning 13 9 +#endif +%} + SpaceTab [ \t]+ InvalidNumber [0-9]+\. Number ([0-9]+)|([0-9]*\.[0-9]+) @@ -1319,6 +1326,13 @@ Separator {SpaceTab}|{Comment} } } +%{ +#ifdef __WATCOMC__ +/* enable warnings for unreachable code */ +#pragma warning 13 1 +#endif +%} + %% PDEFINE LastDef( PDEFINE pDef ) diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index bd6542381d..731a4b1e56 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -23,6 +23,7 @@ #include "types.h" /* our defined types */ #include "compiler.h" #include "hberrors.h" +#include "hbpp.h" #undef OurFree @@ -128,16 +129,17 @@ extern "C" int yywrap( void ); #else int yywrap( void ); /* manages the EOF of current processed file */ #endif -void AddDefine( char * szDefine, char * szValue ); /* add a new Lex define from the command line */ +DEFINES *AddDefine( char * szDefine, char * szValue ); /* add a new Lex define from the command line */ /* Following line added for preprocessor */ void Hbpp_init ( void ); -void * yy_create_buffer( FILE *, int ); /* yacc functions to manage multiple files */ #ifdef __cplusplus typedef struct yy_buffer_state *YY_BUFFER_STATE; +YY_BUFFER_STATE yy_create_buffer( FILE *, int ); /* yacc functions to manage multiple files */ void yy_switch_to_buffer( YY_BUFFER_STATE ); /* yacc functions to manage multiple files */ void yy_delete_buffer( YY_BUFFER_STATE ); /* yacc functions to manage multiple files */ #else +void * yy_create_buffer( FILE *, int ); /* yacc functions to manage multiple files */ void yy_switch_to_buffer( void * ); /* yacc functions to manage multiple files */ void yy_delete_buffer( void * ); /* yacc functions to manage multiple files */ #endif diff --git a/harbour/source/hbpp/harb.h b/harbour/source/hbpp/harb.h index 8b871cfdb5..d15465f23c 100644 --- a/harbour/source/hbpp/harb.h +++ b/harbour/source/hbpp/harb.h @@ -43,21 +43,7 @@ void * _xgrab( ULONG ); /* allocates fixed memory */ void * _xrealloc( void *, ULONG ); /* reallocates memory */ void _xfree( void * ); /* frees fixed memory */ -/* ------------------------------------------ */ -typedef struct -{ - char *name; - char *pars; - int npars; - char *value; -} DEFINES; - -typedef struct -{ - int com_or_xcom; - char *name; - char *mpatt; - char *value; -} COMMANDS, TRANSLATES; +/* includes common definitions shared by preprocessor and harbour.y */ +#include "hbpp.h" #endif /* HARB_H_ */