diff --git a/newbuild/GNUmakefile b/newbuild/GNUmakefile index 98be88e6..a0c871f3 100644 --- a/newbuild/GNUmakefile +++ b/newbuild/GNUmakefile @@ -1,7 +1,6 @@ # 16 october 2015 # TODO http://stackoverflow.com/questions/4122831/disable-make-builtin-rules-and-variables-from-inside-the-make-file -# TODO and figure out what variables are predefined # silence entering/leaving messages MAKEFLAGS += --no-print-directory @@ -30,35 +29,32 @@ ifndef NODEBUG NODEBUG = 0 endif -# TODO $(CC), $(CXX)? if so, $(LD)? -# TODO quotes for the FLAGS options? -# TODO use export instead - http://stackoverflow.com/questions/2826029/passing-additional-variables-from-command-line-to-make -ARGS = \ - OS=$(OS) \ - OUTDIR=$(OUTDIR) \ - OBJDIR=$(OBJDIR) \ - CFLAGS=$(CFLAGS) \ - CXXFLAGS=$(CXXFLAGS) \ - LDFLAGS=$(LDFLAGS) \ - NODEBUG=$(NODEBUG) \ - inlibuibuild=1 +# parameters +export OS +# TODO CC, CXX, RC, CVTRES, LD +export CFLAGS +export CXXFLAGS +# TODO RCFLAGS, CVTRESFLAGS +export LDFLAGS +export NODEBUG +export EXAMPLE -real: - @echo $(MAKE) - @echo $(ARGS) +# other important variables +export OBJDIR +export OUTDIR libui: - @$(MAKE) -f build/GNUmakefile.libui $(ARGS) + @$(MAKE) -f build/GNUmakefile.libui inlibuibuild=1 clean: rm -rf $(OBJDIR) $(OUTDIR) test: libui - @$(MAKE) -f build/GNUmakefile.test $(ARGS) + @$(MAKE) -f build/GNUmakefile.test inlibuibuild=1 # TODO provide a build option for the queuemaintest example: libui - @$(MAKE) -f build/GNUmakefile.example $(ARGS) EXAMPLE=$(EXAMPLE) + @$(MAKE) -f build/GNUmakefile.example inlibuibuild=1 # TODO examples rule? diff --git a/oldbuild/GNUbaserules.mk b/newbuild/build/GNUbasegcc.mk similarity index 77% rename from oldbuild/GNUbaserules.mk rename to newbuild/build/GNUbasegcc.mk index 7b573c8a..8aa12999 100644 --- a/oldbuild/GNUbaserules.mk +++ b/newbuild/build/GNUbasegcc.mk @@ -1,5 +1,32 @@ # 16 october 2015 +# Global flags. + +CFLAGS += \ + -fPIC \ + -Wall -Wextra -pedantic \ + -Wno-unused-parameter \ + -Wno-switch \ + --std=c99 + +# C++11 is needed due to stupid rules involving commas at the end of enum lists that C++03 stupidly didn't follow +# This means sorry, no GCC 2 for Haiku builds :( +CXXFLAGS += \ + -fPIC \ + -Wall -Wextra -pedantic \ + -Wno-unused-parameter \ + -Wno-switch \ + --std=c++11 + +LDFLAGS += \ + -fPIC + +ifneq ($(NODEBUG),1) + CFLAGS += -g + CXXFLAGS += -g + LDFLAGS += -g +endif + OFILES = \ $(subst /,_,$(CFILES)) \ $(subst /,_,$(CXXFILES)) \ @@ -8,35 +35,12 @@ OFILES = \ OFILES := $(OFILES:%=$(OBJDIR)/%.o) -CFLAGS += \ - -g \ - -Wall -Wextra -pedantic \ - -Wno-unused-parameter \ - -Wno-switch \ - --std=c99 - -# C++11 is needed due to stupid rules involving commas at the end of enum lists that C++03 stupidly didn't follow -# This means sorry, no GCC 2 for Haiku builds :( -CXXFLAGS += \ - -g \ - -Wall -Wextra -pedantic \ - -Wno-unused-parameter \ - -Wno-switch \ - --std=c++11 - -LDFLAGS += \ - -g - OUT = $(OUTDIR)/$(NAME)$(SUFFIX) -ifdef CXXFILES - reallinker = $(CXX) -else - reallinker = $(CC) -endif +# TODO make the linker the C++ compiler in a C++ build if needed $(OUT): $(OFILES) | $(OUTDIR) - @$(reallinker) -o $(OUT) $(OFILES) $(LDFLAGS) + @$(LD) -o $(OUT) $(OFILES) $(LDFLAGS) @echo ====== Linked $(OUT) .SECONDEXPANSION: @@ -53,13 +57,11 @@ $(OBJDIR)/%.m.o: $$(subst _,/,%).m $(HFILES) | $(OBJDIR) @$(CC) -o $@ -c $< $(CFLAGS) @echo ====== Compiled $< +# TODO split into $(RC) and $(CVTRES) forms +# with binutils windres can either go straight to a .o file or in the normal two steps $(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR) @$(RC) $(RCFLAGS) $< $@ @echo ====== Compiled $< $(OBJDIR) $(OUTDIR): @mkdir -p $@ - -clean: - rm -rf $(OBJDIR) $(OUTDIR) -.PHONY: clean diff --git a/newbuild/build/GNUmakefile.libui b/newbuild/build/GNUmakefile.libui new file mode 100644 index 00000000..e833b566 --- /dev/null +++ b/newbuild/build/GNUmakefile.libui @@ -0,0 +1,36 @@ +# 16 october 2015 + +ifndef inlibuibuild +$(error Do not run these makefiles directly.) +endif + +# for GCC +SOVERSION = 0 + +include $(OS)/GNUosspecific.mk +include common/GNUfiles.mk +include $(OS)/GNUfiles.mk + +HFILES += \ + ui.h \ + ui_$(OS)$(OSHSUFFIX) + +NAME = libui +SUFFIX = $(LIBSUFFIX) + +ifeq ($(TOOLCHAIN),gcc) + # make every symbol hidden by default except _UI_EXTERN ones + # thanks ebassi in irc.gimp.net/#gtk+ + CFLAGS += \ + -D_UI_EXTERN='__attribute__((visibility("default"))) extern' \ + -fvisibility=hidden + CXXFLAGS += \ + -D_UI_EXTERN='__attribute__((visibility("default"))) extern' \ + -fvisibility=hidden + LDFLAGS += \ + -fvisibility=hidden +else + # TODO +endif + +include build/GNUbase$(TOOLCHAIN).mk diff --git a/oldbuild/common/GNUmakeinc.mk b/newbuild/common/GNUfiles.mk similarity index 100% rename from oldbuild/common/GNUmakeinc.mk rename to newbuild/common/GNUfiles.mk diff --git a/oldbuild/unix/GNUmakeinc.mk b/newbuild/unix/GNUfiles.mk similarity index 57% rename from oldbuild/unix/GNUmakeinc.mk rename to newbuild/unix/GNUfiles.mk index f8eba4ee..4f6d3867 100644 --- a/oldbuild/unix/GNUmakeinc.mk +++ b/newbuild/unix/GNUfiles.mk @@ -31,18 +31,19 @@ CFILES += \ HFILES += \ unix/uipriv_unix.h -# thanks ebassi in irc.gimp.net/#gtk+ -CFLAGS += \ - -D_UI_EXTERN='__attribute__((visibility("default"))) extern' \ - -fvisibility=hidden \ - -fPIC \ - `pkg-config --cflags gtk+-3.0` +# TODO split into a separate file or put in GNUmakefile.libui somehow? +# flags for building a shared library +# OS X does support -shared but it has a preferred name for this so let's use that there instead; hence this is not gcc-global LDFLAGS += \ - -fvisibility=hidden \ - -fPIC \ - `pkg-config --libs gtk+-3.0` -lm + -shared # flags for warning on undefined symbols +# this is not gcc-global because OS X doesn't support these flags LDFLAGS += \ -Wl,--no-undefined -Wl,--no-allow-shlib-undefined + +# flags for setting soname +# this is not gcc-global because OS X uses a different filename format +LDFLAGS += \ + -Wl,-soname,$(NAME)$(SUFFIX).$(SOVERSION) diff --git a/oldbuild/unix/GNUosspecific.mk b/newbuild/unix/GNUosspecific.mk similarity index 79% rename from oldbuild/unix/GNUosspecific.mk rename to newbuild/unix/GNUosspecific.mk index ac298ffb..980690ae 100644 --- a/oldbuild/unix/GNUosspecific.mk +++ b/newbuild/unix/GNUosspecific.mk @@ -3,3 +3,4 @@ EXESUFFIX = LIBSUFFIX = .so OSHSUFFIX = .h +TOOLCHAIN = gcc diff --git a/oldbuild/GNUmakefile.libui b/oldbuild/GNUmakefile.libui deleted file mode 100644 index 0ee4dc71..00000000 --- a/oldbuild/GNUmakefile.libui +++ /dev/null @@ -1,31 +0,0 @@ -# 16 october 2015 - -ifndef inlibuibuild -$(error [FAIL] do not run these makefiles directly) -endif - -include $(OS)/GNUosspecific.mk -include common/GNUmakeinc.mk -include $(OS)/GNUmakeinc.mk - -HFILES += \ - ui.h \ - ui_$(OS)$(OSHSUFFIX) - -NAME = libui - -# GROAN GCC -#CFLAGS += \ -# -fPIC - -SUFFIX = $(LIBSUFFIX) - -LDFLAGS += \ - -shared -# weird things: -# GROAN GCC -# -fPIC \ -# confused by this -# -Wl,-soname,$(NAME)$(SUFFIX).0 - -include GNUbaserules.mk