4 # See http://www.gnu.org/manual/make/html_chapter/make_toc.html#SEC_Contents
5 # for documentation on makefiles. Most of this was culled from the ncurses makefile.
9 #################################
10 #################################
12 #################################
13 #################################
15 # ':=' denotes a "simply expanded" variable. It's value is
16 # set at the time of definition and it never recursively expands
17 # when used. This is in contrast to using '=' which denotes a
18 # recursively expanded variable.
22 # Sane defaults, which are typically overridden on the command line.
24 OBJROOT=$(SRCROOT)/build
27 APPLE_INTERNAL_DIR=/AppleInternal
30 # Disallow $(SRCROOT) == $(OBJROOT)
31 ifeq ($(OBJROOT), $(SRCROOT))
32 $(error SRCROOT same as OBJROOT)
35 #################################
37 #################################
39 # For installhdrs. Not every compiled module has an associated header. Normally,
40 # ICU installs headers as a sub-targe of the install target. But since we only want
41 # certain libraries to install (and since we link all of our own .o modules), we need
42 # invoke the headers targets ourselves. This may be problematic because there isn't a
43 # good way to dist-clean afterwards...we need to do explicit dist-cleans, especially if
44 # install the extra libraries.
47 # EXTRA_HDRS = ./extra/ustdio/ ./layout/
48 HDR_MAKE_SUBDIR = ./common/ ./i18n/ $(EXTRA_HDRS)
50 #################################
52 #################################
54 # For install. We currently don't install EXTRA_LIBS. We also don't install the data
55 # directly into the ICU library. It is now installed at /usr/share/icu/*.dat. Thus we
56 # don't use DATA_OBJ anymore. This could change if we decide to move the data back into
57 # the icucore monolithic library.
59 INSTALL = /usr/bin/install
60 COMMON_OBJ = ./common/*.o
62 STUB_DATA_OBJ = ./stubdata/*.o
63 COMMON_SRC = $(OBJROOT)/common/*.c
64 I18N_SRC = $(OBJROOT)/i18n/*.c
65 STUB_DATA_SRC = $(OBJROOT)/stubdata/*.c
67 #EXTRA_LIBS =./extra/ ./layout/ ./tools/ctestfw/ ./tools/toolutil/
68 #DATA_OBJ = ./data/out/build/*.o
70 #################################
72 #################################
74 #We need to clean after installing.
78 # Some directories aren't cleaned recursively. Clean them manually...
79 MANUAL_CLEAN_TOOLS = ./tools/dumpce
80 MANUAL_CLEAN_EXTRA = ./extra/scrptrun ./samples/layout ./extra/ustdio ./extra
81 MANUAL_CLEAN_TEST = ./test/collperf ./test/iotest ./test/letest ./test/thaitest ./test/threadtest ./test/testmap ./test
82 MANUAL_CLEAN_SAMPLE = ./samples/layout ./samples
84 CLEAN_SUBDIR = ./stubdata ./common ./i18n ./layout ./layoutex ./data ./tools ./$(MANUAL_CLEAN_TOOLS) $(MANUAL_CLEAN_EXTRA) $(MANUAL_CLEAN_TEST) $(MANUAL_CLEAN_SAMPLE)
86 #################################
88 #################################
90 CONFIG_FLAGS = --disable-renaming --disable-extras --disable-ustdio --disable-layout \
91 --disable-samples --with-data-packaging=archive --prefix=/usr/local \
92 --srcdir=$(SRCROOT)/icuSources
94 #################################
96 #################################
98 # This may or may not be an appropriate name for the icu dylib. This naming scheme is
99 # an attempt to follow the icu convention in naming the dylib and then having symbolic
100 # links of easier to remember library names point it it. *UPDATE* the version and
101 # sub-version variables as needed. The Core version should be 'A' until the core
102 # version changes it's API...that is a new version isn't backwards compatible.
103 # The ICU version/subversion should reflect the actual ICU version.
112 INSTALLED_DYLIB = lib$(LIB_NAME).$(CORE_VERS).$(DYLIB_SUFF)
113 DYLIB = lib$(LIB_NAME).$(DYLIB_SUFF)
115 #################################
117 #################################
119 datadir=/usr/share/icu/
120 OPEN_SOURCE_VERSIONS_DIR=/usr/local/OpenSourceVersions/
121 OPEN_SOURCE_LICENSES_DIR=/usr/local/OpenSourceLicenses/
122 ICU_DATA_DIR= data/out
123 B_DATA_FILE=icudt$(ICU_VERS)b.dat
124 L_DATA_FILE=icudt$(ICU_VERS)l.dat
126 #################################
127 # Environment variables
128 #################################
130 # $(RC_ARCHS:%=-arch %) is a substitution reference. It denotes, in this case,
131 # for every value <val> in RC_ARCHS, replace it with "-arch <val>". Substitution
132 # references have the form $(var:a=b). We can insert the strip and prebinding commands
133 # into CFLAGS (and CXXFLAGS). This controls a lot of the external variables so we don't
134 # need to directly modify the ICU files (like for CFLAGS, etc).
136 LIBOVERRIDES=LIBICUDT="-L$(OBJROOT) -l$(LIB_NAME)" \
137 LIBICUUC="-L$(OBJROOT) -l$(LIB_NAME)" \
138 LIBICUI18N="-L$(OBJROOT) -l$(LIB_NAME)"
140 ENV= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
141 CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions" \
142 CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions -fno-rtti" \
143 RC_ARCHS="$(RC_ARCHS)" \
144 DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
146 ENV_CONFIGURE= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
147 CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions" \
148 CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions -fno-rtti" \
149 RC_ARCHS="$(RC_ARCHS)" \
150 DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
152 ENV_DEBUG = APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
153 CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions" \
154 CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions -fno-rtti" \
155 RC_ARCHS="$(RC_ARCHS)" \
156 DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
159 ENV_debug = ENV_DEBUG
161 ORDERFILE=/usr/local/lib/OrderFiles/libicucore.order
162 ifeq "$(shell test -f $(ORDERFILE) && echo YES )" "YES"
163 SECTORDER_FLAGS=-sectorder __TEXT __text $(ORDERFILE)
169 #################################
170 #################################
172 #################################
173 #################################
175 .PHONY : icu check installsrc installhdrs clean install debug debug-install
178 icu debug : $(OBJROOT)/Makefile
180 $(MAKE) $($(ENV_$@)); \
181 $($(ENV_$@)) $(CXX) -current_version $(ICU_VERS).$(ICU_SUBVERS) -compatibility_version 1 -dynamiclib -dynamic \
182 $(RC_ARCHS:%=-arch %) $(CXXFLAGS) $(LDFLAGS) -single_module $(SECTORDER_FLAGS) \
183 -install_name $(libdir)$(INSTALLED_DYLIB) -o ./$(INSTALLED_DYLIB) $(COMMON_OBJ) $(I18N_OBJ) $(STUB_DATA_OBJ); \
184 if test -f ./$(ICU_DATA_DIR)/$(B_DATA_FILE); then \
185 ln -fs ./$(ICU_DATA_DIR)/$(B_DATA_FILE); \
187 DYLD_LIBRARY_PATH="./lib:./stubdata" \
188 ./bin/icuswap -tb ./$(ICU_DATA_DIR)/$(L_DATA_FILE) $(B_DATA_FILE); \
190 if test -f ./$(ICU_DATA_DIR)/$(L_DATA_FILE); then \
191 ln -fs ./$(ICU_DATA_DIR)/$(L_DATA_FILE); \
193 DYLD_LIBRARY_PATH="./lib:./stubdata" \
194 ./bin/icuswap -tl ./$(ICU_DATA_DIR)/$(B_DATA_FILE) $(L_DATA_FILE); \
200 $(MAKE) $(ENV) check; \
204 (cd $(OBJROOT)/samples; \
205 $(MAKE) $(ENV_DEBUG) $(LIBOVERRIDES); \
209 (cd $(OBJROOT)/extra; \
210 $(MAKE) $(ENV_DEBUG) $(LIBOVERRIDES); \
213 $(OBJROOT)/Makefile :
214 if test ! -d $(OBJROOT); then \
215 mkdir -p $(OBJROOT); \
217 (cd $(OBJROOT); $(ENV_CONFIGURE) $(SRCROOT)/icuSources/configure $(CONFIG_FLAGS);)
219 debug-install: debug installhdrs
220 if test ! -d $(DSTROOT)$(libdir)/; then \
221 $(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
223 $(INSTALL) -b -m 0664 $(OBJROOT)/$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB)
224 (cd $(DSTROOT)$(libdir); \
225 ln -fs $(INSTALLED_DYLIB) $(DYLIB));
226 for subdir in $(EXTRA_LIBS); do \
227 (cd $(OBJROOT)/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV_DEBUG) install-library;) \
229 if test ! -d $(DSTROOT)$(datadir)/; then \
230 $(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
232 if test -f $(OBJROOT)/$(B_DATA_FILE); then \
233 $(INSTALL) -b -m 0644 $(OBJROOT)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
235 if test -f $(OBJROOT)/$(L_DATA_FILE); then \
236 $(INSTALL) -b -m 0644 $(OBJROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
238 if test ! -d $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; then \
239 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; \
241 $(INSTALL) -b -m 0644 $(SRCROOT)/ICU.plist $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)ICU.plist;
242 if test ! -d $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; then \
243 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; \
245 $(INSTALL) -b -m 0644 $(SRCROOT)/license.html $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)ICU.html;
247 #################################
249 #################################
251 # Since our sources are in icuSources (ignore the ICU subdirectory for now), we wish to
252 # copy them to somewhere else. We tar it to stdout, cd to the appropriate directory, and
253 # untar from stdin. We then look for all the CVS directories and remove them. We may have
254 # to remove the .cvsignore files also.
257 if test ! -d $(SRCROOT); then mkdir $(SRCROOT); fi;
258 if test -d $(SRCROOT)/icuSources ; then rm -rf $(SRCROOT)/icuSources; fi;
259 tar cf - ./makefile ./ICU.plist ./license.html ./icuSources | (cd $(SRCROOT) ; tar xfp -); \
260 for i in `find $(SRCROOT)/icuSources/ | grep "CVS$$"` ; do \
261 if test -d $$i ; then \
265 for j in `find $(SRCROOT)/icuSources/ | grep ".cvsignore"` ; do \
266 if test -f $$j ; then \
271 # This works. Just not for ~ in the DSTROOT. We run configure first (in case it hasn't
272 # been already). Then we make the install-headers target on specific makefiles (since
273 # not every subdirectory/sub-component has a install-headers target).
275 installhdrs : $(OBJROOT)/Makefile
277 for subdir in $(HDR_MAKE_SUBDIR); do \
278 (cd $$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-headers); \
281 # We run configure and run make first. This generates the .o files. We then link them
282 # all up together into libicucore. Then we put it into its install location, create
283 # symbolic links, and then strip the main dylib. Then install the remaining libraries.
284 # We cleanup the sources folder.
286 install : installhdrs icu
287 if test ! -d $(DSTROOT)$(libdir)/; then \
288 $(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
290 $(INSTALL) -b -m 0664 $(OBJROOT)/$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB)
291 (cd $(DSTROOT)$(libdir); \
292 ln -fs $(INSTALLED_DYLIB) $(DYLIB));
293 cp $(OBJROOT)/$(INSTALLED_DYLIB) $(SYMROOT)/$(INSTALLED_DYLIB);
294 strip -x -u -r -S $(DSTROOT)$(libdir)$(INSTALLED_DYLIB);
295 for subdir in $(EXTRA_LIBS); do \
296 (cd $(OBJROOT)/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-library;) \
298 if test ! -d $(DSTROOT)$(datadir)/; then \
299 $(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
301 if test -f $(OBJROOT)/$(B_DATA_FILE); then \
302 $(INSTALL) -b -m 0644 $(OBJROOT)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
304 if test -f $(OBJROOT)/$(L_DATA_FILE); then \
305 $(INSTALL) -b -m 0644 $(OBJROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
307 if test ! -d $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; then \
308 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; \
310 $(INSTALL) -b -m 0644 $(SRCROOT)/ICU.plist $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)ICU.plist;
311 if test ! -d $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; then \
312 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; \
314 $(INSTALL) -b -m 0644 $(SRCROOT)/license.html $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)ICU.html;