Skip to content

Commit

Permalink
include ex9_43_2.cpp in the makefile ,change the comment in GNU_makef…
Browse files Browse the repository at this point in the history
…ile_template and add .phony in makefile
  • Loading branch information
mudongliang committed Apr 17, 2015
1 parent 1956c05 commit 18d8992
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
30 changes: 18 additions & 12 deletions GNU_makefile_template
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#g++ compiler: options

# -std=c++0x enables ISO C++ 11 standard
# -I.. pulls in the Version_test.h file for conditional compilation
# of code the uses features that might not yet be implemented
# -std=c++11 enables ISO C++ 11 standard
# use -pedantic -Wall flag when compiling advised by author!
CC = g++
CCFLAGS = -pedantic -Wall -std=c++11 -I .

Expand All @@ -14,11 +13,16 @@ LOCFLAGS = -I ..

####### To compile without using a makefile
# To compile an object file from a source file you could execute
# g++ -std=c++0x -c filename.cc # produces filename.obj
# g++ -pedantic -Wall -std=c++11 -I . -c filename.cpp -o filename.o
# g++ -pedantic -Wall -std=c++11 -I . -c factMain.cc -o factMain.o
# g++ -pedantic -Wall -std=c++11 -I . -c fact.cc -o fact.o

# To compile an executable file from an object file, you would execute
# g++ -std=c++0x filename.o # produces filename.exe
# g++ -pedantic -Wall -std=c++11 -I . filename.o -o filename
# g++ -pedantic -Wall -std=c++11 -I . -o factMain factMain.o fact.o

# To compile an executable file from a source file, you would execute
# g++ -std=c++0x filename.cc # produces filename.exe
# g++ -pedantic -Wall -std=c++11 -I . -o factMain factMain.cpp fact.cpp
#######

# each subdirectory contains a Makefile that lists the executable
Expand All @@ -29,7 +33,7 @@ LOCFLAGS = -I ..
# to build each .exe file listed in that subdirectory's makefile
all: $(OBJECTS)

# rule that says how to make a .o object file from a .cc source file
# rule that says how to make a .o object file from a .cc/.cpp source file
# for a given source file in a given directory you could compile it
# into an object file by executing "make filename.o"

Expand All @@ -45,16 +49,18 @@ all: $(OBJECTS)
%.o: %.cpp
$(CC) $(CCFLAGS) $(LOCFLAGS) -c $< -o $@

# rule that says how to make a .exe executable file from a .o object file
# rule that says how to make an executable file from the object file
# for a given object file in a given directory you could compile it
# into an executable file by executing "make filename"
$(OBJECTS): % : %.o
$(CC) $(CCFLAGS) $(LOCFLAGS) $< -o $@

# target to clean up the object files and any core files
# executing "make clean" in a subdirectory will remove all
# files named core or any file ending in .obj, or .stackdump
# target to clean up the object files
# executing "make clean" in a subdirectory will
# remove any file that is ending in .o
clean:
rm -rf *.o

# target to remove executable files as well as object and core files
# target to remove executable files as well as object files
clobber: clean
rm -rf $(OBJECTS) $(OTHOBJS)
3 changes: 2 additions & 1 deletion ch09/makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#cutable files for this directory
OBJECTS = ex9_13 ex9_14 ex9_15 ex9_16 ex9_18 ex9_19 ex9_20 ex9_22 ex9_24 \
ex9_26 ex9_27 ex9_31_1 ex9_31_2 ex9_32 ex9_33 ex9_34 ex9_38 \
ex9_41 ex9_43 ex9_44 ex9_45 ex9_46 ex9_47_1 ex9_47_2 ex9_49 \
ex9_41 ex9_43_2 ex9_44 ex9_45 ex9_46 ex9_47_1 ex9_47_2 ex9_49 \
ex9_50 ex9_51 ex9_52
# ex9_43_1.cpp can be compiled by clang or vs2012+
all:$(OBJECTS)

# tells make to use the file "../GNU_makefile_template", which
Expand Down
5 changes: 5 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.PHONY : all clean clobber

# automake compile all the files in all subdirectories
all:
cd ch01; make all
cd ch02; make all
Expand All @@ -18,6 +21,7 @@ all:
cd ch17; make all
cd ch18; make all

# automake remvoe the object file in all subdirectories
clean:
cd ch01; make clean
cd ch02; make clean
Expand All @@ -38,6 +42,7 @@ clean:
cd ch17; make clean
cd ch18; make clean

# automake remove the object and executable files in all subdirectories
clobber:
cd ch01; make clobber
cd ch02; make clobber
Expand Down

0 comments on commit 18d8992

Please sign in to comment.