1 # environment variables:
2 # $INCLUDE_PATH is a colon-delimited list of include directories
5 SPACE_CHAR
=$(empty
) $(empty
)
8 # # # # # # # # # # # # # # # # # # # # #
10 OUTPUT_FILE_ST
=libUnicode.a
11 OUTPUT_FILE_MT
=libUnicode_MT.a
13 OBJECT_DIR_ST
=.
/obj_st
14 OBJECT_DIR_MT
=.
/obj_mt
27 # # # # # # # # # # # # # # # # # # # # #
29 INCLUDE_DIR_LIST
=$(subst $(COLON_CHAR
),$(SPACE_CHAR
),$(INCLUDE_PATH
)) $(INCLUDE_DIRS
)
30 INCLUDE_FLAGS
=$(addprefix -I
,$(INCLUDE_DIR_LIST
))
31 CFLAGS_ST
=$(INCLUDE_FLAGS
) $(CFLAGS_USER
) -D_GNU_SOURCE
-Wall
-Wno-unknown-pragmas
32 CFLAGS_MT
=$(INCLUDE_FLAGS
) $(CFLAGS_USER
) -D_GNU_SOURCE
-D_REENTRANT
-Wall
-Wno-unknown-pragmas
33 CFLAGS_DEBUG_ST
=$(CFLAGS_ST
) -D_DEBUG
-g
34 CFLAGS_RELEASE_ST
=$(CFLAGS_ST
) -DNDEBUG
-O2
35 CFLAGS_DEBUG_MT
=$(CFLAGS_MT
) -D_DEBUG
-g
36 CFLAGS_RELEASE_MT
=$(CFLAGS_MT
) -DNDEBUG
-O2
38 LIBRARY_FLAGS
=$(addprefix -l
,$(LIBRARIES
))
39 LFLAGS
=$(LIBRARY_FLAGS
) $(LFLAGS_USER
) -r
40 LFLAGS_DEBUG
=$(LFLAGS
)
41 LFLAGS_RELEASE
=$(LFLAGS
)
46 # # # # # # # # # # # # # # # # # # # # #
48 DEBUG_OBJ_DIR_ST
=$(OBJECT_DIR_ST
)/debug
49 RELEASE_OBJ_DIR_ST
=$(OBJECT_DIR_ST
)/release
50 DEBUG_OBJ_DIR_MT
=$(OBJECT_DIR_MT
)/debug
51 RELEASE_OBJ_DIR_MT
=$(OBJECT_DIR_MT
)/release
53 DEBUG_DIR
=$(OUTPUT_DIR
)/debug
54 RELEASE_DIR
=$(OUTPUT_DIR
)/release
56 FIND
=$(shell ls
$(x
)/*.
cpp)
57 SOURCE_LIST
= $(SOURCE_FILES
) $(foreach x
, $(SOURCE_DIRS
), $(FIND
))
59 DEBUG_OBJ_LIST_ST
=$(addprefix $(DEBUG_OBJ_DIR_ST
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
60 RELEASE_OBJ_LIST_ST
=$(addprefix $(RELEASE_OBJ_DIR_ST
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
61 DEBUG_OBJ_LIST_MT
=$(addprefix $(DEBUG_OBJ_DIR_MT
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
62 RELEASE_OBJ_LIST_MT
=$(addprefix $(RELEASE_OBJ_DIR_MT
)/, $(notdir $(SOURCE_LIST
:.
cpp=.o
)))
64 # # # # # # # # # # # # # # # # # # # # #
66 release_st
: echoRelease_st releaseDirs_st
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
67 @echo Successfully built
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
70 debug_st
: debugDirs_st
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
71 @echo Successfully built
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
74 release_mt
: echoRelease_mt releaseDirs_mt
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
75 @echo Successfully built
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
78 debug_mt
: debugDirs_mt
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
79 @echo Successfully built
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
82 all: clean debug_st release_st debug_mt release_mt
84 all_st
: clean debug_st release_st
86 all_mt
: clean debug_mt release_mt
88 # # # # # # # # # # # # # # # # # # # # #
91 @mkdir
-p
$(DEBUG_OBJ_DIR_ST
)
92 @mkdir
-p
$(DEBUG_DIR
)
94 $(DEBUG_OBJ_DIR_ST
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
95 $(CPP
) $(CFLAGS_DEBUG_ST
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
97 $(DEBUG_DIR
)/$(OUTPUT_FILE_ST
): $(DEBUG_OBJ_LIST_ST
)
98 $(LINK
) $(LFLAGS_DEBUG
) -o
$@
$(DEBUG_OBJ_LIST_ST
)
102 @mkdir
-p
$(DEBUG_OBJ_DIR_MT
)
103 @mkdir
-p
$(DEBUG_DIR
)
105 $(DEBUG_OBJ_DIR_MT
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
106 $(CPP
) $(CFLAGS_DEBUG_MT
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
108 $(DEBUG_DIR
)/$(OUTPUT_FILE_MT
): $(DEBUG_OBJ_LIST_MT
)
109 $(LINK
) $(LFLAGS_DEBUG
) -o
$@
$(DEBUG_OBJ_LIST_MT
)
112 # # # # # # # # # # # # # # # # # # # # #
115 @echo Building
$(OUTPUT_FILE_ST
)
116 @echo compiler
: $(CPP
) $(CFLAGS_RELEASE_ST
)
117 @echo linker
: $(LINK
) $(LFLAGS_RELEASE
)
121 @echo Building
$(OUTPUT_FILE_MT
)
122 @echo compiler
: $(CPP
) $(CFLAGS_RELEASE_MT
)
123 @echo linker
: $(LINK
) $(LFLAGS_RELEASE
)
127 # # # # # # # # # # # # # # # # # # # # #
130 @mkdir
-p
$(RELEASE_OBJ_DIR_ST
)
131 @mkdir
-p
$(RELEASE_DIR
)
133 $(RELEASE_OBJ_DIR_ST
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
134 @echo compiling
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
135 @
$(CPP
) $(CFLAGS_RELEASE_ST
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
137 $(RELEASE_DIR
)/$(OUTPUT_FILE_ST
): $(RELEASE_OBJ_LIST_ST
)
138 @echo linking
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
139 @
$(LINK
) $(LFLAGS_RELEASE
) -o
$@
$(RELEASE_OBJ_LIST_ST
)
142 @mkdir
-p
$(RELEASE_OBJ_DIR_MT
)
143 @mkdir
-p
$(RELEASE_DIR
)
145 $(RELEASE_OBJ_DIR_MT
)/%.o
: $(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
146 @echo compiling
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
147 @
$(CPP
) $(CFLAGS_RELEASE_MT
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SOURCE_LIST
))
149 $(RELEASE_DIR
)/$(OUTPUT_FILE_MT
): $(RELEASE_OBJ_LIST_MT
)
150 @echo linking
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
151 @
$(LINK
) $(LFLAGS_RELEASE
) -o
$@
$(RELEASE_OBJ_LIST_MT
)
154 # # # # # # # # # # # # # # # # # # # # #
157 @echo removing
"$(OBJECT_DIR_ST)/*.o"
158 @
rm -rf
$(OBJECT_DIR_ST
)
159 @echo removing
"$(OBJECT_DIR_MT)/*.o"
160 @
rm -rf
$(OBJECT_DIR_MT
)
161 @echo removing
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
162 @
rm -f
$(DEBUG_DIR
)/$(OUTPUT_FILE_ST
)
163 @echo removing
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
164 @
rm -f
$(RELEASE_DIR
)/$(OUTPUT_FILE_ST
)
165 @echo removing
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
166 @
rm -f
$(DEBUG_DIR
)/$(OUTPUT_FILE_MT
)
167 @echo removing
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)
168 @
rm -f
$(RELEASE_DIR
)/$(OUTPUT_FILE_MT
)