diff --git a/Makefile b/Makefile index 4495a0b..7b5c82a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ all: - cd src/test; make all - cd src/examples; make all + mkdir -p build + cd test; make all + cd examples; make all clean: - cd src/test; make clean - cd src/examples; make clean + cd test; make clean + cd examples; make clean diff --git a/src/examples/Makefile b/examples/Makefile similarity index 68% rename from src/examples/Makefile rename to examples/Makefile index 9b5b264..75ef88b 100644 --- a/src/examples/Makefile +++ b/examples/Makefile @@ -1,22 +1,20 @@ $(VERBOSE).SILENT: -TEMPLATE_PROGNAME = ../../build/template -C_PROGNAME = ../../build/cmock -CPP_PROGNAME = ../../build/cppmock +BUILD_DIR = ../build +TEMPLATE_PROGNAME = $(BUILD_DIR)/template +C_PROGNAME = $(BUILD_DIR)/cmock +CPP_PROGNAME = $(BUILD_DIR)/cppmock CC = gcc CC += -c CPP = g++ CPP += -c LD = g++ -ODIR = ../../build - -C_OBJFILES = ../../build/cmocktest.o ../../build/embedded.o -TEMPLATE_OBJFILES = ../../build/test_suite_template.o -CPP_OBJFILES = ../../build/cppmocktest.o ../../build/embedded.o +C_OBJFILES = $(BUILD_DIR)/cmocktest.o $(BUILD_DIR)/embedded.o +TEMPLATE_OBJFILES = $(BUILD_DIR)/test_suite_template.o +CPP_OBJFILES = $(BUILD_DIR)/cppmocktest.o $(BUILD_DIR)/embedded.o CPP_LIBS = -lgtest -lpthread -lgtest_main -ODIR = ../../build all: $(C_PROGNAME) $(CPP_PROGNAME) $(TEMPLATE_PROGNAME) @@ -24,24 +22,24 @@ all: $(C_PROGNAME) $(CPP_PROGNAME) $(TEMPLATE_PROGNAME) clean: @echo "Cleaning object files" - @echo " rm -f ../../build/*.o" - rm -f ../../build/*.o + @echo " rm -f $(BUILD_DIR)/*.o" + rm -f $(BUILD_DIR)/*.o @echo "Cleaning backups" @echo " rm -f *~" rm -f *~ @echo "Removing programs" @echo " rm -f "$(C_PROGNAME) rm -f $(C_PROGNAME) - @echo " rm -f "$(CPP_PROGNAME) - rm -f $(CPP_PROGNAME) + @echo " rm -f "$(CPP_PROGNAME) $(TEMPLATE_PROGNAME) + rm -f $(CPP_PROGNAME) $(TEMPLATE_PROGNAME) -../../build/%.o: %.c +$(BUILD_DIR)/%.o: %.c @echo "Compiling "$@ @echo " CC "$< $(CC) -o $@ $< -../../build/%.o: %.cpp +$(BUILD_DIR)/%.o: %.cpp @echo "Compiling "$@ @echo " CPP "$< $(CPP) -I/home/mlong/tools/gtest/gtest-1.5.0/include -o $@ $< diff --git a/src/examples/cmocktest.c b/examples/cmocktest.c similarity index 100% rename from src/examples/cmocktest.c rename to examples/cmocktest.c diff --git a/src/examples/cppmocktest.cpp b/examples/cppmocktest.cpp similarity index 100% rename from src/examples/cppmocktest.cpp rename to examples/cppmocktest.cpp diff --git a/src/examples/embedded.c b/examples/embedded.c similarity index 100% rename from src/examples/embedded.c rename to examples/embedded.c diff --git a/src/examples/embedded.h b/examples/embedded.h similarity index 100% rename from src/examples/embedded.h rename to examples/embedded.h diff --git a/src/examples/test_suite_template.c b/examples/test_suite_template.c similarity index 100% rename from src/examples/test_suite_template.c rename to examples/test_suite_template.c diff --git a/src/fakegen.rb b/fakegen.rb similarity index 100% rename from src/fakegen.rb rename to fakegen.rb diff --git a/src/fff.h b/fff.h similarity index 100% rename from src/fff.h rename to fff.h diff --git a/src/test/Makefile b/test/Makefile similarity index 67% rename from src/test/Makefile rename to test/Makefile index 6821269..e480e13 100644 --- a/src/test/Makefile +++ b/test/Makefile @@ -1,18 +1,22 @@ +BUILD_DIR = ../build + CPP_SRCS += \ fff_test.cpp OBJS += \ -../../build/fff_test.o +$(BUILD_DIR)/fff_test.o LIBS := -lgtest_main -lgtest -lpthread +PROGNAME = $(BUILD_DIR)/fff_test + # All Target -all: ../../build/fff_test +all: $(BUILD_DIR)/fff_test # Each subdirectory must supply rules for building sources it contributes -../../build/%.o: %.cpp +$(BUILD_DIR)/%.o: %.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' g++ -I/home/mlong/tools/gtest/gtest-1.5.0/include -O0 -g3 -Wall -c -o"$@" "$<" @@ -21,15 +25,15 @@ all: ../../build/fff_test # Tool invocations -../../build/fff_test: $(OBJS) $(USER_OBJS) +$(PROGNAME): $(OBJS) $(USER_OBJS) @echo 'Building target: $@' @echo 'Invoking: GCC C++ Linker' - g++ -L/home/mlong/tools/gtest -o"../../build/fff_test" $(OBJS) $(LIBS) + g++ -L/home/mlong/tools/gtest -o"$(PROGNAME)" $(OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' # Other Targets clean: - -$(RM) $(OBJS) fff_test + -$(RM) $(OBJS) $(PROGNAME) -@echo ' ' diff --git a/src/test/fff_test.cpp b/test/fff_test.cpp similarity index 100% rename from src/test/fff_test.cpp rename to test/fff_test.cpp