2009-08-20 20:07 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* utils/hbmk2/hbmk2.prg
  * config/global.mk
    ! Fixed to -undef:__PLATFORM__UNIX even for Windows host platforms.
      This is required because Cygwin builds have this envvar set.
      I'm not sure that setting __PLATFORM__UNIX for Cygwin is right
      behavior though.

  * config/dos/watcom.mk
  * config/win/watcom.mk
  * config/linux/watcom.mk
  * config/os2/watcom.mk
  + config/common/watcom.mk
    % Moved common watcom compiler specific make logic to one file.
      I've choosen OS/2 rules in this global makefile, as they will
      work on all platforms, albeit in the known slighly hacky way.
      It's easy to reintroduce shell specific rules for more advanced
      shells. There was one common rule set for nt/dos shells, plus
      a very clean one for sh. I may do this in a next commit.
      After this change it's possible to create all possible watcom
      cross-builds. Pls shout if I missed something or the concept
      seems to have some potential flaws.
    ; QUESTION: Does 'wlib' support '-p=64' option on Linux watcom builds?
    ; NOTE: Still most of the not yet merged logic could be merged,
            since there is only a few minor difference between them.
    ; TODO: Add shell optimized watcom rules for nt/dos/sh shells.
    ; TODO: Try to do a similar stunt for gcc.mk files.

  * source/pp/ppcore.c
    * #ifdef -> #if defined()
This commit is contained in:
Viktor Szakats
2009-08-20 18:16:55 +00:00
parent d56a65142e
commit dca33ebdd1
9 changed files with 127 additions and 223 deletions

View File

@@ -17,6 +17,37 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-08-20 20:07 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbmk2/hbmk2.prg
* config/global.mk
! Fixed to -undef:__PLATFORM__UNIX even for Windows host platforms.
This is required because Cygwin builds have this envvar set.
I'm not sure that setting __PLATFORM__UNIX for Cygwin is right
behavior though.
* config/dos/watcom.mk
* config/win/watcom.mk
* config/linux/watcom.mk
* config/os2/watcom.mk
+ config/common/watcom.mk
% Moved common watcom compiler specific make logic to one file.
I've choosen OS/2 rules in this global makefile, as they will
work on all platforms, albeit in the known slighly hacky way.
It's easy to reintroduce shell specific rules for more advanced
shells. There was one common rule set for nt/dos shells, plus
a very clean one for sh. I may do this in a next commit.
After this change it's possible to create all possible watcom
cross-builds. Pls shout if I missed something or the concept
seems to have some potential flaws.
; QUESTION: Does 'wlib' support '-p=64' option on Linux watcom builds?
; NOTE: Still most of the not yet merged logic could be merged,
since there is only a few minor difference between them.
; TODO: Add shell optimized watcom rules for nt/dos/sh shells.
; TODO: Try to do a similar stunt for gcc.mk files.
* source/pp/ppcore.c
* #ifdef -> #if defined()
2009-08-20 15:49 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* config/global.mk
! Fixed dos autodetection to not be overridden by explicit

View File

