1 # environment variables:
2 # $INCLUDE_PATH is a colon-delimited list of include directories
5 SPACE_CHAR
=$(empty
) $(empty
)
8 # # # # # # # # # # # # # # # # # # # # #
10 OUTPUT_FILE_ST
=libBase.a
11 OUTPUT_FILE_MT
=libBase_MT.a
12 OUTPUT_DIR
=..
/..
/..
/lib
13 OBJECT_DIR_ST
=.
/obj_st
14 OBJECT_DIR_MT
=.
/obj_mt
16 STL_HOME
=..
/..
/..
/..
/stlport453
18 INCLUDE_DIRS
=.. ..
/ $(STL_HOME
)/stlport
29 # # # # # # # # # # # # # # # # # # # # #
31 INCLUDE_DIR_LIST
=$(subst $(COLON_CHAR
),$(SPACE_CHAR
),$(INCLUDE_PATH
)) $(INCLUDE_DIRS
)
32 INCLUDE_FLAGS
=$(addprefix -I
,$(INCLUDE_DIR_LIST
))
33 CFLAGS_ST
=$(INCLUDE_FLAGS
) $(CFLAGS_USER
) -D_GNU_SOURCE
-Wall
-Wno-unknown-pragmas
34 CFLAGS_MT
=$(INCLUDE_FLAGS
) $(CFLAGS_USER
) -D_GNU_SOURCE
-D_REENTRANT
-Wall
-Wno-unknown-pragmas
35 CFLAGS_DEBUG_ST
=$(CFLAGS_ST
) -D_DEBUG
-g
36 CFLAGS_RELEASE_ST
=$(CFLAGS_ST
) -DNDEBUG
-O2
37 CFLAGS_DEBUG_MT
=$(CFLAGS_MT
) -D_DEBUG
-g
38 CFLAGS_RELEASE_MT
=$(CFLAGS_MT
) -DNDEBUG
-O2
40 LIBRARY_FLAGS
=$(addprefix -l
,$(LIBRARIES
))
41 LFLAGS
=$(LIBRARY_FLAGS
) $(LFLAGS_USER
) -r
42 LFLAGS_DEBUG
=$(LFLAGS
)
43 LFLAGS_RELEASE
=$(LFLAGS
)
48 # # # # # # # # # # # # # # # # # # # # #
50 DEBUG_OBJ_DIR_ST
=$(OBJECT_DIR_ST
)/debug
51 RELEASE_OBJ_DIR_ST
=$(OBJECT_DIR_ST
)/release
52 DEBUG_OBJ_DIR_MT
=$(OBJECT_DIR_MT
)/debug
53 RELEASE_OBJ_DIR_MT
=$(OBJECT_DIR_MT
)/release
55 DEBUG_DIR
=$(OUTPUT_DIR
)/debug
56 RELEASE_DIR
=$(OUTPUT_DIR
)/release
58 FIND
=$(shell ls
$(x
)/*.
cpp)
59 SOURCE_LIST
= $(SOURCE_FILES
) $(foreach x
, $(SOURCE_DIRS
), $(FIND
))
61 DEBUG_OBJ_LIST_ST
=$(addprefix $(DEBUG_OBJ_DIR_ST
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
62 RELEASE_OBJ_LIST_ST
=$(addprefix $(RELEASE_OBJ_DIR_ST
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
63 DEBUG_OBJ_LIST_MT
=$(addprefix $(DEBUG_OBJ_DIR_MT
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
64 RELEASE_OBJ_LIST_MT
=$(addprefix $(RELEASE_OBJ_DIR_MT
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
67 DEPENDENCY_LIST
= $(SOURCE_LIST
:.
cpp=.d
)
69 # # # # # # # # # # # # # # # # # # # # #
71 release_st
: echoRelease_st releaseDirs_st
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
72 @echo Successfully built
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
75 debug_st
: debugDirs_st
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
76 @echo Successfully built
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
79 release_mt
: echoRelease_mt releaseDirs_mt
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
80 @echo Successfully built
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
83 debug_mt
: debugDirs_mt
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
84 @echo Successfully built
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
87 all: clean debug_st release_st debug_mt release_mt
89 all_st
: clean debug_st release_st
91 all_mt
: clean debug_mt release_mt
93 # # # # # # # # # # # # # # # # # # # # #
96 @mkdir
-p
$(DEBUG_OBJ_DIR_ST
)
97 @mkdir
-p
$(DEBUG_DIR
)
99 $(DEBUG_OBJ_DIR_ST
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
100 $(CPP
) $(CFLAGS_DEBUG_ST
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
102 $(DEBUG_DIR
)/$(OUTPUT_FILE_ST
): $(DEBUG_OBJ_LIST_ST
)
103 $(LINK
) $(LFLAGS_DEBUG
) -o
$@
$(DEBUG_OBJ_LIST_ST
)
107 @mkdir
-p
$(DEBUG_OBJ_DIR_MT
)
108 @mkdir
-p
$(DEBUG_DIR
)
110 $(DEBUG_OBJ_DIR_MT
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
111 $(CPP
) $(CFLAGS_DEBUG_MT
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
113 $(DEBUG_DIR
)/$(OUTPUT_FILE_MT
): $(DEBUG_OBJ_LIST_MT
)
114 $(LINK
) $(LFLAGS_DEBUG
) -o
$@
$(DEBUG_OBJ_LIST_MT
)
117 # # # # # # # # # # # # # # # # # # # # #
120 @echo Building
$(OUTPUT_FILE_ST
)
121 @echo compiler
: $(CPP
) $(CFLAGS_RELEASE_ST
)
122 @echo linker
: $(LINK
) $(LFLAGS_RELEASE
)
126 @echo Building
$(OUTPUT_FILE_MT
)
127 @echo compiler
: $(CPP
) $(CFLAGS_RELEASE_MT
)
128 @echo linker
: $(LINK
) $(LFLAGS_RELEASE
)
132 # # # # # # # # # # # # # # # # # # # # #
135 @mkdir
-p
$(RELEASE_OBJ_DIR_ST
)
136 @mkdir
-p
$(RELEASE_DIR
)
138 $(RELEASE_OBJ_DIR_ST
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
139 @echo compiling
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
140 @
$(CPP
) $(CFLAGS_RELEASE_ST
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
142 $(RELEASE_DIR
)/$(OUTPUT_FILE_ST
): $(RELEASE_OBJ_LIST_ST
)
143 @echo linking
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
144 @
$(LINK
) $(LFLAGS_RELEASE
) -o
$@
$(RELEASE_OBJ_LIST_ST
)
147 @mkdir
-p
$(RELEASE_OBJ_DIR_MT
)
148 @mkdir
-p
$(RELEASE_DIR
)
150 $(RELEASE_OBJ_DIR_MT
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
151 @echo compiling
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
152 @
$(CPP
) $(CFLAGS_RELEASE_MT
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
154 $(RELEASE_DIR
)/$(OUTPUT_FILE_MT
): $(RELEASE_OBJ_LIST_MT
)
155 @echo linking
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
156 @
$(LINK
) $(LFLAGS_RELEASE
) -o
$@
$(RELEASE_OBJ_LIST_MT
)
158 # # # # # # # # # # # # # # # # # # # # #
162 .PHONY
: $(DEPENDENCY_LIST
)
164 depend
: .depend
$(DEPENDENCY_LIST
)
171 @echo Generating dependencies for
$(notdir $(@
:.d
=.
cpp))
172 @echo
-n
$(DEBUG_OBJ_DIR_ST
)/ >> .depend
173 @
$(CPP
) -MM
$(addprefix -I
,$(INCLUDE_DIRS
)) $(@
:.d
=.
cpp)>> .depend
174 @echo
-n
$(DEBUG_OBJ_DIR_MT
)/ >> .depend
175 @
$(CPP
) -MM
$(addprefix -I
,$(INCLUDE_DIRS
)) $(@
:.d
=.
cpp) >> .depend
176 @echo
-n
$(RELEASE_OBJ_DIR_ST
)/ >> .depend
177 @
$(CPP
) -MM
$(addprefix -I
,$(INCLUDE_DIRS
)) $(@
:.d
=.
cpp)>> .depend
178 @echo
-n
$(RELEASE_OBJ_DIR_MT
)/ >> .depend
179 @
$(CPP
) -MM
$(addprefix -I
,$(INCLUDE_DIRS
)) $(@
:.d
=.
cpp) >> .depend
181 # # # # # # # # # # # # # # # # # # # # #
184 @echo removing
"$(OBJECT_DIR_ST)/*.o"
185 @
rm -rf
$(OBJECT_DIR_ST
)
186 @echo removing
"$(OBJECT_DIR_MT)/*.o"
187 @
rm -rf
$(OBJECT_DIR_MT
)
188 @echo removing
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
189 @
rm -f
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
190 @echo removing
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
191 @
rm -f
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
192 @echo removing
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
193 @
rm -f
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
194 @echo removing
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
195 @
rm -f
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)