Skip to content

Commit

Permalink
Improve makefiles
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
michahoiting committed Nov 7, 2012
1 parent 82c6df4 commit f0ea84c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions examples/driver_testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gtest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' '

Expand Down
7 changes: 4 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' '

Expand Down Expand Up @@ -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 ' '

0 comments on commit f0ea84c

Please sign in to comment.