]> git.saurik.com Git - apple/icu.git/blame - makefile
ICU-6.2.7.tar.gz
[apple/icu.git] / makefile
CommitLineData
b75a7d8f
A
1##
2# Makefile for ICU
3#
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.
6#
7##
8
9#################################
10#################################
11# MAKE VARS
12#################################
13#################################
14
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.
19
20SHELL := /bin/sh
21
22# Sane defaults, which are typically overridden on the command line.
374ca955
A
23SRCROOT=$(shell pwd)
24OBJROOT=$(SRCROOT)/build
25DSTROOT=$(OBJROOT)
b75a7d8f 26SYMROOT=$(OBJROOT)
b75a7d8f
A
27APPLE_INTERNAL_DIR=/AppleInternal
28RC_ARCHS=
29
374ca955
A
30# Disallow $(SRCROOT) == $(OBJROOT)
31ifeq ($(OBJROOT), $(SRCROOT))
32$(error SRCROOT same as OBJROOT)
33endif
b75a7d8f
A
34
35#################################
36# Headers
37#################################
38
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.
45
46EXTRA_HDRS =
47# EXTRA_HDRS = ./extra/ustdio/ ./layout/
48HDR_MAKE_SUBDIR = ./common/ ./i18n/ $(EXTRA_HDRS)
49
50#################################
51# Install
52#################################
53
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.
58
59INSTALL = /usr/bin/install
60COMMON_OBJ = ./common/*.o
61I18N_OBJ = ./i18n/*.o
62STUB_DATA_OBJ = ./stubdata/*.o
374ca955
A
63COMMON_SRC = $(OBJROOT)/common/*.c
64I18N_SRC = $(OBJROOT)/i18n/*.c
65STUB_DATA_SRC = $(OBJROOT)/stubdata/*.c
b75a7d8f
A
66EXTRA_LIBS =
67#EXTRA_LIBS =./extra/ ./layout/ ./tools/ctestfw/ ./tools/toolutil/
68#DATA_OBJ = ./data/out/build/*.o
69
70#################################
71# Cleaning
72#################################
73
74#We need to clean after installing.
75
76EXTRA_CLEAN =
77
78# Some directories aren't cleaned recursively. Clean them manually...
79MANUAL_CLEAN_TOOLS = ./tools/dumpce
80MANUAL_CLEAN_EXTRA = ./extra/scrptrun ./samples/layout ./extra/ustdio ./extra
81MANUAL_CLEAN_TEST = ./test/collperf ./test/iotest ./test/letest ./test/thaitest ./test/threadtest ./test/testmap ./test
82MANUAL_CLEAN_SAMPLE = ./samples/layout ./samples
83
84CLEAN_SUBDIR = ./stubdata ./common ./i18n ./layout ./layoutex ./data ./tools ./$(MANUAL_CLEAN_TOOLS) $(MANUAL_CLEAN_EXTRA) $(MANUAL_CLEAN_TEST) $(MANUAL_CLEAN_SAMPLE)
85
86#################################
87# Config flags
88#################################
89
374ca955
A
90CONFIG_FLAGS = --disable-renaming --disable-extras --disable-ustdio --disable-layout \
91 --disable-samples --with-data-packaging=archive --prefix=/usr/local \
92 --srcdir=$(SRCROOT)/icuSources
b75a7d8f
A
93
94#################################
95# Install paths
96#################################
97
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.
104
374ca955
A
105LIB_NAME = icucore
106ICU_VERS = 32
b75a7d8f
A
107ICU_SUBVERS = 0
108CORE_VERS = A
109DYLIB_SUFF = dylib
110libdir = /usr/lib/
111
374ca955
A
112INSTALLED_DYLIB = lib$(LIB_NAME).$(CORE_VERS).$(DYLIB_SUFF)
113DYLIB = lib$(LIB_NAME).$(DYLIB_SUFF)
b75a7d8f
A
114
115#################################
116# Data files
117#################################
118
119datadir=/usr/share/icu/
374ca955
A
120OPEN_SOURCE_VERSIONS_DIR=/usr/local/OpenSourceVersions/
121OPEN_SOURCE_LICENSES_DIR=/usr/local/OpenSourceLicenses/
122ICU_DATA_DIR= data/out
b75a7d8f
A
123B_DATA_FILE=icudt$(ICU_VERS)b.dat
124L_DATA_FILE=icudt$(ICU_VERS)l.dat
125
374ca955
A
126#################################
127# Environment variables
128#################################
129
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).
135
136LIBOVERRIDES=LIBICUDT="-L$(OBJROOT) -l$(LIB_NAME)" \
137 LIBICUUC="-L$(OBJROOT) -l$(LIB_NAME)" \
138 LIBICUI18N="-L$(OBJROOT) -l$(LIB_NAME)"
139
140ENV= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
141 CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions" \
4648c0c3 142 CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions -fno-rtti -fvisibility-inlines-hidden" \
374ca955
A
143 RC_ARCHS="$(RC_ARCHS)" \
144 DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
145
146ENV_CONFIGURE= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
147 CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions" \
4648c0c3 148 CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions -fno-rtti -fvisibility-inlines-hidden" \
374ca955
A
149 RC_ARCHS="$(RC_ARCHS)" \
150 DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
151
152ENV_DEBUG = APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
153 CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions" \
4648c0c3 154 CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions -fno-rtti -fvisibility-inlines-hidden" \
374ca955
A
155 RC_ARCHS="$(RC_ARCHS)" \
156 DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
157
158ENV_icu = ENV
159ENV_debug = ENV_DEBUG
160
161ORDERFILE=/usr/local/lib/OrderFiles/libicucore.order
162ifeq "$(shell test -f $(ORDERFILE) && echo YES )" "YES"
163 SECTORDER_FLAGS=-sectorder __TEXT __text $(ORDERFILE)
164else
165 SECTORDER_FLAGS=
166endif
167
168
b75a7d8f
A
169#################################
170#################################
171# TARGETS
172#################################
173#################################
374ca955
A
174
175.PHONY : icu check installsrc installhdrs clean install debug debug-install
176.DELETE_ON_ERROR :
177
178icu debug : $(OBJROOT)/Makefile
179 (cd $(OBJROOT); \
180 $(MAKE) $($(ENV_$@)); \
4648c0c3
A
181 tmpfile=`mktemp -t weakexternal` || exit 1; \
182 nm -m $(COMMON_OBJ) $(I18N_OBJ) $(STUB_DATA_OBJ) | fgrep "weak external" | fgrep -v "undefined" | sed -e 's/.*weak external //' | uniq | cat >$$tmpfile; \
374ca955 183 $($(ENV_$@)) $(CXX) -current_version $(ICU_VERS).$(ICU_SUBVERS) -compatibility_version 1 -dynamiclib -dynamic \
4648c0c3 184 $(RC_ARCHS:%=-arch %) $(CXXFLAGS) $(LDFLAGS) -single_module $(SECTORDER_FLAGS) -unexported_symbols_list $$tmpfile \
374ca955
A
185 -install_name $(libdir)$(INSTALLED_DYLIB) -o ./$(INSTALLED_DYLIB) $(COMMON_OBJ) $(I18N_OBJ) $(STUB_DATA_OBJ); \
186 if test -f ./$(ICU_DATA_DIR)/$(B_DATA_FILE); then \
187 ln -fs ./$(ICU_DATA_DIR)/$(B_DATA_FILE); \
188 else \
189 DYLD_LIBRARY_PATH="./lib:./stubdata" \
190 ./bin/icuswap -tb ./$(ICU_DATA_DIR)/$(L_DATA_FILE) $(B_DATA_FILE); \
191 fi; \
192 if test -f ./$(ICU_DATA_DIR)/$(L_DATA_FILE); then \
193 ln -fs ./$(ICU_DATA_DIR)/$(L_DATA_FILE); \
194 else \
195 DYLD_LIBRARY_PATH="./lib:./stubdata" \
196 ./bin/icuswap -tl ./$(ICU_DATA_DIR)/$(B_DATA_FILE) $(L_DATA_FILE); \
197 fi; \
198 );
199
200check : icu
201 (cd $(OBJROOT); \
202 $(MAKE) $(ENV) check; \
203 );
204
205samples: icu
206 (cd $(OBJROOT)/samples; \
207 $(MAKE) $(ENV_DEBUG) $(LIBOVERRIDES); \
208 );
209
210extra: icu
211 (cd $(OBJROOT)/extra; \
212 $(MAKE) $(ENV_DEBUG) $(LIBOVERRIDES); \
213 );
214
215$(OBJROOT)/Makefile :
216 if test ! -d $(OBJROOT); then \
217 mkdir -p $(OBJROOT); \
218 fi;
219 (cd $(OBJROOT); $(ENV_CONFIGURE) $(SRCROOT)/icuSources/configure $(CONFIG_FLAGS);)
220
221debug-install: debug installhdrs
222 if test ! -d $(DSTROOT)$(libdir)/; then \
223 $(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
224 fi;
225 $(INSTALL) -b -m 0664 $(OBJROOT)/$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB)
226 (cd $(DSTROOT)$(libdir); \
227 ln -fs $(INSTALLED_DYLIB) $(DYLIB));
228 for subdir in $(EXTRA_LIBS); do \
229 (cd $(OBJROOT)/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV_DEBUG) install-library;) \
230 done;
231 if test ! -d $(DSTROOT)$(datadir)/; then \
232 $(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
233 fi;
234 if test -f $(OBJROOT)/$(B_DATA_FILE); then \
235 $(INSTALL) -b -m 0644 $(OBJROOT)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
236 fi;
237 if test -f $(OBJROOT)/$(L_DATA_FILE); then \
238 $(INSTALL) -b -m 0644 $(OBJROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
239 fi;
240 if test ! -d $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; then \
241 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; \
242 fi;
243 $(INSTALL) -b -m 0644 $(SRCROOT)/ICU.plist $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)ICU.plist;
244 if test ! -d $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; then \
245 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; \
246 fi;
247 $(INSTALL) -b -m 0644 $(SRCROOT)/license.html $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)ICU.html;
248
249#################################
250# B&I TARGETS
251#################################
252
b75a7d8f
A
253# Since our sources are in icuSources (ignore the ICU subdirectory for now), we wish to
254# copy them to somewhere else. We tar it to stdout, cd to the appropriate directory, and
255# untar from stdin. We then look for all the CVS directories and remove them. We may have
256# to remove the .cvsignore files also.
257
258installsrc :
259 if test ! -d $(SRCROOT); then mkdir $(SRCROOT); fi;
260 if test -d $(SRCROOT)/icuSources ; then rm -rf $(SRCROOT)/icuSources; fi;
374ca955 261 tar cf - ./makefile ./ICU.plist ./license.html ./icuSources | (cd $(SRCROOT) ; tar xfp -); \
b75a7d8f
A
262 for i in `find $(SRCROOT)/icuSources/ | grep "CVS$$"` ; do \
263 if test -d $$i ; then \
264 rm -rf $$i; \
265 fi; \
266 done
267 for j in `find $(SRCROOT)/icuSources/ | grep ".cvsignore"` ; do \
268 if test -f $$j ; then \
269 rm -f $$j; \
270 fi; \
271 done
272
273# This works. Just not for ~ in the DSTROOT. We run configure first (in case it hasn't
274# been already). Then we make the install-headers target on specific makefiles (since
275# not every subdirectory/sub-component has a install-headers target).
276
374ca955
A
277installhdrs : $(OBJROOT)/Makefile
278 (cd $(OBJROOT); \
b75a7d8f
A
279 for subdir in $(HDR_MAKE_SUBDIR); do \
280 (cd $$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-headers); \
374ca955
A
281 done;);
282
b75a7d8f
A
283# We run configure and run make first. This generates the .o files. We then link them
284# all up together into libicucore. Then we put it into its install location, create
285# symbolic links, and then strip the main dylib. Then install the remaining libraries.
286# We cleanup the sources folder.
287
374ca955 288install : installhdrs icu
b75a7d8f
A
289 if test ! -d $(DSTROOT)$(libdir)/; then \
290 $(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
374ca955
A
291 fi;
292 $(INSTALL) -b -m 0664 $(OBJROOT)/$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB)
293 (cd $(DSTROOT)$(libdir); \
294 ln -fs $(INSTALLED_DYLIB) $(DYLIB));
295 cp $(OBJROOT)/$(INSTALLED_DYLIB) $(SYMROOT)/$(INSTALLED_DYLIB);
296 strip -x -u -r -S $(DSTROOT)$(libdir)$(INSTALLED_DYLIB);
b75a7d8f 297 for subdir in $(EXTRA_LIBS); do \
374ca955 298 (cd $(OBJROOT)/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-library;) \
b75a7d8f
A
299 done;
300 if test ! -d $(DSTROOT)$(datadir)/; then \
301 $(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
302 fi;
374ca955
A
303 if test -f $(OBJROOT)/$(B_DATA_FILE); then \
304 $(INSTALL) -b -m 0644 $(OBJROOT)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
b75a7d8f 305 fi;
374ca955
A
306 if test -f $(OBJROOT)/$(L_DATA_FILE); then \
307 $(INSTALL) -b -m 0644 $(OBJROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
b75a7d8f 308 fi;
374ca955
A
309 if test ! -d $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; then \
310 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; \
b75a7d8f 311 fi;
374ca955
A
312 $(INSTALL) -b -m 0644 $(SRCROOT)/ICU.plist $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)ICU.plist;
313 if test ! -d $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; then \
314 $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; \
b75a7d8f 315 fi;
374ca955 316 $(INSTALL) -b -m 0644 $(SRCROOT)/license.html $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)ICU.html;
b75a7d8f 317
374ca955
A
318clean :
319 -rm -rf $(OBJROOT)