From f0ea84ce35d5455e5ca4911e5f1e07907db6adbb Mon Sep 17 00:00:00 2001 From: Micha Hoiting Date: Mon, 5 Nov 2012 16:47:55 +0100 Subject: [PATCH] Improve makefiles Added the use of the $(MAKE) variable to support 'gnumake'. Fixed an issue with some make compile rule and the -o option. All targets are removed from the build directory when running 'make clean'. --- Makefile | 14 +++++++------- examples/Makefile | 8 ++++---- examples/driver_testing/Makefile | 6 ++---- gtest/Makefile | 2 +- test/Makefile | 7 ++++--- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index ea10d3a..a774e0b 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -all: +all: mkdir -p build - cd gtest; make all - cd test; make all - cd examples; make all + cd gtest; $(MAKE) all + cd test; $(MAKE) all + cd examples; $(MAKE) all clean: - cd gtest; make clean - cd test; make clean - cd examples; make clean + cd gtest; $(MAKE) clean + cd test; $(MAKE) clean + cd examples; $(MAKE) clean diff --git a/examples/Makefile b/examples/Makefile index c49de2b..f352de3 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,7 +1,7 @@ all: - cd embedded_ui; make all - cd driver_testing; make all + cd embedded_ui; $(MAKE) all + cd driver_testing; $(MAKE) all clean: - cd embedded_ui; make clean - cd driver_testing; make clean + cd embedded_ui; $(MAKE) clean + cd driver_testing; $(MAKE) clean diff --git a/examples/driver_testing/Makefile b/examples/driver_testing/Makefile index 108cb32..b636a01 100644 --- a/examples/driver_testing/Makefile +++ b/examples/driver_testing/Makefile @@ -30,10 +30,8 @@ clean: @echo " rm -f *~" rm -f *~ @echo "Removing programs" - @echo " rm -f "$(C_PROGNAME) - rm -f $(C_PROGNAME) - @echo " rm -f "$(CPP_PROGNAME) $(TEMPLATE_PROGNAME) - rm -f $(CPP_PROGNAME) $(TEMPLATE_PROGNAME) + @echo " rm -f $(CPP_PROGNAME_NOFFF) $(CPP_PROGNAME_FFF) $(TEMPLATE_PROGNAME)" + rm -f $(CPP_PROGNAME_NOFFF) $(CPP_PROGNAME_FFF) $(TEMPLATE_PROGNAME) $(BUILD_DIR)/%.o: %.c diff --git a/gtest/Makefile b/gtest/Makefile index eb7b8f4..6593c0e 100644 --- a/gtest/Makefile +++ b/gtest/Makefile @@ -10,7 +10,7 @@ SOURCES=gtest-all.cc gtest-main.cc $(BUILD_DIR)/%.o: %.cc @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -I../ -O0 -g3 -Wall -c -o"$@" "$<" + g++ -I../ -O0 -g3 -Wall -c -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/test/Makefile b/test/Makefile index 67407e6..76fc8fc 100644 --- a/test/Makefile +++ b/test/Makefile @@ -32,14 +32,14 @@ all: $(FFF_TEST_CPP_TARGET) $(FFF_TEST_C_TARGET) $(FFF_TEST_GLOBAL_C_TARGET) $(F $(BUILD_DIR)/%.o: %.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -I../ -O0 -g3 -Wall -c -o"$@" "$<" + g++ -I../ -O0 -g3 -Wall -c -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' $(BUILD_DIR)/%.o: %.c @echo 'Building file: $<' @echo 'Invoking: GCC C Compiler' - gcc -I../ -O0 -g3 -Wall -std=c99 -c -o"$@" "$<" + gcc -I../ -O0 -g3 -Wall -std=c99 -c -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' @@ -75,6 +75,7 @@ $(FFF_TEST_GLOBAL_CPP_TARGET): $(FFF_TEST_GLOBAL_CPP_OBJS) # Other Targets clean: - -$(RM) $(FFF_TEST_CPP_OBJS) $(FFF_TEST_GLOBAL_C_OBJS) $(FFF_TEST_C_OBJS) $(FFF_TEST_CPP_TARGET) $(FFF_TEST_C_TARGET) $(FFF_TEST_GLOBAL_C_TARGET) + -$(RM) $(FFF_TEST_CPP_OBJS) $(FFF_TEST_GLOBAL_C_OBJS) $(FFF_TEST_C_OBJS) \ + $(FFF_TEST_CPP_TARGET) $(FFF_TEST_C_TARGET) $(FFF_TEST_GLOBAL_CPP_TARGET) $(FFF_TEST_GLOBAL_C_TARGET) -@echo ' '