@@ -0,0 +1,82 @@
#
# $Id$
#
# GNU MAKE file for Open Watcom C/C++ compiler
# ---------------------------------------------------------------
# See option docs here:
# http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/compiler-tools/cpopts.html
# http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/compiler-tools/wlink.html
# http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/compiler-tools/wlib.html
# ---------------------------------------------------------------
ifeq ($(CC),wcc386)
ifneq ($(HB_HOST_ARCH),linux)
CPPFLAGS := $(subst /,\,$(CPPFLAGS))
CC_RULE = $(CC) $(subst /,\,$(HB_INC_DEPEND)) $(CPPFLAGS) $(subst /,\,$(CFLAGS)) $(subst /,\,$(HB_CFLAGS)) $(subst /,\,$(HB_USER_CFLAGS)) $(CC_OUT)$(<F:.c=$(OBJ_EXT)) $(CC_IN)$(subst /,\,$<)
endif
endif
LDLIBS := $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib))
# NOTE: Hack to force no extension for Linux binaries created on non-Linux hosts.
# Otherwise they become '.elf'. [vszakats]
ifeq ($(HB_ARCHITECTURE),linux)
ifneq ($(HB_HOST_ARCH),linux)
BIN_EXT := .
endif
endif
comma := ,
LDFILES_COMMA = $(subst $(subst x,x, ),$(comma) ,$(^F))
LDLIBS_COMMA := $(subst $(subst x,x, ),$(comma) ,$(strip $(LDLIBS)))
LD_RULE = $(LD) $(LDFLAGS) $(HB_USER_LDFLAGS) NAME $(BIN_DIR)/$@$(BIN_EXT) FILE $(LDFILES_COMMA) $(if $(LDLIBS_COMMA), LIB $(LDLIBS_COMMA),)
ifeq ($(HB_SHELL),sh)
create_library = $(AR) $(ARFLAGS) $(HB_USER_AFLAGS) $(LIB_DIR)/$@ $(foreach file,$(^F),-+$(file))
else
# maximum size of command line in OS2 is limited to 1024 characters
# the trick with divided 'wordlist' is workaround for it:
# -$(if $(wordlist 1,100,$(^F)), $(ECHO) $(wordlist 1,100,$(addprefix -+,$(^F))) >> __lib__.tmp,)
# -$(if $(wordlist 101,200,$(^F)), $(ECHO) $(wordlist 101,200,$(addprefix -+,$(^F))) >> __lib__.tmp,)
# -$(if $(wordlist 201,300,$(^F)), $(ECHO) $(wordlist 301,300,$(addprefix -+,$(^F))) >> __lib__.tmp,)
# anyhow OS/2 port# of GNU make 3.81 seems to have bug and GPFs when total
# commands length is too big so for %i in ( *$(OBJ_EXT) ) do ... below is
# ugly workaround for both problems
ifeq ($(HB_SHELL),nt)
FILE := %%f
else
FILE := %f
endif
define create_library
@$(ECHO) $(LIB_DIR)/$@ > __lib__.tmp
for $(FILE) in ( *$(OBJ_EXT) ) do @$(ECHO) -+$(FILE) >> __lib__.tmp
$(AR) $(ARFLAGS) $(HB_USER_AFLAGS) @__lib__.tmp
endef
endif
AR := wlib
ARFLAGS := -q -p=64 -c -n
AR_RULE = $(create_library)
ifeq ($(HB_SHELL),dos)
# disable DOS/4GW Banner
export DOS4G := quiet
# work arround to DOS command line size limit
ifeq ($(CC),wcc386)
export WCC386 := $(strip $(CPPFLAGS))
else
export WPP386 := $(strip $(CPPFLAGS))
endif
CPPFLAGS :=
export HARBOURCMD := $(HB_FLAGS)
HB_FLAGS :=
endif
include $(TOP)$(ROOT)config/rules.mk

View File

