From da8d31c9d5154793ee4448ef0a60114a636014f8 Mon Sep 17 00:00:00 2001 From: sezero Date: Tue, 11 Sep 2018 23:00:02 +0300 Subject: [PATCH] Makefile.mingw: revise so that it works for both cross- and native-builds --- glide2x/Makefile.mingw | 6 ++++ glide2x/cvg/glide/src/Makefile.mingw | 46 +++++++++++++++++++++++--- glide2x/h3/glide/src/Makefile.mingw | 43 +++++++++++++++++++++--- glide2x/sst1/glide/src/Makefile.mingw | 43 +++++++++++++++++++++--- glide3x/Makefile.mingw | 6 ++++ glide3x/cvg/glide3/src/Makefile.mingw | 46 +++++++++++++++++++++++--- glide3x/h3/glide3/src/Makefile.mingw | 46 +++++++++++++++++++++++--- glide3x/h5/glide3/src/Makefile.mingw | 42 ++++++++++++++++++++--- glide3x/h5/glide3/tests/Makefile.mingw | 25 +++++++++++++- glide3x/sst1/glide3/src/Makefile.mingw | 46 +++++++++++++++++++++++--- 10 files changed, 313 insertions(+), 36 deletions(-) diff --git a/glide2x/Makefile.mingw b/glide2x/Makefile.mingw index 07b05ee..a1b5b5c 100644 --- a/glide2x/Makefile.mingw +++ b/glide2x/Makefile.mingw @@ -9,6 +9,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # FX_GLIDE_HW build for the given ASIC (sst1, sst96, cvg, h3). # default = h3 diff --git a/glide2x/cvg/glide/src/Makefile.mingw b/glide2x/cvg/glide/src/Makefile.mingw index d705fbe..3035f51 100644 --- a/glide2x/cvg/glide/src/Makefile.mingw +++ b/glide2x/cvg/glide/src/Makefile.mingw @@ -15,6 +15,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # CPU optimize for the given processor. # default = -mtune=pentium @@ -58,16 +64,36 @@ GLIDE_LIBDIR = ../../lib # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -162,8 +188,12 @@ CFLAGS += -DGL_AMD3D override USE_X86 = 1 endif +ifeq ($(WINMODE),1) +HOST_CFLAGS=$(CFLAGS) +else # for cross-builds HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -DFX_DLL_ENABLE -march=%,$(CFLAGS)) +endif ############################################################################### # objects @@ -269,6 +299,12 @@ $(GLIDE_LIBDIR)/fxoem2x.dll: # $(warning FxOem2x not enabled... Skipping fxoem2x.dll) endif +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) +#ifeq ($(FXOEM2X),1) +# $(STRIP) $(GLIDE_LIBDIR)/fxoem2x.dll +#endif + ############################################################################### # rules(2) ############################################################################### diff --git a/glide2x/h3/glide/src/Makefile.mingw b/glide2x/h3/glide/src/Makefile.mingw index 3739098..de41f36 100644 --- a/glide2x/h3/glide/src/Makefile.mingw +++ b/glide2x/h3/glide/src/Makefile.mingw @@ -11,6 +11,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # H4=1 High speed Avenger. # default = no @@ -52,16 +58,36 @@ GLIDE_LIBDIR = ../../lib # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -152,11 +178,15 @@ ifeq ($(USE_X86),1) CFLAGS += -DGL_X86 endif +ifeq ($(WINMODE),1) +HOST_CFLAGS=$(CFLAGS) +else # for cross-builds # note that with this, fxgasm outputs wrong (20 bytes shorter) SIZEOF_GC and SIZEOF_GrState # values in fxgasm.h - everything else is the same (compared to fxgasm.h generated by MSVC 6). # those two are not used by the asm sources, so we are good. HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -DFX_DLL_ENABLE -DHWC_EXT_INIT=% -march=%,$(CFLAGS)) +endif ############################################################################### # objects @@ -239,6 +269,9 @@ $(GLIDE_LIBDIR)/$(GLIDE_DLL): $(GLIDE_OBJECTS) $(GLIDE_RES) $(GLIDE_LIBDIR)/$(GLIDE_IMP): $(GLIDE_LIBDIR)/$(GLIDE_DLL) $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(GLIDE_DLL) --input-def $(GLIDE_LIBDIR)/$(GLIDE_DEF) --output-lib $@ +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) + ############################################################################### # rules(2) ############################################################################### diff --git a/glide2x/sst1/glide/src/Makefile.mingw b/glide2x/sst1/glide/src/Makefile.mingw index e639862..8b12b85 100644 --- a/glide2x/sst1/glide/src/Makefile.mingw +++ b/glide2x/sst1/glide/src/Makefile.mingw @@ -15,6 +15,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # FX_GLIDE_HW build for the given ASIC (either sst1, or sst96). # default = sst1 @@ -53,16 +59,36 @@ GLIDE_LIBDIR = ../../lib # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -141,8 +167,12 @@ ifneq ($(USE_X86),1) CFLAGS += -DGLIDE_USE_C_TRISETUP endif +ifeq ($(WINMODE),1) +HOST_CFLAGS=$(CFLAGS) +else # for cross-builds HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -DFX_DLL_ENABLE -march=%,$(CFLAGS)) +endif ############################################################################### # objects @@ -239,6 +269,9 @@ $(GLIDE_LIBDIR)/$(GLIDE_DLL): $(GLIDE_OBJECTS) $(GLIDE_RES) $(GLIDE_LIBDIR)/$(GLIDE_IMP): $(GLIDE_LIBDIR)/$(GLIDE_DLL) $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(GLIDE_DLL) --input-def $(GLIDE_LIBDIR)/$(GLIDE_DEF) --output-lib $@ +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) + ############################################################################### # rules(2) ############################################################################### diff --git a/glide3x/Makefile.mingw b/glide3x/Makefile.mingw index 138c215..522705e 100644 --- a/glide3x/Makefile.mingw +++ b/glide3x/Makefile.mingw @@ -9,6 +9,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # FX_GLIDE_HW build for the given ASIC (sst1, sst96, cvg, h3, h5). # default = h5 diff --git a/glide3x/cvg/glide3/src/Makefile.mingw b/glide3x/cvg/glide3/src/Makefile.mingw index 779b6c3..452615d 100644 --- a/glide3x/cvg/glide3/src/Makefile.mingw +++ b/glide3x/cvg/glide3/src/Makefile.mingw @@ -9,6 +9,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # OPTFLAGS pass given optimization flags to compiler # default = -O2 -ffast-math -mtune=pentium @@ -56,16 +62,36 @@ TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -154,8 +180,12 @@ else CFLAGS += -DGLIDE_USE_C_TRISETUP endif +ifeq ($(WINMODE),1) +HOST_CFLAGS=$(CFLAGS) +else # for cross-builds HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -DFX_DLL_ENABLE -march=%,$(CFLAGS)) +endif ############################################################################### # objects @@ -284,6 +314,12 @@ $(TEXUS_EXEDIR)/$(TEXUS_EXE): $(FX_GLIDE_SW)/texus2/cmd/cmd.c $(GLIDE_LIBDIR)/$( # $(warning Texus2 not enabled... Skipping $(TEXUS_EXE)) #endif +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) +#ifeq ($(TEXUS2),1) +# $(STRIP) $(TEXUS_EXEDIR)/$(TEXUS_EXE) +#endif + ############################################################################### # rules(2) ############################################################################### diff --git a/glide3x/h3/glide3/src/Makefile.mingw b/glide3x/h3/glide3/src/Makefile.mingw index 86755e9..1912967 100644 --- a/glide3x/h3/glide3/src/Makefile.mingw +++ b/glide3x/h3/glide3/src/Makefile.mingw @@ -9,6 +9,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # H4=1 High speed Avenger. # default = no @@ -54,16 +60,36 @@ TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -151,11 +177,15 @@ override USE_DRAWTRI_ASM = 1 endif endif +ifeq ($(WINMODE),1) +HOST_CFLAGS=$(CFLAGS) +else # for cross-builds # note that with this, fxgasm outputs wrong (20 bytes shorter) SIZEOF_GC and SIZEOF_GrState # values in fxgasm.h - everything else is the same (compared to fxgasm.h generated by MSVC 6). # those two are not used by the asm sources, so we are good. HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -DFX_DLL_ENABLE -DHWC_EXT_INIT=% -march=%,$(CFLAGS)) +endif ############################################################################### # objects @@ -274,6 +304,12 @@ $(TEXUS_EXEDIR)/$(TEXUS_EXE): $(FX_GLIDE_SW)/texus2/cmd/cmd.c $(GLIDE_LIBDIR)/$( # $(warning Texus2 not enabled... Skipping $(TEXUS_EXE)) #endif +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) +#ifeq ($(TEXUS2),1) +# $(STRIP) $(TEXUS_EXEDIR)/$(TEXUS_EXE) +#endif + ############################################################################### # rules(2) ############################################################################### diff --git a/glide3x/h5/glide3/src/Makefile.mingw b/glide3x/h5/glide3/src/Makefile.mingw index d6a5423..3900876 100644 --- a/glide3x/h5/glide3/src/Makefile.mingw +++ b/glide3x/h5/glide3/src/Makefile.mingw @@ -9,6 +9,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # H4=1 High speed Avenger/Napalm. # default = no @@ -60,16 +66,36 @@ TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -308,6 +334,12 @@ $(TEXUS_EXEDIR)/$(TEXUS_EXE): $(FX_GLIDE_SW)/texus2/cmd/cmd.c $(GLIDE_LIBDIR)/$( # $(warning Texus2 not enabled... Skipping $(TEXUS_EXE)) #endif +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) +#ifeq ($(TEXUS2),1) +# $(STRIP) $(TEXUS_EXEDIR)/$(TEXUS_EXE) +#endif + ############################################################################### # rules(2) ############################################################################### diff --git a/glide3x/h5/glide3/tests/Makefile.mingw b/glide3x/h5/glide3/tests/Makefile.mingw index 309b4ca..b27de78 100644 --- a/glide3x/h5/glide3/tests/Makefile.mingw +++ b/glide3x/h5/glide3/tests/Makefile.mingw @@ -8,6 +8,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # CPU optimize for the given processor. # default = pentium @@ -24,7 +30,24 @@ FX_GLIDE_HW = h5 TOP = ../../.. CPU ?= pentium -CC = mingw32-gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc + CFLAGS = -Wall -O2 -ffast-math -mtune=$(CPU) CFLAGS += -I$(TOP)/$(FX_GLIDE_HW)/glide3/src -I$(TOP)/$(FX_GLIDE_HW)/incsrc CFLAGS += -I$(TOP)/swlibs/fxmisc diff --git a/glide3x/sst1/glide3/src/Makefile.mingw b/glide3x/sst1/glide3/src/Makefile.mingw index 7bcd69a..dcce723 100644 --- a/glide3x/sst1/glide3/src/Makefile.mingw +++ b/glide3x/sst1/glide3/src/Makefile.mingw @@ -9,6 +9,12 @@ # # Available options: # +# CROSS cross-compiler toolchain prefix +# Needed when cross-compiling e.g. on Linux, +# as opposed to compiling on native Windows. +# default = i686-pc-mingw32- +# (Note that a trailing '-' is necessary.) +# # Environment variables: # FX_GLIDE_HW build for the given ASIC (either sst1, or sst96). # default = sst1 @@ -51,16 +57,36 @@ TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin # tools ############################################################################### -CC = gcc +# default cross-toolchain prefix +DEF_CROSS=i686-pc-mingw32- +#DEF_CROSS=i686-w64-mingw32- + +# detect if running under unix by finding 'rm' in $PATH : +ifeq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +WINMODE= 1 +UNLINK = del $(subst /,\,$(1)) +HOST_CC = $(CC) +else +WINMODE= 0 +UNLINK = $(RM) $(1) +ifeq ($(CROSS),) +CROSS=$(DEF_CROSS) +endif +endif + +CC = $(CROSS)gcc AS = nasm LD = $(CC) -RC = windres -DLLTOOL = dlltool +RC = $(CROSS)windres +DLLTOOL = $(CROSS)dlltool +STRIP = $(CROSS)strip +ifeq ($(WINMODE),1) +HOST_CC = $(CC) +else #for cross-builds HOST_CC = gcc - -UNLINK = $(RM) $(1) +endif ############################################################################### # defines @@ -146,8 +172,12 @@ else CFLAGS += -DGLIDE_USE_C_TRISETUP endif +ifeq ($(WINMODE),1) +HOST_CFLAGS=$(CFLAGS) +else # for cross-builds HOST_CFLAGS=$(filter-out -mcpu=% -mtune=% -DFX_DLL_ENABLE -march=%,$(CFLAGS)) +endif ############################################################################### # objects @@ -277,6 +307,12 @@ $(TEXUS_EXEDIR)/$(TEXUS_EXE): $(FX_GLIDE_SW)/texus2/cmd/cmd.c $(GLIDE_LIBDIR)/$( # $(warning Texus2 not enabled... Skipping $(TEXUS_EXE)) #endif +strip: + $(STRIP) $(GLIDE_LIBDIR)/$(GLIDE_DLL) +#ifeq ($(TEXUS2),1) +# $(STRIP) $(TEXUS_EXEDIR)/$(TEXUS_EXE) +#endif + ############################################################################### # rules(2) ###############################################################################