diff --git a/GNUbaserules.mk b/GNUbaserules.mk index fa8e90fd..cd66f0bc 100644 --- a/GNUbaserules.mk +++ b/GNUbaserules.mk @@ -1,8 +1,5 @@ # 16 october 2015 -OUTDIR = out -OBJDIR = .obj - OFILES = \ $(subst /,_,$(CFILES)) \ $(subst /,_,$(MFILES)) \ diff --git a/GNUmakefile b/GNUmakefile index f15f7450..b7dd2a24 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,6 +3,9 @@ # silence entering/leaving messages MAKEFLAGS += --no-print-directory +OUTDIR = out +OBJDIR = .obj + # MAME does this so :/ ifeq ($(OS),Windows_NT) OS = windows @@ -29,10 +32,10 @@ ifndef ARCH endif libui: - @$(MAKE) -f GNUmakefile.libui OS=$(OS) ARCH=$(ARCH) + @$(MAKE) -f GNUmakefile.libui OS=$(OS) ARCH=$(ARCH) OUTDIR=$(OUTDIR) OBJDIR=$(OBJDIR) clean: - @$(MAKE) -f GNUmakefile.libui OS=$(OS) ARCH=$(ARCH) clean + @$(MAKE) -f GNUmakefile.libui OS=$(OS) ARCH=$(ARCH) OUTDIR=$(OUTDIR) OBJDIR=$(OBJDIR) clean test: libui - @$(MAKE) -f GNUmakefile.test OS=$(OS) ARCH=$(ARCH) + @$(MAKE) -f GNUmakefile.test OS=$(OS) ARCH=$(ARCH) OUTDIR=$(OUTDIR) OBJDIR=$(OBJDIR) diff --git a/GNUmakefile.libui b/GNUmakefile.libui index cc8732c5..847ce3d6 100644 --- a/GNUmakefile.libui +++ b/GNUmakefile.libui @@ -1,5 +1,6 @@ # 16 october 2015 +include $(OS)/GNUosspecific.mk include common/GNUmakeinc.mk include $(OS)/GNUmakeinc.mk @@ -12,6 +13,8 @@ NAME = libui CFLAGS += \ -fPIC +SUFFIX = $(LIBSUFFIX) + LDFLAGS += \ -shared \ -fPIC \ diff --git a/GNUmakefile.test b/GNUmakefile.test index ae9d1c65..0f2c69c8 100644 --- a/GNUmakefile.test +++ b/GNUmakefile.test @@ -1,5 +1,6 @@ # 16 october 2015 +include $(OS)/GNUosspecific.mk include test/GNUmakeinc.mk HFILES += \ @@ -7,35 +8,10 @@ HFILES += \ NAME = test -SUFFIX = -ifeq ($(OS),windows) - SUFFIX = .exe -endif +SUFFIX = $(EXESUFFIX) -# TODO split out this logic somehow -ifeq ($(OS),windows) -ifeq ($(ARCH),amd64) - ifndef CC - CC = x86_64-w64-mingw32-gcc - endif - ifndef RC - RC = x86_64-w64-mingw32-windres - endif -else ifeq ($(ARCH),386) - ifndef CC - CC = i686-w64-mingw32-gcc - endif - ifndef RC - RC = i686-w64-mingw32-windres - endif -else ifneq ($(ARCH),default) - $(error [FAIL] unknown architecture $(ARCH)) -endif - LDFLAGS += out/libui.dll -else ifeq ($(OS),darwin) - LDFLAGS += out/libui.dylib -else - LDFLAGS += out/libui.so -endif +# TODO what's the difference between doing this and linking to out/libui.so directly? +# LDFLAGS += -L$(OUTDIR) -lui +LDFLAGS += $(OUTDIR)/libui$(LIBSUFFIX) include GNUbaserules.mk diff --git a/darwin/GNUmakeinc.mk b/darwin/GNUmakeinc.mk index b6c90e6b..8f0470c2 100644 --- a/darwin/GNUmakeinc.mk +++ b/darwin/GNUmakeinc.mk @@ -48,5 +48,3 @@ LDFLAGS += \ # on warning about undefined symbols: # the gcc flags don't work with Apple's linker # fortunately, we don't need any; Apple's linker warns about undefined symbols in -shared builds! - -SUFFIX = .dylib diff --git a/darwin/GNUosspecific.mk b/darwin/GNUosspecific.mk new file mode 100644 index 00000000..b38372d8 --- /dev/null +++ b/darwin/GNUosspecific.mk @@ -0,0 +1,4 @@ +# 16 october 2015 + +EXESUFFIX = +LIBSUFFIX = .dylib diff --git a/unix/GNUmakeinc.mk b/unix/GNUmakeinc.mk index bc920610..972c471e 100644 --- a/unix/GNUmakeinc.mk +++ b/unix/GNUmakeinc.mk @@ -45,5 +45,3 @@ LDFLAGS += \ # flags for warning on undefined symbols LDFLAGS += \ -Wl,--no-undefined -Wl,--no-allow-shlib-undefined - -SUFFIX = .so diff --git a/unix/GNUosspecific.mk b/unix/GNUosspecific.mk new file mode 100644 index 00000000..0e2a497c --- /dev/null +++ b/unix/GNUosspecific.mk @@ -0,0 +1,4 @@ +# 16 october 2015 + +EXESUFFIX = +LIBSUFFIX = .so diff --git a/windows/GNUmakeinc.mk b/windows/GNUmakeinc.mk index f2aa682e..06f54ccf 100644 --- a/windows/GNUmakeinc.mk +++ b/windows/GNUmakeinc.mk @@ -56,23 +56,3 @@ LDFLAGS += \ # warnings on undefined symbols LDFLAGS += \ -Wl,--no-undefined -Wl,--no-allow-shlib-undefined - -SUFFIX = .dll - -ifeq ($(ARCH),amd64) - ifndef CC - CC = x86_64-w64-mingw32-gcc - endif - ifndef RC - RC = x86_64-w64-mingw32-windres - endif -else ifeq ($(ARCH),386) - ifndef CC - CC = i686-w64-mingw32-gcc - endif - ifndef RC - RC = i686-w64-mingw32-windres - endif -else ifneq ($(ARCH),default) - $(error [FAIL] unknown architecture $(ARCH)) -endif diff --git a/windows/GNUosspecific.mk b/windows/GNUosspecific.mk new file mode 100644 index 00000000..50512181 --- /dev/null +++ b/windows/GNUosspecific.mk @@ -0,0 +1,22 @@ +# 16 october 2015 + +EXESUFFIX = .exe +LIBSUFFIX = .dll + +ifeq ($(ARCH),amd64) + ifndef CC + CC = x86_64-w64-mingw32-gcc + endif + ifndef RC + RC = x86_64-w64-mingw32-windres + endif +else ifeq ($(ARCH),386) + ifndef CC + CC = i686-w64-mingw32-gcc + endif + ifndef RC + RC = i686-w64-mingw32-windres + endif +else ifneq ($(ARCH),default) + $(error [FAIL] unknown architecture $(ARCH)) +endif