@@ -42,6 +42,7 @@ ifneq ($(HB_BUILD_OPTIM),no)
# optimization flags
# don't enable -ol optimization in OpenWatcom 1.1 - gives buggy code
# -oxaht
CPPFLAGS += -onaehtr -s -ei -zp4 -zt0
#CPPFLAGS += -obl+m
ifeq ($(CC),wpp386)
@@ -57,33 +58,6 @@ ifeq ($(HB_BUILD_DEBUG),yes)
CPPFLAGS += -d2
endif
ifeq ($(CC),wcc386)
ifneq ($(HB_HOST_ARCH),linux)
CPPFLAGS := $(subst /,\,$(CPPFLAGS))
CC_RULE = $(CC) $(subst /,\,$(HB_INC_DEPEND)) $(CPPFLAGS) $(subst /,\,$(CFLAGS)) $(subst /,\,$(HB_CFLAGS)) $(subst /,\,$(HB_USER_CFLAGS)) $(CC_OUT)$(<F:.c=$(OBJ_EXT)) $(CC_IN)$(subst /,\,$<)
endif
endif
# NOTE: The empty line directly before 'endef' HAVE TO exist!
# It causes that every command will be separated by LF
define link_file
@$(ECHO) FILE $(file) >> __link__.tmp
endef
# NOTE: The empty line directly before 'endef' HAVE TO exist!
define link_lib
@$(ECHO) LIB $(lib) >> __link__.tmp
endef
define link_exe_file
@$(ECHO) $(LDFLAGS) NAME $(BIN_DIR)/$@ > __link__.tmp
$(foreach file,$(^F),$(link_file))
$(foreach lib,$(LDLIBS),$(link_lib))
-$(LD) @__link__.tmp
endef
LD := wlink
ifeq ($(HB_BUILD_DEBUG),yes)
LDFLAGS += DEBUG ALL
@@ -96,41 +70,6 @@ else
LDFLAGS += SYS dos4g OP STUB=wstubq.exe
endif
LDLIBS := $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib))
LD_RULE = $(link_exe_file) $(HB_USER_LDFLAGS)
# NOTE: The empty line directly before 'endef' HAVE TO exist!
define lib_object
@$(ECHO) -+$(file) >> __lib__.tmp
endef
define create_library
@$(ECHO) $(LIB_DIR)/$@ > __lib__.tmp
$(foreach file,$(^F),$(lib_object))
$(AR) $(ARFLAGS) $(HB_USER_AFLAGS) @__lib__.tmp
endef
AR := wlib
ARFLAGS := -q -p=64 -c -n
AR_RULE = $(create_library)
ifeq ($(HB_SHELL),dos)
# disable DOS/4GW Banner
export DOS4G := quiet
# work arround to DOS command line size limit
ifeq ($(CC),wcc386)
export WCC386 := $(strip $(CPPFLAGS))
else
export WPP386 := $(strip $(CPPFLAGS))
endif
CPPFLAGS :=
export HARBOURCMD := $(HB_FLAGS)
HB_FLAGS :=
endif
include $(TOP)$(ROOT)config/common/watcom.mk
include $(TOP)$(ROOT)config/rules.mk

View File

@@ -26,7 +26,6 @@
# TOFIX: $(realpath/abspath) need GNU Make 3.81 or upper
# TOFIX: $(eval) needs GNU Make 3.80 or upper
ifeq ($(GLOBAL_CF_),)
GLOBAL_CF_ := yes
@@ -818,6 +817,8 @@ ifneq ($(HB_HOST_ARCH)$(HB_HOST_CPU),$(HB_ARCHITECTURE)$(HB_CPU))
# Setup platform macros (undefine host, define target)
ifeq ($(HB_HOST_ARCH),win)
HB_PRGFLAGS += -undef:__PLATFORM__WINDOWS
# We only need this to avoid problems with using Cygwin binaries as native ones.
HB_PRGFLAGS += -undef:__PLATFORM__UNIX
else
ifeq ($(HB_HOST_ARCH),dos)
HB_PRGFLAGS += -undef:__PLATFORM__DOS

View File

@@ -66,40 +66,6 @@ ifeq ($(HB_BUILD_DEBUG),yes)
endif
LDFLAGS += SYS linux
LDLIBS := $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib))
comma := ,
LDFILES_COMMA = $(subst $(subst x,x, ),$(comma) ,$(^F))
LDLIBS_COMMA := $(subst $(subst x,x, ),$(comma) ,$(strip $(LDLIBS)))
ifneq ($(HB_SHELL),sh)
LD_RULE = $(LD) $(LDFLAGS) $(HB_USER_LDFLAGS) NAME $(BIN_DIR)/$@. FILE $(LDFILES_COMMA)
else
LD_RULE = $(LD) $(LDFLAGS) $(HB_USER_LDFLAGS) NAME $(BIN_DIR)/$@ FILE $(LDFILES_COMMA)
endif
ifneq ($(LDLIBS_COMMA),)
LD_RULE += LIB $(LDLIBS_COMMA)
endif
AR := wlib
# ARFLAGS := -q -c -n -fa
ARFLAGS := -q -c -n
AR_RULE = $(AR) $(ARFLAGS) $(HB_USER_AFLAGS) $(LIB_DIR)/$@ $(foreach file,$(^F),-+$(file))
ifeq ($(HB_SHELL),dos)
# disable DOS/4GW Banner
export DOS4G := quiet
# work arround to DOS command line size limit
ifeq ($(CC),wcc386)
export WCC386 := $(strip $(CPPFLAGS))
else
export WPP386 := $(strip $(CPPFLAGS))
endif
CPPFLAGS :=
export HARBOURCMD := $(HB_FLAGS)
HB_FLAGS :=
endif
include $(TOP)$(ROOT)config/common/watcom.mk
include $(TOP)$(ROOT)config/rules.mk

