From f4e2bcdde411d331fdc936c82b9cc624085b95cb Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 11 Feb 2012 01:14:46 +0000 Subject: [PATCH] Makefile improvements. --- Makefile | 50 +++++++++++++++++++++++--------------------------- config.mk | 28 +++++++++++++++++++++++----- linux/lc | 17 ----------------- version.mk | 4 ++-- 4 files changed, 48 insertions(+), 51 deletions(-) delete mode 100644 linux/lc diff --git a/Makefile b/Makefile index 8342fcbc..d78a5a8f 100644 --- a/Makefile +++ b/Makefile @@ -4,62 +4,61 @@ include config.mk ### Module directories MODULES := $(OSDIR) common -### look for include files in -### each of the modules +### Look for include files in each of the modules CPPFLAGS += $(patsubst %,-I%,$(MODULES)) $(OS) CPPFLAGS += -g -### extra libraries if required +### Extra libraries if required LIBS := -### each module will add to this +### Each module will add to this SRC := BIN := bin/leocad +ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean), ) -include $(OSDIR)/config.mk +endif -### include the description for -### each module +### Include the description for each module include $(patsubst %,%/module.mk,$(MODULES)) -### determine the object files +### Determine the object files OBJ := \ $(patsubst %.c,%.o,$(filter %.c,$(SRC))) \ $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRC))) -### link the program +### Link the program .PHONY: all static all: $(BIN) static: bin/leocad.static -bin/leocad: $(OBJ) bin - $(CXX) -o $@ $(OBJ) $(LIBS) $(LDFLAGS) +bin/leocad: $(OBJ) bin Makefile + @echo Linking $@ + @$(CXX) -o $@ $(OBJ) $(LIBS) $(LDFLAGS) -bin/leocad.static: $(OBJ) bin +bin/leocad.static: $(OBJ) bin Makefile $(CXX) -static -o $@ $(OBJ) $(LIBS) $(LDFLAGS) bin: - mkdir bin + @mkdir bin -### include the C/C++ include -### dependencies -ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean spotless), ) +### Include the C/C++ include dependencies +ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean), ) -include $(OBJ:.o=.d) endif -### calculate C/C++ include -### dependencies -%.d: %.c - @[ -s $(OSDIR)/config.h ] || $(MAKE) config - @$(CC) -MM -MT '$(patsubst %.d,%.o, $@)' $(CFLAGS) $(CPPFLAGS) -w $< > $@ +### Calculate C/C++ include dependencies +%.d: %.cpp $(OSDIR)/config.h $(OSDIR)/config.mk + @$(CXX) -MM -MT '$(patsubst %.d,%.o, $@)' $(CXXFLAGS) $(CPPFLAGS) -w $< > $@ @[ -s $@ ] || rm -f $@ -%.d: %.cpp - @[ -s $(OSDIR)/config.h ] || $(MAKE) config - @$(CXX) -MM -MT '$(patsubst %.d,%.o, $@)' $(CXXFLAGS) $(CPPFLAGS) -w $< > $@ +### Main compiler rule +%.o: %.cpp $(OSDIR)/config.h $(OSDIR)/config.mk + @echo $< + @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o '$(patsubst %.cpp,%.o, $@)' $< @[ -s $@ ] || rm -f $@ ### Various cleaning functions @@ -71,12 +70,10 @@ clean: veryclean: clean find $(MODULES) -name \*.d | xargs rm -f rm -rf bin - -spotless: veryclean rm -rf arch $(OSDIR)/config.mk $(OSDIR)/config.h -### dependency stuff is done automatically, so these do nothing. +### Dependency stuff is done automatically, so these do nothing. .PHONY: dep depend @@ -94,7 +91,6 @@ help: @echo ' a -zip or -tgz variants)' @echo ' clean' @echo ' veryclean' - @echo ' spotless' @echo ### Rules to make various packaging diff --git a/config.mk b/config.mk index d269b153..d11f9b23 100644 --- a/config.mk +++ b/config.mk @@ -135,6 +135,9 @@ config-help: CONFTEST="\#include \nint main() { FILE *f=fopen(\"conftestval\", \"w\");\n\ if (!f) return 1; fprintf(f, \"%%d\\\n\", (int)sizeof(%s)); return 0; }\n" +$(OSDIR)/config.h $(OSDIR)/config.mk: + make config + config: @echo "Automatic configuration" @@ -229,11 +232,6 @@ config: ac_cv_sizeof_void_p=0; \ fi; \ echo "#define LC_SIZEOF_VOID_P $$ac_cv_sizeof_void_p" >> $(OSDIR)/config.h; \ - if test "$$ac_cv_sizeof_void_p" -eq "8"; then \ - echo "#define LC_POINTER_TO_INT(p) ((lcint32)(lcint64)(p))" >> $(OSDIR)/config.h; \ - else \ - echo "#define LC_POINTER_TO_INT(p) ((lcint32)(p))" >> $(OSDIR)/config.h; \ - fi; \ rm -f conftest.c conftest conftestval; \ \ echo -n "checking size of long long... "; \ @@ -260,6 +258,11 @@ config: case 8 in \ $$ac_cv_sizeof_long_long) lcint64="long long";; \ esac; \ + if test "$$ac_cv_sizeof_void_p" -eq "8"; then \ + echo "#define LC_POINTER_TO_INT(p) ((lcint32)(lcint64)(p))" >> $(OSDIR)/config.h; \ + else \ + echo "#define LC_POINTER_TO_INT(p) ((lcint32)(p))" >> $(OSDIR)/config.h; \ + fi; \ echo "" >> $(OSDIR)/config.h; \ echo "typedef signed char lcint8;" >> $(OSDIR)/config.h; \ echo "typedef unsigned char lcuint8;" >> $(OSDIR)/config.h; \ @@ -333,6 +336,21 @@ ifeq ($(TEST_GTK), 1) fi endif +## Check if the user has OpenGL installed + @echo -n "Checking for OpenGL support... " + @echo "#include " > gltest.c + @echo "int main() { return 0; }" >> gltest.c + @if { (eval $(CC) gltest.c -o gltest $(CPPFLAGS) $(LDFLAGS)); } && \ + (test -s gltest); then \ + echo "ok"; \ + else \ + rm -f gltest.c gltest; \ + echo "failed"; \ + rm -rf $(OSDIR)/config.mk $(OSDIR)/config.h; \ + exit 1; \ + fi + @rm -f gltest.c gltest + ## Check if the user has libjpeg installed @echo -n "Checking for jpeg support... " @echo "char jpeg_read_header();" > jpegtest.c diff --git a/linux/lc b/linux/lc deleted file mode 100644 index 4caa15c7..00000000 --- a/linux/lc +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# set the LeoCAD library path -LEOCAD_LIB=/mnt/f/projects/leocad/windows/debug/ -export LEOCAD_LIB - -# run the program -./leocad - - - - - - - - - diff --git a/version.mk b/version.mk index b9159d42..6da7877a 100644 --- a/version.mk +++ b/version.mk @@ -1,5 +1,5 @@ MAJOR := 0 -MINOR := 75 -PATCHLVL := 2 +MINOR := 76 +PATCHLVL := 0 VERSIONTAG := VERSION := $(MAJOR).$(MINOR).$(PATCHLVL)