From 8cff71890f72d619162b4b8fac6f96f268deabd6 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 26 Feb 2009 09:45:30 +0100 Subject: made the GNU make NMAKE switch as we go to Windows now, also fixed small bugs in the makefiles --- GNUmakefile | 2 +- docs/GNUmakefile | 2 +- include/GNUmakefile | 2 +- makefiles/clean.mk | 38 -------- makefiles/compiler.mk | 227 -------------------------------------------- makefiles/depend.mk | 67 ------------- makefiles/dist.mk | 39 -------- makefiles/gmake/clean.mk | 38 ++++++++ makefiles/gmake/compiler.mk | 227 ++++++++++++++++++++++++++++++++++++++++++++ makefiles/gmake/depend.mk | 67 +++++++++++++ makefiles/gmake/dist.mk | 39 ++++++++ makefiles/gmake/guess_env | 173 +++++++++++++++++++++++++++++++++ makefiles/gmake/help.mk | 11 +++ makefiles/gmake/install.mk | 28 ++++++ makefiles/gmake/platform.mk | 56 +++++++++++ makefiles/gmake/sub.mk | 26 +++++ makefiles/gmake/top.mk | 48 ++++++++++ makefiles/guess_env | 173 --------------------------------- makefiles/help.mk | 11 --- makefiles/install.mk | 28 ------ makefiles/platform.mk | 56 ----------- makefiles/sub.mk | 26 ----- makefiles/top.mk | 48 ---------- src/GNUmakefile | 2 +- tests/GNUmakefile | 2 +- tests/daemon/GNUmakefile | 2 +- tests/port/GNUmakefile | 2 +- 27 files changed, 720 insertions(+), 720 deletions(-) delete mode 100644 makefiles/clean.mk delete mode 100644 makefiles/compiler.mk delete mode 100644 makefiles/depend.mk delete mode 100644 makefiles/dist.mk create mode 100644 makefiles/gmake/clean.mk create mode 100644 makefiles/gmake/compiler.mk create mode 100644 makefiles/gmake/depend.mk create mode 100644 makefiles/gmake/dist.mk create mode 100755 makefiles/gmake/guess_env create mode 100644 makefiles/gmake/help.mk create mode 100644 makefiles/gmake/install.mk create mode 100644 makefiles/gmake/platform.mk create mode 100644 makefiles/gmake/sub.mk create mode 100644 makefiles/gmake/top.mk delete mode 100755 makefiles/guess_env delete mode 100644 makefiles/help.mk delete mode 100644 makefiles/install.mk delete mode 100644 makefiles/platform.mk delete mode 100644 makefiles/sub.mk delete mode 100644 makefiles/top.mk diff --git a/GNUmakefile b/GNUmakefile index ca6b9c1..9fa21bc 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,4 +5,4 @@ SUBDIRS = src include tests docs PACKAGE_NAME = WolfBones PACKAGE_VERSION = 0.0.1 --include $(TOPDIR)/makefiles/top.mk +-include $(TOPDIR)/makefiles/gmake/top.mk diff --git a/docs/GNUmakefile b/docs/GNUmakefile index 4ab049c..eb3ca24 100644 --- a/docs/GNUmakefile +++ b/docs/GNUmakefile @@ -2,7 +2,7 @@ TOPDIR = .. SUBDIRS = --include $(TOPDIR)/makefiles/sub.mk +-include $(TOPDIR)/makefiles/gmake/sub.mk doc: cd $(TOPDIR); doxygen docs/doxygen.conf diff --git a/include/GNUmakefile b/include/GNUmakefile index 7960c24..c4f5f06 100644 --- a/include/GNUmakefile +++ b/include/GNUmakefile @@ -1,6 +1,6 @@ TOPDIR = .. --include $(TOPDIR)/makefiles/sub.mk +-include $(TOPDIR)/makefiles/gmake/sub.mk local_clean: -@rm -f wolf/*.bak diff --git a/makefiles/clean.mk b/makefiles/clean.mk deleted file mode 100644 index d416905..0000000 --- a/makefiles/clean.mk +++ /dev/null @@ -1,38 +0,0 @@ -# cleans up directories -# -# requires: -# - SUBDIRS: for recursive cleaning -# - local_clean, local_distclean targets in local GNUmakefile -# - all artifacts to clean: -# - BINS, TEST_BINS, TEST_CPP_BINS, CPP_BINS -# - OBJS, CPPOBJS, BIN_OBJS, TEST_BIN_OBJS, CPP_BIN_OBJS, TEST_CPP_BIN_OBJS -# - CMODULES, CPPMODULES -# -# provides: -# - target: clean -# - target: distclean - -.PHONY: clean_recursive clean local_clean - -clean_recursive: - @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ - (set -e; $(MAKE) -C $$d clean || exit 1); done) - -clean: clean_recursive local_clean - -@rm -f *.bak 2>/dev/null - -@rm -f *~ 2>/dev/null - -@rm -f *.d port/*.d 2>/dev/null - -@rm -f $(BINS) $(CPP_BINS) $(TEST_BINS) $(TEST_CPP_BINS) 2>/dev/null - -@rm -f $(OBJS) $(CPP_OBJS) $(BIN_OBJS) $(TEST_BIN_OBJS) $(CPP_BIN_OBJS) $(TEST_CPP_BIN_OBJS) 2>/dev/null - -@rm -f exec/* - -@rm -f *.core - -@rm -f $(CMODULES) $(CPPMODULES) - -@rm -f $(CMODULES .o=.d) $(CPPMODULES .o=.d) - -.PHONY: distclean_recursive distclean local_distclean - -distclean_recursive: - @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ - (set -e; $(MAKE) -C $$d distclean || exit 1); done) - -distclean: distclean_recursive local_distclean clean diff --git a/makefiles/compiler.mk b/makefiles/compiler.mk deleted file mode 100644 index 3409d4c..0000000 --- a/makefiles/compiler.mk +++ /dev/null @@ -1,227 +0,0 @@ -# sets compiler settings -# -# requires: -# - INCLUDE_DIRS -# -# provides: -# - BIN_OBJS: the object files we need for the binaries which we build always -# - CPP_BIN_OBJS: same for binaries which have C++ code in them -# - TEST_BIN_OBJS: same as BIN_OBJS but for test binaries compiled only when -# testing -# - TEST_CPP_BIN_OBJS: same for C++ tests -# - -# start of gcc section - -ifeq "$(COMPILER)" "gcc" - -GCC_MAJOR_VERSION = $(shell $(TOPDIR)/makefiles/guess_env --gcc-major-version $(CC)) -GCC_MINOR_VERSION = $(shell $(TOPDIR)/makefiles/guess_env --gcc-minor-version $(CC)) - -# -Wswitch-default: not good for switches with enums -# -Wsystem-headers: bad idea, as header files are usually happily broken :-) -# -Wtraditional: we don't want to program tradition K&R C anymore! -# -Wunsafe-loop-optimizations: ?? -# -Wno-attributes, -Wmissing-format-attribute: ?? later -# -Wpacked -Wpadded: ?? very questionable -# -Wunreachable-code: doesn't work -# -Wno-div-by-zero: we get NaN and friend over macros, so need for funny tricks :-) -# -Wstrict-overflow=5 is relatively new, later maybe -# -fstack-protector or -fstack-protector-all: should be used, but U -# have currently big problems to get it around compiler gcc and -lssl -# probing! FIXME later -# -fstack-protector-all: does something funny to the shared objects.. -# -Wstack-protector makes no sense without SSP -# everything implied by -Wall is not explicitly specified (gcc 4.2.3) -# TODO: reenable -O2 -# -Waggregate-return: is for K&R code and mostly useless nowadays - -# compilation flags and compilers -COMMON_COMPILE_FLAGS = \ - -g -D_REENTRANT \ - -fstrict-aliasing \ - -pedantic -Wall -Werror \ - -Wunused -Wno-import \ - -Wformat -Wformat-y2k -Wformat-nonliteral -Wformat-security -Wformat-y2k \ - -Wswitch-enum -Wunknown-pragmas -Wfloat-equal \ - -Wundef -Wshadow -Wpointer-arith \ - -Wcast-qual -Wcast-align \ - -Wwrite-strings \ - -Wmissing-noreturn \ - -Wno-multichar -Wparentheses -Wredundant-decls \ - -Winline \ - -Wdisabled-optimization -ifeq "$(GCC_MAJOR_VERSION)" "4" -COMMON_COMPILE_FLAGS += \ - -Wfatal-errors -Wmissing-include-dirs -Wvariadic-macros \ - -Wvolatile-register-var \ - -Wstrict-aliasing=2 -Wextra -Winit-self -# -Wconversion had to meanings before gcc 4.3 (warn about ABI changes when porting -# old K&R code without function prototypes) and warn about conversions loosing -# precision. So we enable only -Wconversion (not -Wtraditional-conversion) for gcc -# >= 4.3 and no -Wconversion for older gcc versions! -# (see also http://gcc.gnu.org/wiki/NewWconversion) -ifeq "$(GCC_MINOR_VERSION)" "3" -COMMON_COMPILE_FLAGS += -Wconversion -endif - -endif - -ifeq "$(GCC_MAJOR_VERSION)" "3" - -# gcc 3.3, testend on OpenBSD 4.2 -ifeq "$(GCC_MINOR_VERSION)" "3" -COMMON_COMPILE_FLAGS += \ - -W -endif - -# gcc 3.4, not tested yet -ifeq "$(GCC_MINOR_VERSION)" "4" -COMMON_COMPILE_FLAGS += \ - -Wstrict-aliasing=2 -Wextra -Winit-self -endif - -endif - -COMPILE_FLAGS = \ - $(COMMON_COMPILE_FLAGS) \ - -std=c99 \ - -Wnonnull \ - -Wbad-function-cast -Wstrict-prototypes \ - -Wmissing-prototypes -Wmissing-declarations \ - -Wnested-externs - -# gcc 4.x -ifeq "$(GCC_MAJOR_VERSION)" "4" -COMPILE_FLAGS += \ - -Wc++-compat -Wdeclaration-after-statement -Wold-style-definition \ - -funit-at-a-time -endif - -ifeq "$(GCC_MAJOR_VERSION)" "3" - -# gcc 3.4, not tested yet -ifeq "$(GCC_MINOR_VERSION)" "4" -COMPILE_FLAGS += \ - -Wdeclaration-after-statement -Wold-style-definition \ - -funit-at-a-time -endif - -# gcc 3.3, testend on OpenBSD 4.2 -ifeq "$(GCC_MINOR_VERSION)" "3" -#COMPILE_FLAGS += \ -# -Wdeclaration-after-statement -endif - -endif - -CCPP_COMPILE_FLAGS = \ - $(COMMON_COMPILE_FLAGS) \ - -std=c++98 - -# gcc 4.x -ifeq "$(GCC_MAJOR_VERSION)" "4" -CCPP_COMPILE_FLAGS += \ - -Wno-invalid-offsetof -funit-at-a-time -endif - -ifeq "$(GCC_MAJOR_VERSION)" "3" - -# gcc 3.4, not tested yet -ifeq "$(GCC_MINOR_VERSION)" "4" -CCPP_COMPILE_FLAGS += \ - -Wno-invalid-offsetof -endif - -# gcc 3.3, testend on OpenBSD 4.2 -ifeq "$(GCC_MINOR_VERSION)" "3" -#CCPP_COMPILE_FLAGS += \ -# -Wdeclaration-after-statement -endif - -endif - -#CC = gcc -CCPP = g++ - -endif - -# end of gcc section - -# start of tcc section - -# currently we don't need this, the tcc flags are fairly consistent -#TCC_MAJOR_VERSION = $(shell $(TOPDIR)/makefiles/guess_env --tcc-major-version $(CC)) -#TCC_MINOR_VERSION = $(shell $(TOPDIR)/makefiles/guess_env --tcc-minor-version $(CC)) - -ifeq "$(COMPILER)" "tcc" -COMPILE_FLAGS = \ - -Wall -Werror -Wunsupported -endif - -# end of tcc section - -# start of icc section - -# currently we don't need this, the icc flags are fairly consistent -#ICC_MAJOR_VERSION = $(shell $(TOPDIR)/makefiles/guess_env --icc-major-version $(CC)) -#ICC_MINOR_VERSION = $(shell $(TOPDIR)/makefiles/guess_env --icc-minor-version $(CC)) - -# -vec-report0: turn of SSE2 vector usage messages (they are common since P-4 anyway!) - -ifeq "$(COMPILER)" "icc" -COMPILE_FLAGS = \ - -Wall -Werror -vec-report0 -endif - -# end of icc section - -# start of spro section - -# -xc99=all: full C99 compliance for the code (syntax and library functions) -# -Xc: full ISO compliance, no K&R stuf -# -mt: enable mutlithreading (-D_REENTRANT for header files, -lthread for ld) -# -errwarn=%all: convert all warnings to errors -# -v: do more restrictive syntax checking -# TODO: enable -O2 - -ifeq "$(COMPILER)" "spro" -COMPILE_FLAGS = \ - -xc99=all -Xc -errwarn=%all -mt -v -endif - -# end of spro section - -CFLAGS = $(COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) -CCPPFLAGS = $(CCPP_COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) - -LDFLAGS = $(INCLUDE_LDFLAGS) -LIBS = $(INCLUDE_LIBS) -LINK = $(CC) -CCPP_LINK = $(CCPP) - -%.o : %.c - $(CC) -c -o $@ $(CFLAGS) $< - -%.o : %.cpp - $(CCPP) -c -o $@ $(CCPPFLAGS) $< - -%$(EXE): %.o $(OBJS) $(TEST_OBJS) - $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(TEST_OBJS) $< $(LIBS) - -%.sho : %.c - $(CC) -c -o $@ -fPIC -DSHARED $(CFLAGS) $< - -%$(SO) : %.sho $(OBJS) - $(LINK) -shared -o $@ $(LDFLAGS) $(LIBS) $(OBJS) $< - -%.sho++ : %.cpp - $(CCPP) -c -o $@ -fPIC -DSHARED $(CCPPFLAGS) $< - -%$(SO) : %.sho++ $(OBJS) $(CPPOBJS) - $(CCPP_LINK) -shared -o $@ $(LDFLAGS) $(LIBS) $(OBJS) $(CPPOBJS) $< - -BIN_OBJS = $(BINS:$(EXE)=.o) -TEST_BIN_OBJS = $(TEST_BINS:$(EXE)=.o) -CPP_BIN_OBJS = $(CPP_BINS:$(EXE)=.o) -TEST_CPP_BIN_OBJS = $(TEST_CPP_BINS:$(EXE)=.o) diff --git a/makefiles/depend.mk b/makefiles/depend.mk deleted file mode 100644 index bcdb5b2..0000000 --- a/makefiles/depend.mk +++ /dev/null @@ -1,67 +0,0 @@ -# provides generic rules for C/C++ dependeny generation using -# 'makedepend', 'gcc -MM' or similar mechanisms -# -# requires: -# - compilers CC and CCPP -# - INCLUDEDIRS -# - OBJS, CPP_OBJS and BIN_OBJS, CPP_BIN_OBJS -# - TEST_BINS, TEST_BIN_OBJS, TEST_CPP_BINS, TEST_CPP_BIN_OBJS -# -# provides: -# - included dependency files -# -# author: Andreas Baumann, abaumann at yahoo dot com - -ifeq "$(COMPILER)" "gcc" - -%.d : %.c - @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES -MM -MT $@ $(CFLAGS) $< | \ - sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ - -%.d : %.cpp - @echo Generating dependencies for $< - @$(CCPP) -DMAKE_DEPENDENCIES -MM -MT $@ $(CCPPFLAGS) $< | \ - sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ - -endif - -ifeq "$(COMPILER)" "tcc" - -%.d : %.c - @echo Generating dependencies for $< - @makedepend -DMAKE_DEPENDENCIES $(INCLUDE_DIRS) -I/usr/lib/tcc/include -f - $< > $@ - -endif - -ifeq "$(COMPILER)" "icc" - -%.d : %.c - @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES -MM -MT $@ $(CFLAGS) $< | \ - sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ - -%.d : %.cpp - @echo Generating dependencies for $< - @$(CCPP) -DMAKE_DEPENDENCIES -MM -MT $@ $(CCPPFLAGS) $< | \ - sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ - -endif - -ifeq "$(COMPILER)" "spro" - -%.d : %.c - @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES -xM1 $(INCLUDE_DIRS) $< > $@ - -%.d : %.cpp - @echo Generating dependencies for $< - @$(CCPP) -DMAKE_DEPENDENCIES -xM1 $(INCLUDE_DIRS) $< > $@ -endif - --include $(OBJS:.o=.d) --include $(CPP_OBJS:.o=.d) --include $(BIN_OBJS:.o=.d) --include $(CPP_BIN_OBJS:.o=.d) --include $(TEST_BIN_OBJS:.o=.d) --include $(TEST_CPP_BIN_OBJS:.o=.d) diff --git a/makefiles/dist.mk b/makefiles/dist.mk deleted file mode 100644 index 50a4a81..0000000 --- a/makefiles/dist.mk +++ /dev/null @@ -1,39 +0,0 @@ -# creates a source tarball ready for distribution -# -# requires: -# - PACKAGE_NAME -# - PACKAGE_VERSION -# -# provides: -# - target: dist -# - target: dist-bz2, dist-gz, dist-Z - -.PHONY: dist dist-bz2 dist-gz dist-Z - -dist: - -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION) - -@rm -rf /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) - mkdir /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) - cp -r * /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/. - -@cd /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) ; \ - $(MAKE) distclean ; \ - find . -name .svn -exec rm -rf {} \; ; \ - find . -name .git -exec rm -rf {} \; ; \ - cd .. ; \ - tar cvf $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar \ - $(PACKAGE_NAME)-$(PACKAGE_VERSION) - -@rm -rf /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) - @mv /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar . - -dist-bz2: dist - -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).bz2 - @bzip2 -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar - -dist-gz: dist - -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).gz - @gzip $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar - -dist-Z: dist - -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).Z - @compress -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar - diff --git a/makefiles/gmake/clean.mk b/makefiles/gmake/clean.mk new file mode 100644 index 0000000..d416905 --- /dev/null +++ b/makefiles/gmake/clean.mk @@ -0,0 +1,38 @@ +# cleans up directories +# +# requires: +# - SUBDIRS: for recursive cleaning +# - local_clean, local_distclean targets in local GNUmakefile +# - all artifacts to clean: +# - BINS, TEST_BINS, TEST_CPP_BINS, CPP_BINS +# - OBJS, CPPOBJS, BIN_OBJS, TEST_BIN_OBJS, CPP_BIN_OBJS, TEST_CPP_BIN_OBJS +# - CMODULES, CPPMODULES +# +# provides: +# - target: clean +# - target: distclean + +.PHONY: clean_recursive clean local_clean + +clean_recursive: + @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d clean || exit 1); done) + +clean: clean_recursive local_clean + -@rm -f *.bak 2>/dev/null + -@rm -f *~ 2>/dev/null + -@rm -f *.d port/*.d 2>/dev/null + -@rm -f $(BINS) $(CPP_BINS) $(TEST_BINS) $(TEST_CPP_BINS) 2>/dev/null + -@rm -f $(OBJS) $(CPP_OBJS) $(BIN_OBJS) $(TEST_BIN_OBJS) $(CPP_BIN_OBJS) $(TEST_CPP_BIN_OBJS) 2>/dev/null + -@rm -f exec/* + -@rm -f *.core + -@rm -f $(CMODULES) $(CPPMODULES) + -@rm -f $(CMODULES .o=.d) $(CPPMODULES .o=.d) + +.PHONY: distclean_recursive distclean local_distclean + +distclean_recursive: + @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d distclean || exit 1); done) + +distclean: distclean_recursive local_distclean clean diff --git a/makefiles/gmake/compiler.mk b/makefiles/gmake/compiler.mk new file mode 100644 index 0000000..5d04dd4 --- /dev/null +++ b/makefiles/gmake/compiler.mk @@ -0,0 +1,227 @@ +# sets compiler settings +# +# requires: +# - INCLUDE_DIRS +# +# provides: +# - BIN_OBJS: the object files we need for the binaries which we build always +# - CPP_BIN_OBJS: same for binaries which have C++ code in them +# - TEST_BIN_OBJS: same as BIN_OBJS but for test binaries compiled only when +# testing +# - TEST_CPP_BIN_OBJS: same for C++ tests +# + +# start of gcc section + +ifeq "$(COMPILER)" "gcc" + +GCC_MAJOR_VERSION = $(shell $(TOPDIR)/makefiles/gmake/guess_env --gcc-major-version $(CC)) +GCC_MINOR_VERSION = $(shell $(TOPDIR)/makefiles/gmake/guess_env --gcc-minor-version $(CC)) + +# -Wswitch-default: not good for switches with enums +# -Wsystem-headers: bad idea, as header files are usually happily broken :-) +# -Wtraditional: we don't want to program tradition K&R C anymore! +# -Wunsafe-loop-optimizations: ?? +# -Wno-attributes, -Wmissing-format-attribute: ?? later +# -Wpacked -Wpadded: ?? very questionable +# -Wunreachable-code: doesn't work +# -Wno-div-by-zero: we get NaN and friend over macros, so need for funny tricks :-) +# -Wstrict-overflow=5 is relatively new, later maybe +# -fstack-protector or -fstack-protector-all: should be used, but U +# have currently big problems to get it around compiler gcc and -lssl +# probing! FIXME later +# -fstack-protector-all: does something funny to the shared objects.. +# -Wstack-protector makes no sense without SSP +# everything implied by -Wall is not explicitly specified (gcc 4.2.3) +# TODO: reenable -O2 +# -Waggregate-return: is for K&R code and mostly useless nowadays + +# compilation flags and compilers +COMMON_COMPILE_FLAGS = \ + -g -D_REENTRANT \ + -fstrict-aliasing \ + -pedantic -Wall -Werror \ + -Wunused -Wno-import \ + -Wformat -Wformat-y2k -Wformat-nonliteral -Wformat-security -Wformat-y2k \ + -Wswitch-enum -Wunknown-pragmas -Wfloat-equal \ + -Wundef -Wshadow -Wpointer-arith \ + -Wcast-qual -Wcast-align \ + -Wwrite-strings \ + -Wmissing-noreturn \ + -Wno-multichar -Wparentheses -Wredundant-decls \ + -Winline \ + -Wdisabled-optimization +ifeq "$(GCC_MAJOR_VERSION)" "4" +COMMON_COMPILE_FLAGS += \ + -Wfatal-errors -Wmissing-include-dirs -Wvariadic-macros \ + -Wvolatile-register-var \ + -Wstrict-aliasing=2 -Wextra -Winit-self +# -Wconversion had to meanings before gcc 4.3 (warn about ABI changes when porting +# old K&R code without function prototypes) and warn about conversions loosing +# precision. So we enable only -Wconversion (not -Wtraditional-conversion) for gcc +# >= 4.3 and no -Wconversion for older gcc versions! +# (see also http://gcc.gnu.org/wiki/NewWconversion) +ifeq "$(GCC_MINOR_VERSION)" "3" +COMMON_COMPILE_FLAGS += -Wconversion +endif + +endif + +ifeq "$(GCC_MAJOR_VERSION)" "3" + +# gcc 3.3, testend on OpenBSD 4.2 +ifeq "$(GCC_MINOR_VERSION)" "3" +COMMON_COMPILE_FLAGS += \ + -W +endif + +# gcc 3.4, not tested yet +ifeq "$(GCC_MINOR_VERSION)" "4" +COMMON_COMPILE_FLAGS += \ + -Wstrict-aliasing=2 -Wextra -Winit-self +endif + +endif + +COMPILE_FLAGS = \ + $(COMMON_COMPILE_FLAGS) \ + -std=c99 \ + -Wnonnull \ + -Wbad-function-cast -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wnested-externs + +# gcc 4.x +ifeq "$(GCC_MAJOR_VERSION)" "4" +COMPILE_FLAGS += \ + -Wc++-compat -Wdeclaration-after-statement -Wold-style-definition \ + -funit-at-a-time +endif + +ifeq "$(GCC_MAJOR_VERSION)" "3" + +# gcc 3.4, not tested yet +ifeq "$(GCC_MINOR_VERSION)" "4" +COMPILE_FLAGS += \ + -Wdeclaration-after-statement -Wold-style-definition \ + -funit-at-a-time +endif + +# gcc 3.3, testend on OpenBSD 4.2 +ifeq "$(GCC_MINOR_VERSION)" "3" +#COMPILE_FLAGS += \ +# -Wdeclaration-after-statement +endif + +endif + +CCPP_COMPILE_FLAGS = \ + $(COMMON_COMPILE_FLAGS) \ + -std=c++98 + +# gcc 4.x +ifeq "$(GCC_MAJOR_VERSION)" "4" +CCPP_COMPILE_FLAGS += \ + -Wno-invalid-offsetof -funit-at-a-time +endif + +ifeq "$(GCC_MAJOR_VERSION)" "3" + +# gcc 3.4, not tested yet +ifeq "$(GCC_MINOR_VERSION)" "4" +CCPP_COMPILE_FLAGS += \ + -Wno-invalid-offsetof +endif + +# gcc 3.3, testend on OpenBSD 4.2 +ifeq "$(GCC_MINOR_VERSION)" "3" +#CCPP_COMPILE_FLAGS += \ +# -Wdeclaration-after-statement +endif + +endif + +#CC = gcc +CCPP = g++ + +endif + +# end of gcc section + +# start of tcc section + +# currently we don't need this, the tcc flags are fairly consistent +#TCC_MAJOR_VERSION = $(shell $(TOPDIR)/makefiles/gmake/guess_env --tcc-major-version $(CC)) +#TCC_MINOR_VERSION = $(shell $(TOPDIR)/makefiles/gmake/guess_env --tcc-minor-version $(CC)) + +ifeq "$(COMPILER)" "tcc" +COMPILE_FLAGS = \ + -Wall -Werror -Wunsupported +endif + +# end of tcc section + +# start of icc section + +# currently we don't need this, the icc flags are fairly consistent +#ICC_MAJOR_VERSION = $(shell $(TOPDIR)/makefiles/gmake/guess_env --icc-major-version $(CC)) +#ICC_MINOR_VERSION = $(shell $(TOPDIR)/makefiles/gmake/guess_env --icc-minor-version $(CC)) + +# -vec-report0: turn of SSE2 vector usage messages (they are common since P-4 anyway!) + +ifeq "$(COMPILER)" "icc" +COMPILE_FLAGS = \ + -Wall -Werror -vec-report0 +endif + +# end of icc section + +# start of spro section + +# -xc99=all: full C99 compliance for the code (syntax and library functions) +# -Xc: full ISO compliance, no K&R stuf +# -mt: enable mutlithreading (-D_REENTRANT for header files, -lthread for ld) +# -errwarn=%all: convert all warnings to errors +# -v: do more restrictive syntax checking +# TODO: enable -O2 + +ifeq "$(COMPILER)" "spro" +COMPILE_FLAGS = \ + -xc99=all -Xc -errwarn=%all -mt -v +endif + +# end of spro section + +CFLAGS = $(COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) +CCPPFLAGS = $(CCPP_COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) + +LDFLAGS = $(INCLUDE_LDFLAGS) +LIBS = $(INCLUDE_LIBS) +LINK = $(CC) +CCPP_LINK = $(CCPP) + +%.o : %.c + $(CC) -c -o $@ $(CFLAGS) $< + +%.o : %.cpp + $(CCPP) -c -o $@ $(CCPPFLAGS) $< + +%$(EXE): %.o $(OBJS) $(TEST_OBJS) + $(LINK) -o $@ $(LDFLAGS) $(OBJS) $(TEST_OBJS) $< $(LIBS) + +%.sho : %.c + $(CC) -c -o $@ -fPIC -DSHARED $(CFLAGS) $< + +%$(SO) : %.sho $(OBJS) + $(LINK) -shared -o $@ $(LDFLAGS) $(LIBS) $(OBJS) $< + +%.sho++ : %.cpp + $(CCPP) -c -o $@ -fPIC -DSHARED $(CCPPFLAGS) $< + +%$(SO) : %.sho++ $(OBJS) $(CPPOBJS) + $(CCPP_LINK) -shared -o $@ $(LDFLAGS) $(LIBS) $(OBJS) $(CPPOBJS) $< + +BIN_OBJS = $(BINS:$(EXE)=.o) +TEST_BIN_OBJS = $(TEST_BINS:$(EXE)=.o) +CPP_BIN_OBJS = $(CPP_BINS:$(EXE)=.o) +TEST_CPP_BIN_OBJS = $(TEST_CPP_BINS:$(EXE)=.o) diff --git a/makefiles/gmake/depend.mk b/makefiles/gmake/depend.mk new file mode 100644 index 0000000..bcdb5b2 --- /dev/null +++ b/makefiles/gmake/depend.mk @@ -0,0 +1,67 @@ +# provides generic rules for C/C++ dependeny generation using +# 'makedepend', 'gcc -MM' or similar mechanisms +# +# requires: +# - compilers CC and CCPP +# - INCLUDEDIRS +# - OBJS, CPP_OBJS and BIN_OBJS, CPP_BIN_OBJS +# - TEST_BINS, TEST_BIN_OBJS, TEST_CPP_BINS, TEST_CPP_BIN_OBJS +# +# provides: +# - included dependency files +# +# author: Andreas Baumann, abaumann at yahoo dot com + +ifeq "$(COMPILER)" "gcc" + +%.d : %.c + @echo Generating dependencies for $< + @$(CC) -DMAKE_DEPENDENCIES -MM -MT $@ $(CFLAGS) $< | \ + sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ + +%.d : %.cpp + @echo Generating dependencies for $< + @$(CCPP) -DMAKE_DEPENDENCIES -MM -MT $@ $(CCPPFLAGS) $< | \ + sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ + +endif + +ifeq "$(COMPILER)" "tcc" + +%.d : %.c + @echo Generating dependencies for $< + @makedepend -DMAKE_DEPENDENCIES $(INCLUDE_DIRS) -I/usr/lib/tcc/include -f - $< > $@ + +endif + +ifeq "$(COMPILER)" "icc" + +%.d : %.c + @echo Generating dependencies for $< + @$(CC) -DMAKE_DEPENDENCIES -MM -MT $@ $(CFLAGS) $< | \ + sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ + +%.d : %.cpp + @echo Generating dependencies for $< + @$(CCPP) -DMAKE_DEPENDENCIES -MM -MT $@ $(CCPPFLAGS) $< | \ + sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ + +endif + +ifeq "$(COMPILER)" "spro" + +%.d : %.c + @echo Generating dependencies for $< + @$(CC) -DMAKE_DEPENDENCIES -xM1 $(INCLUDE_DIRS) $< > $@ + +%.d : %.cpp + @echo Generating dependencies for $< + @$(CCPP) -DMAKE_DEPENDENCIES -xM1 $(INCLUDE_DIRS) $< > $@ +endif + +-include $(OBJS:.o=.d) +-include $(CPP_OBJS:.o=.d) +-include $(BIN_OBJS:.o=.d) +-include $(CPP_BIN_OBJS:.o=.d) +-include $(TEST_BIN_OBJS:.o=.d) +-include $(TEST_CPP_BIN_OBJS:.o=.d) diff --git a/makefiles/gmake/dist.mk b/makefiles/gmake/dist.mk new file mode 100644 index 0000000..50a4a81 --- /dev/null +++ b/makefiles/gmake/dist.mk @@ -0,0 +1,39 @@ +# creates a source tarball ready for distribution +# +# requires: +# - PACKAGE_NAME +# - PACKAGE_VERSION +# +# provides: +# - target: dist +# - target: dist-bz2, dist-gz, dist-Z + +.PHONY: dist dist-bz2 dist-gz dist-Z + +dist: + -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION) + -@rm -rf /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) + mkdir /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) + cp -r * /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/. + -@cd /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) ; \ + $(MAKE) distclean ; \ + find . -name .svn -exec rm -rf {} \; ; \ + find . -name .git -exec rm -rf {} \; ; \ + cd .. ; \ + tar cvf $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar \ + $(PACKAGE_NAME)-$(PACKAGE_VERSION) + -@rm -rf /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) + @mv /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar . + +dist-bz2: dist + -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).bz2 + @bzip2 -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar + +dist-gz: dist + -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).gz + @gzip $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar + +dist-Z: dist + -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).Z + @compress -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar + diff --git a/makefiles/gmake/guess_env b/makefiles/gmake/guess_env new file mode 100755 index 0000000..d0a31ae --- /dev/null +++ b/makefiles/gmake/guess_env @@ -0,0 +1,173 @@ +#!/bin/sh + +# operating system and major, minor version, more should not be necessary + +UNAME_SYSTEM=`(uname -s) 2>/dev/null` +UNAME_RELEASE=`(uname -r) 2>/dev/null` +UNAME_VERSION=`(uname -v) 2>/dev/null` +UNAME_MACHINE=`(uname -m) 2>/dev/null` + +case "$UNAME_SYSTEM.$UNAME_RELEASE" in + Linux*) PLATFORM=LINUX + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` + ;; + + FreeBSD*) PLATFORM=FREEBSD + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` + ;; + + OpenBSD*) PLATFORM=OPENBSD + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` + ;; + + NetBSD*) PLATFORM=NETBSD + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` + ;; + + SunOS*) PLATFORM=SUNOS + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` + ;; + + CYGWIN_NT*) PLATFORM=CYGWIN + _tmp=`echo $UNAME_SYSTEM | cut -d - -f 2` + OS_MAJOR_VERSION=`echo $_tmp | cut -d . -f 1` + OS_MINOR_VERSION=`echo $_tmp | cut -d . -f 2` + ;; + + *) + PLATFORM=UNKNOWN + echo "Unknown platform '$UNAME_SYSTEM $UNAME_RELEASE'" + exit 1 +esac + +# the architecture + +case "$UNAME_MACHINE" in + i*86*) ARCH=x86 + ;; + + sun4u) ARCH=sun4u + ;; + + *) ARCH=UNKNOWN + echo "Unknown architecture '$UNAME_MACHINE'" + exit 1 + +esac + +# the compiler and version + +# what compiler do we have (we can't relly on it's name as it may be a cc link to the binary!) +CC=$2 +( $CC --version | grep GCC ) 2>/dev/null 1>/dev/null +if test $? = 0; then + COMPILER='gcc' +else + ( $CC -v | grep tcc ) 2>/dev/null 1>/dev/null + if test $? = 0; then + COMPILER='tcc' + else + ( $CC -V 2>&1 | grep l_cproc_p ) >/dev/null + if test $? = 0; then + COMPILER='icc' + else + ( $CC -xhelp=readme | head -n 1 | grep 'Sun Studio' ) >/dev/null + if test $? = 0; then + COMPILER='spro' + else + COMPILER='unknown' + fi + fi + fi +fi + +# version of gcc (GNU C compiler) + +if test $COMPILER = "gcc"; then + GCC_VERSION=`gcc -dumpversion` + GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d . -f 1` + GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d . -f 2` +fi + +# version of tcc (Tiny C compiler) + +if test $COMPILER = "tcc"; then + TCC_VERSION=`tcc -v | cut -d ' ' -f 3` + TCC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` + TCC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` +fi + +# version of icc (Intel C compiler) + +if test $COMPILER = "icc"; then + ICC_VERSION=`icc -dumpversion` + ICC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` + ICC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` +fi + +# version of spro (Sun Pro compiler, Sun Studio) + +if test $COMPILER = 'spro'; then + SPRO_VERSION=`$CC -xhelp=readme | head -n 1 | cut -d ' ' -f 3` + SPRO_MAJOR_VERSION=`echo $SPRO_VERSION | cut -d : -f 1` +fi + +case "$1" in + --platform) echo $PLATFORM + ;; + + --os-major-version) echo $OS_MAJOR_VERSION + ;; + + --os-minor-version) echo $OS_MINOR_VERSION + ;; + + --arch) echo $ARCH + ;; + + --compiler) echo $COMPILER + ;; + + --gcc-major-version) echo $GCC_MAJOR_VERSION + ;; + + --gcc-minor-version) echo $GCC_MINOR_VERSION + ;; + + --tcc-major-version) echo $TCC_MAJOR_VERSION + ;; + + --tcc-minor-version) echo $TCC_MINOR_VERSION + ;; + + --icc-major-version) echo $ICC_MAJOR_VERSION + ;; + + --icc-minor-version) echo $ICC_MINOR_VERSION + ;; + + --spro-major-version) echo $SPRO_MAJOR_VERSION + ;; + + --all) + cat </dev/null` -UNAME_RELEASE=`(uname -r) 2>/dev/null` -UNAME_VERSION=`(uname -v) 2>/dev/null` -UNAME_MACHINE=`(uname -m) 2>/dev/null` - -case "$UNAME_SYSTEM.$UNAME_RELEASE" in - Linux*) PLATFORM=LINUX - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` - ;; - - FreeBSD*) PLATFORM=FREEBSD - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` - ;; - - OpenBSD*) PLATFORM=OPENBSD - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` - ;; - - NetBSD*) PLATFORM=NETBSD - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` - ;; - - SunOS*) PLATFORM=SUNOS - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` - ;; - - CYGWIN_NT*) PLATFORM=CYGWIN - _tmp=`echo $UNAME_SYSTEM | cut -d - -f 2` - OS_MAJOR_VERSION=`echo $_tmp | cut -d . -f 1` - OS_MINOR_VERSION=`echo $_tmp | cut -d . -f 2` - ;; - - *) - PLATFORM=UNKNOWN - echo "Unknown platform '$UNAME_SYSTEM $UNAME_RELEASE'" - exit 1 -esac - -# the architecture - -case "$UNAME_MACHINE" in - i*86*) ARCH=x86 - ;; - - sun4u) ARCH=sun4u - ;; - - *) ARCH=UNKNOWN - echo "Unknown architecture '$UNAME_MACHINE'" - exit 1 - -esac - -# the compiler and version - -# what compiler do we have (we can't relly on it's name as it may be a cc link to the binary!) -CC=$2 -( $CC --version | grep GCC ) 2>/dev/null 1>/dev/null -if test $? = 0; then - COMPILER='gcc' -else - ( $CC -v | grep tcc ) 2>/dev/null 1>/dev/null - if test $? = 0; then - COMPILER='tcc' - else - ( $CC -V 2>&1 | grep l_cproc_p ) >/dev/null - if test $? = 0; then - COMPILER='icc' - else - ( $CC -xhelp=readme | head -n 1 | grep 'Sun Studio' ) >/dev/null - if test $? = 0; then - COMPILER='spro' - else - COMPILER='unknown' - fi - fi - fi -fi - -# version of gcc (GNU C compiler) - -if test $COMPILER = "gcc"; then - GCC_VERSION=`gcc -dumpversion` - GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d . -f 1` - GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d . -f 2` -fi - -# version of tcc (Tiny C compiler) - -if test $COMPILER = "tcc"; then - TCC_VERSION=`tcc -v | cut -d ' ' -f 3` - TCC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` - TCC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` -fi - -# version of icc (Intel C compiler) - -if test $COMPILER = "icc"; then - ICC_VERSION=`icc -dumpversion` - ICC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` - ICC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` -fi - -# version of spro (Sun Pro compiler, Sun Studio) - -if test $COMPILER = 'spro'; then - SPRO_VERSION=`$CC -xhelp=readme | head -n 1 | cut -d ' ' -f 3` - SPRO_MAJOR_VERSION=`echo $SPRO_VERSION | cut -d : -f 1` -fi - -case "$1" in - --platform) echo $PLATFORM - ;; - - --os-major-version) echo $OS_MAJOR_VERSION - ;; - - --os-minor-version) echo $OS_MINOR_VERSION - ;; - - --arch) echo $ARCH - ;; - - --compiler) echo $COMPILER - ;; - - --gcc-major-version) echo $GCC_MAJOR_VERSION - ;; - - --gcc-minor-version) echo $GCC_MINOR_VERSION - ;; - - --tcc-major-version) echo $TCC_MAJOR_VERSION - ;; - - --tcc-minor-version) echo $TCC_MINOR_VERSION - ;; - - --icc-major-version) echo $ICC_MAJOR_VERSION - ;; - - --icc-minor-version) echo $ICC_MINOR_VERSION - ;; - - --spro-major-version) echo $SPRO_MAJOR_VERSION - ;; - - --all) - cat <