View File

@@ -42,6 +42,7 @@ ifneq ($(HB_BUILD_OPTIM),no)
# optimization flags
# don't enable -ol optimization in OpenWatcom 1.1 - gives buggy code
# -oxaht
CPPFLAGS += -onaehtr -s -ei -zp4 -zt0
#CPPFLAGS += -obl+m
ifeq ($(CC),wpp386)
@@ -59,70 +60,12 @@ ifeq ($(HB_BUILD_DEBUG),yes)
CPPFLAGS += -d2
endif
ifeq ($(CC),wcc386)
ifneq ($(HB_HOST_ARCH),linux)
CPPFLAGS := $(subst /,\,$(CPPFLAGS))
CC_RULE = $(CC) $(subst /,\,$(HB_INC_DEPEND)) $(CPPFLAGS) $(subst /,\,$(CFLAGS)) $(subst /,\,$(HB_CFLAGS)) $(subst /,\,$(HB_USER_CFLAGS)) $(CC_OUT)$(<F:.c=$(OBJ_EXT)) $(CC_IN)$(subst /,\,$<)
endif
endif
LD := wlink
ifeq ($(HB_BUILD_DEBUG),yes)
LDFLAGS += DEBUG ALL
endif
LDFLAGS += SYS os2v2
LDLIBS := $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib))
comma := ,
LDFILES_COMMA = $(subst $(subst x,x, ),$(comma) ,$(^F))
LDLIBS_COMMA := $(subst $(subst x,x, ),$(comma) ,$(strip $(LDLIBS)))
LD_RULE = $(LD) $(LDFLAGS) $(HB_USER_LDFLAGS) NAME $(BIN_DIR)/$@ FILE $(LDFILES_COMMA) $(if $(LDLIBS_COMMA), LIB $(LDLIBS_COMMA),)
ifeq ($(HB_SHELL),sh)
create_library = $(AR) $(ARFLAGS) $(HB_USER_AFLAGS) $(LIB_DIR)/$@ $(foreach file,$(^F),-+$(file))
else
# maximum size of command line in OS2 is limited to 1024 characters
# the trick with divided 'wordlist' is workaround for it:
# -$(if $(wordlist 1,100,$(^F)), $(ECHO) $(wordlist 1,100,$(addprefix -+,$(^F))) >> __lib__.tmp,)
# -$(if $(wordlist 101,200,$(^F)), $(ECHO) $(wordlist 101,200,$(addprefix -+,$(^F))) >> __lib__.tmp,)
# -$(if $(wordlist 201,300,$(^F)), $(ECHO) $(wordlist 301,300,$(addprefix -+,$(^F))) >> __lib__.tmp,)
# anyhow OS2 port# of GNU make 3.81 seems to have bug and GPFs when total
# commands length is too big so for %i in ( *$(OBJ_EXT) ) do ... below is
# ugly workaround for both problems
ifeq ($(HB_SHELL),nt)
FILE := %%f
else
FILE := %f
endif
define create_library
@$(ECHO) $(LIB_DIR)/$@ > __lib__.tmp
for $(FILE) in ( *$(OBJ_EXT) ) do @$(ECHO) -+$(FILE) >> __lib__.tmp
$(AR) $(ARFLAGS) $(HB_USER_AFLAGS) @__lib__.tmp
endef
endif
AR := wlib
ARFLAGS := -q -p=64 -c -n
AR_RULE = $(create_library)
ifeq ($(HB_SHELL),dos)
# disable DOS/4GW Banner
export DOS4G := quiet
# work arround to DOS command line size limit
ifeq ($(CC),wcc386)
export WCC386 := $(strip $(CPPFLAGS))
else
export WPP386 := $(strip $(CPPFLAGS))
endif
CPPFLAGS :=
export HARBOURCMD := $(HB_FLAGS)
HB_FLAGS :=
endif
include $(TOP)$(ROOT)config/common/watcom.mk
include $(TOP)$(ROOT)config/rules.mk

View File

@@ -46,6 +46,7 @@ ifneq ($(HB_BUILD_OPTIM),no)
# don't enable -ol optimization in OpenWatcom 1.1 - gives buggy code
# -oxaht
CPPFLAGS += -onaehtr -s -ei -zp4 -zt0
#CPPFLAGS += -obl+m
ifeq ($(CC),wpp386)
CPPFLAGS += -oi+
else
@@ -61,75 +62,12 @@ ifeq ($(HB_BUILD_DEBUG),yes)
CPPFLAGS += -d2
endif
ifeq ($(CC),wcc386)
ifneq ($(HB_HOST_ARCH),linux)
CPPFLAGS := $(subst /,\,$(CPPFLAGS))
CC_RULE = $(CC) $(subst /,\,$(HB_INC_DEPEND)) $(CPPFLAGS) $(subst /,\,$(CFLAGS)) $(subst /,\,$(HB_CFLAGS)) $(subst /,\,$(HB_USER_CFLAGS)) $(CC_OUT)$(<F:.c=$(OBJ_EXT)) $(CC_IN)$(subst /,\,$<)
endif
endif
# NOTE: The empty line directly before 'endef' HAVE TO exist!
# It causes that every command will be separated by LF
define link_file
@$(ECHO) FILE $(file) >> __link__.tmp
endef
# NOTE: The empty line directly before 'endef' HAVE TO exist!
define link_lib
@$(ECHO) LIB $(lib) >> __link__.tmp
endef
define link_exe_file
@$(ECHO) $(LDFLAGS) NAME $(BIN_DIR)/$@ > __link__.tmp
$(foreach file,$(^F),$(link_file))
$(foreach lib,$(LDLIBS),$(link_lib))
-$(LD) @__link__.tmp
endef
LD := wlink
ifeq ($(HB_BUILD_DEBUG),yes)
LDFLAGS += DEBUG ALL
endif
LDFLAGS += SYS nt
LDLIBS := $(foreach lib,$(LIBS),$(LIB_DIR)/$(lib))
LDLIBS += $(foreach lib,$(SYSLIBS),$(lib))
LD_RULE = $(link_exe_file) $(HB_USER_LDFLAGS)
# NOTE: The empty line directly before 'endef' HAVE TO exist!
define lib_object
@$(ECHO) -+$(file) >> __lib__.tmp
endef
define create_library
@$(ECHO) $(LIB_DIR)/$@ > __lib__.tmp
$(foreach file,$(^F),$(lib_object))
$(AR) $(ARFLAGS) $(HB_USER_AFLAGS) @__lib__.tmp
endef
AR := wlib
ARFLAGS := -q -p=64 -c -n
AR_RULE = $(create_library)
ifeq ($(HB_SHELL),dos)
# disable DOS/4GW Banner
export DOS4G := quiet
# work arround to DOS command line size limit
ifeq ($(CC),wcc386)
export WCC386 := $(strip $(CPPFLAGS))
else
export WPP386 := $(strip $(CPPFLAGS))
endif
CPPFLAGS :=
export HARBOURCMD := $(HB_FLAGS)
HB_FLAGS :=
endif
include $(TOP)$(ROOT)config/common/watcom.mk
include $(TOP)$(ROOT)config/rules.mk

View File

@@ -5361,7 +5361,7 @@ void hb_pp_initDynDefines( PHB_PP_STATE pState )
hb_xfree( szPlatform );
hb_pp_addDefine( pState, szDefine, szResult );
#ifdef HB_OS_UNIX
#if defined( HB_OS_UNIX )
hb_strncpy( szDefine + 12, "UNIX", sizeof( szDefine ) - 13 );
hb_pp_addDefine( pState, szDefine, szResult );
#endif

View File

@@ -5677,6 +5677,10 @@ STATIC PROCEDURE PlatformPRGFlags( hbmk, aOPTPRG )
#if defined( __PLATFORM__WINCE )
AAdd( aUnd, "__PLATFORM__WINCE" )
#endif
/* This is defined with Cygwin */
#if defined( __PLATFORM__UNIX )
AAdd( aUnd, "__PLATFORM__UNIX" )
#endif
#elif defined( __PLATFORM__DOS )
AAdd( aUnd, "__PLATFORM__DOS" )
#elif defined( __PLATFORM__OS2 )