SHELL := /bin/sh
# Sane defaults, which are typically overridden on the command line.
-SRCROOT=/tmp
-OBJROOT=$(SRCROOT)
+SRCROOT=$(shell pwd)
+OBJROOT=$(SRCROOT)/build
+DSTROOT=$(OBJROOT)
SYMROOT=$(OBJROOT)
-DSTROOT=/tmp/build
APPLE_INTERNAL_DIR=/AppleInternal
RC_ARCHS=
-#################################
-# Environment variables
-#################################
-
-# $(RC_ARCHS:%=-arch %) is a substitution reference. It denotes, in this case,
-# for every value <val> in RC_ARCHS, replace it with "-arch <val>". Substitution
-# references have the form $(var:a=b). We can insert the strip and prebinding commands
-# into CFLAGS (and CXXFLAGS). This controls a lot of the external variables so we don't
-# need to directly modify the ICU files (like for CFLAGS, etc).
-
-ENV= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
- CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions" \
- CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions" \
- RC_ARCHS="$(RC_ARCHS)" \
- DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
-
-ENV_CONFIGURE= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
- CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions" \
- CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions" \
- RC_ARCHS="$(RC_ARCHS)" \
- DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
-
-ENV_DEBUG = APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
- CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions" \
- CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions" \
- RC_ARCHS="$(RC_ARCHS)" \
- DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
+# Disallow $(SRCROOT) == $(OBJROOT)
+ifeq ($(OBJROOT), $(SRCROOT))
+$(error SRCROOT same as OBJROOT)
+endif
#################################
# Headers
COMMON_OBJ = ./common/*.o
I18N_OBJ = ./i18n/*.o
STUB_DATA_OBJ = ./stubdata/*.o
+COMMON_SRC = $(OBJROOT)/common/*.c
+I18N_SRC = $(OBJROOT)/i18n/*.c
+STUB_DATA_SRC = $(OBJROOT)/stubdata/*.c
EXTRA_LIBS =
#EXTRA_LIBS =./extra/ ./layout/ ./tools/ctestfw/ ./tools/toolutil/
#DATA_OBJ = ./data/out/build/*.o
# Config flags
#################################
-CONFIG_FLAGS = --disable-renaming --disable-extras --disable-ustdio --disable-layout --disable-tests --disable-samples --with-data-packaging=archive --prefix=/usr/local
+CONFIG_FLAGS = --disable-renaming --disable-extras --disable-ustdio --disable-layout \
+ --disable-samples --with-data-packaging=archive --prefix=/usr/local \
+ --srcdir=$(SRCROOT)/icuSources
#################################
# Install paths
# version changes it's API...that is a new version isn't backwards compatible.
# The ICU version/subversion should reflect the actual ICU version.
-LIB_NAME = libicucore
-ICU_VERS = 26
+LIB_NAME = icucore
+ICU_VERS = 32
ICU_SUBVERS = 0
CORE_VERS = A
DYLIB_SUFF = dylib
libdir = /usr/lib/
-INSTALLED_DYLIB = $(LIB_NAME).$(CORE_VERS).$(DYLIB_SUFF)
-DYLIB = $(LIB_NAME).$(DYLIB_SUFF)
+INSTALLED_DYLIB = lib$(LIB_NAME).$(CORE_VERS).$(DYLIB_SUFF)
+DYLIB = lib$(LIB_NAME).$(DYLIB_SUFF)
#################################
# Data files
#################################
datadir=/usr/share/icu/
-ICU_DATA_DIR= /data/out/
+OPEN_SOURCE_VERSIONS_DIR=/usr/local/OpenSourceVersions/
+OPEN_SOURCE_LICENSES_DIR=/usr/local/OpenSourceLicenses/
+ICU_DATA_DIR= data/out
B_DATA_FILE=icudt$(ICU_VERS)b.dat
L_DATA_FILE=icudt$(ICU_VERS)l.dat
+#################################
+# Environment variables
+#################################
+
+# $(RC_ARCHS:%=-arch %) is a substitution reference. It denotes, in this case,
+# for every value <val> in RC_ARCHS, replace it with "-arch <val>". Substitution
+# references have the form $(var:a=b). We can insert the strip and prebinding commands
+# into CFLAGS (and CXXFLAGS). This controls a lot of the external variables so we don't
+# need to directly modify the ICU files (like for CFLAGS, etc).
+
+LIBOVERRIDES=LIBICUDT="-L$(OBJROOT) -l$(LIB_NAME)" \
+ LIBICUUC="-L$(OBJROOT) -l$(LIB_NAME)" \
+ LIBICUI18N="-L$(OBJROOT) -l$(LIB_NAME)"
+
+ENV= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
+ CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions" \
+ CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -g -Os -fno-exceptions -fno-rtti" \
+ RC_ARCHS="$(RC_ARCHS)" \
+ DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
+
+ENV_CONFIGURE= APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
+ CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions" \
+ CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" -g -Os -fno-exceptions -fno-rtti" \
+ RC_ARCHS="$(RC_ARCHS)" \
+ DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
+
+ENV_DEBUG = APPLE_INTERNAL_DIR="$(APPLE_INTERNAL_DIR)" \
+ CFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions" \
+ CXXFLAGS="-DICU_DATA_DIR=\"\\\"/usr/share/icu/\\\"\" $(RC_ARCHS:%=-arch %) -O0 -g -fno-exceptions -fno-rtti" \
+ RC_ARCHS="$(RC_ARCHS)" \
+ DYLD_LIBRARY_PATH="$(DSTROOT)/usr/local/lib"
+
+ENV_icu = ENV
+ENV_debug = ENV_DEBUG
+
+ORDERFILE=/usr/local/lib/OrderFiles/libicucore.order
+ifeq "$(shell test -f $(ORDERFILE) && echo YES )" "YES"
+ SECTORDER_FLAGS=-sectorder __TEXT __text $(ORDERFILE)
+else
+ SECTORDER_FLAGS=
+endif
+
+
#################################
#################################
# TARGETS
#################################
#################################
+
+.PHONY : icu check installsrc installhdrs clean install debug debug-install
+.DELETE_ON_ERROR :
+
+icu debug : $(OBJROOT)/Makefile
+ (cd $(OBJROOT); \
+ $(MAKE) $($(ENV_$@)); \
+ $($(ENV_$@)) $(CXX) -current_version $(ICU_VERS).$(ICU_SUBVERS) -compatibility_version 1 -dynamiclib -dynamic \
+ $(RC_ARCHS:%=-arch %) $(CXXFLAGS) $(LDFLAGS) -single_module $(SECTORDER_FLAGS) \
+ -install_name $(libdir)$(INSTALLED_DYLIB) -o ./$(INSTALLED_DYLIB) $(COMMON_OBJ) $(I18N_OBJ) $(STUB_DATA_OBJ); \
+ if test -f ./$(ICU_DATA_DIR)/$(B_DATA_FILE); then \
+ ln -fs ./$(ICU_DATA_DIR)/$(B_DATA_FILE); \
+ else \
+ DYLD_LIBRARY_PATH="./lib:./stubdata" \
+ ./bin/icuswap -tb ./$(ICU_DATA_DIR)/$(L_DATA_FILE) $(B_DATA_FILE); \
+ fi; \
+ if test -f ./$(ICU_DATA_DIR)/$(L_DATA_FILE); then \
+ ln -fs ./$(ICU_DATA_DIR)/$(L_DATA_FILE); \
+ else \
+ DYLD_LIBRARY_PATH="./lib:./stubdata" \
+ ./bin/icuswap -tl ./$(ICU_DATA_DIR)/$(B_DATA_FILE) $(L_DATA_FILE); \
+ fi; \
+ );
+
+check : icu
+ (cd $(OBJROOT); \
+ $(MAKE) $(ENV) check; \
+ );
+
+samples: icu
+ (cd $(OBJROOT)/samples; \
+ $(MAKE) $(ENV_DEBUG) $(LIBOVERRIDES); \
+ );
+
+extra: icu
+ (cd $(OBJROOT)/extra; \
+ $(MAKE) $(ENV_DEBUG) $(LIBOVERRIDES); \
+ );
+
+$(OBJROOT)/Makefile :
+ if test ! -d $(OBJROOT); then \
+ mkdir -p $(OBJROOT); \
+ fi;
+ (cd $(OBJROOT); $(ENV_CONFIGURE) $(SRCROOT)/icuSources/configure $(CONFIG_FLAGS);)
+
+debug-install: debug installhdrs
+ if test ! -d $(DSTROOT)$(libdir)/; then \
+ $(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
+ fi;
+ $(INSTALL) -b -m 0664 $(OBJROOT)/$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB)
+ (cd $(DSTROOT)$(libdir); \
+ ln -fs $(INSTALLED_DYLIB) $(DYLIB));
+ for subdir in $(EXTRA_LIBS); do \
+ (cd $(OBJROOT)/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV_DEBUG) install-library;) \
+ done;
+ if test ! -d $(DSTROOT)$(datadir)/; then \
+ $(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
+ fi;
+ if test -f $(OBJROOT)/$(B_DATA_FILE); then \
+ $(INSTALL) -b -m 0644 $(OBJROOT)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
+ fi;
+ if test -f $(OBJROOT)/$(L_DATA_FILE); then \
+ $(INSTALL) -b -m 0644 $(OBJROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
+ fi;
+ if test ! -d $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; then \
+ $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; \
+ fi;
+ $(INSTALL) -b -m 0644 $(SRCROOT)/ICU.plist $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)ICU.plist;
+ if test ! -d $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; then \
+ $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; \
+ fi;
+ $(INSTALL) -b -m 0644 $(SRCROOT)/license.html $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)ICU.html;
+
+#################################
+# B&I TARGETS
+#################################
+
# Since our sources are in icuSources (ignore the ICU subdirectory for now), we wish to
# copy them to somewhere else. We tar it to stdout, cd to the appropriate directory, and
# untar from stdin. We then look for all the CVS directories and remove them. We may have
installsrc :
if test ! -d $(SRCROOT); then mkdir $(SRCROOT); fi;
if test -d $(SRCROOT)/icuSources ; then rm -rf $(SRCROOT)/icuSources; fi;
- tar cf - ./makefile ./icuSources ./$(L_DATA_FILE) | (cd $(SRCROOT) ; tar xfp -); \
+ tar cf - ./makefile ./ICU.plist ./license.html ./icuSources | (cd $(SRCROOT) ; tar xfp -); \
for i in `find $(SRCROOT)/icuSources/ | grep "CVS$$"` ; do \
if test -d $$i ; then \
rm -rf $$i; \
# been already). Then we make the install-headers target on specific makefiles (since
# not every subdirectory/sub-component has a install-headers target).
-installhdrs : $(SRCROOT)/icuSources/Makefile
- $(SHELL) -ec \
- 'cd $(SRCROOT)/icuSources; \
+installhdrs : $(OBJROOT)/Makefile
+ (cd $(OBJROOT); \
for subdir in $(HDR_MAKE_SUBDIR); do \
(cd $$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-headers); \
- done;'
-
+ done;);
+
# We run configure and run make first. This generates the .o files. We then link them
# all up together into libicucore. Then we put it into its install location, create
# symbolic links, and then strip the main dylib. Then install the remaining libraries.
# We cleanup the sources folder.
-install : installhdrs $(SRCROOT)/icuSources/Makefile
- $(SHELL) -ec \
- 'cd $(SRCROOT)/icuSources; \
- $(MAKE) $(ENV); \
- $(ENV) $(CXX) -current_version $(ICU_VERS).$(ICU_SUBVERS) -compatibility_version 1 -dynamiclib -dynamic $(RC_ARCHS:%=-arch %) $(CXXFLAGS) $(LDFLAGS) -single_module -sectorder __TEXT __text /usr/local/lib/OrderFiles/libicucore.order -install_name $(libdir)$(INSTALLED_DYLIB) -o ./$(INSTALLED_DYLIB) $(COMMON_OBJ) $(I18N_OBJ) $(STUB_DATA_OBJ); \
+install : installhdrs icu
if test ! -d $(DSTROOT)$(libdir)/; then \
$(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
- fi; \
- $(INSTALL) -b -m 0664 ./$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB); \
- cd $(DSTROOT)$(libdir); \
- ln -fs $(INSTALLED_DYLIB) $(DYLIB); \
- cp $(INSTALLED_DYLIB) $(SYMROOT)/$(INSTALLED_DYLIB); \
- strip -x -u -r -S $(DSTROOT)$(libdir)$(INSTALLED_DYLIB);'
+ fi;
+ $(INSTALL) -b -m 0664 $(OBJROOT)/$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB)
+ (cd $(DSTROOT)$(libdir); \
+ ln -fs $(INSTALLED_DYLIB) $(DYLIB));
+ cp $(OBJROOT)/$(INSTALLED_DYLIB) $(SYMROOT)/$(INSTALLED_DYLIB);
+ strip -x -u -r -S $(DSTROOT)$(libdir)$(INSTALLED_DYLIB);
for subdir in $(EXTRA_LIBS); do \
- (cd $(SRCROOT)/icuSources/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-library;) \
+ (cd $(OBJROOT)/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) install-library;) \
done;
if test ! -d $(DSTROOT)$(datadir)/; then \
$(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
fi;
- if test -f $(SRCROOT)/icuSources/$(ICU_DATA_DIR)/$(B_DATA_FILE); then \
- $(INSTALL) -b -m 0644 $(SRCROOT)/icuSources/$(ICU_DATA_DIR)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
+ if test -f $(OBJROOT)/$(B_DATA_FILE); then \
+ $(INSTALL) -b -m 0644 $(OBJROOT)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
fi;
- if test -f $(SRCROOT)/$(L_DATA_FILE); then \
- $(INSTALL) -b -m 0644 $(SRCROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
+ if test -f $(OBJROOT)/$(L_DATA_FILE); then \
+ $(INSTALL) -b -m 0644 $(OBJROOT)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
fi;
- for i in $(CLEAN_SUBDIR) ; do \
- if test -e $(SRCROOT/icuSources/$$i); then \
- (cd $(SRCROOT)/icuSources/$$i; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) distclean); \
- fi; \
- done; \
- (cd $(SRCROOT)/icuSources; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) distclean-local;)
- if test -f $(SRCROOT)/icuSources/config/icu-config; then \
- rm -rf $(SRCROOT)/icuSources/config/icu-config; \
- fi;
- if test -f $(SRCROOT)/icuSources/$(INSTALLED_DYLIB); then \
- rm -rf $(SRCROOT)/icuSources/$(INSTALLED_DYLIB); \
- fi;
-
-clean :
- if test -d $(SRCROOT)/icuSources; then \
- if test -e $(SRCROOT)/icuSources/Makefile; then \
- for i in $(CLEAN_SUBDIR) ; do \
- if test -e $(SRCROOT/icuSources/$$i); then \
- (cd $(SRCROOT)/icuSources/$$i; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) distclean); \
- fi; \
- done; \
- (cd $(SRCROOT)/icuSources; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) distclean-local;) \
- fi; \
+ if test ! -d $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; then \
+ $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)/; \
fi;
- if test -f $(SRCROOT)/icuSources/config/icu-config; then \
- rm -rf $(SRCROOT)/icuSources/config/icu-config; \
+ $(INSTALL) -b -m 0644 $(SRCROOT)/ICU.plist $(DSTROOT)$(OPEN_SOURCE_VERSIONS_DIR)ICU.plist;
+ if test ! -d $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; then \
+ $(INSTALL) -d -m 0755 $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)/; \
fi;
- if test -f $(SRCROOT)/icuSources/$(INSTALLED_DYLIB); then \
- rm -rf $(SRCROOT)/icuSources/$(INSTALLED_DYLIB); \
- fi;
-
-$(SRCROOT)/icuSources/Makefile :
- $(SHELL) -ec \
- 'cd $(SRCROOT)/icuSources; \
- $(ENV_CONFIGURE) ./configure $(CONFIG_FLAGS);'
-
-#################################
-# OPTIONAL TARGETS
-#################################
-
-# These targets aren't required by B&I. They're supposed to make life easier by not deleting
-# the object files so that we don't have to rebuild the entire binary every single time. This
-# should aid in development.
+ $(INSTALL) -b -m 0644 $(SRCROOT)/license.html $(DSTROOT)$(OPEN_SOURCE_LICENSES_DIR)ICU.html;
-debug: installhdrs $(SRCROOT)/icuSources/Makefile
- $(SHELL) -ec \
- 'cd $(SRCROOT)/icuSources; \
- $(MAKE) $(ENV_DEBUG); \
- $(ENV_DEBUG) $(CXX) -current_version $(ICU_VERS).$(ICU_SUBVERS) -compatibility_version 1 -dynamiclib -dynamic $(RC_ARCHS:%=-arch %) $(CXXFLAGS) $(LDFLAGS) -install_name $(libdir)$(INSTALLED_DYLIB) -o ./$(INSTALLED_DYLIB) $(COMMON_OBJ) $(I18N_OBJ) $(STUB_DATA_OBJ); \
- if test ! -d $(DSTROOT)$(libdir)/; then \
- $(INSTALL) -d -m 0775 $(DSTROOT)$(libdir)/; \
- fi; \
- $(INSTALL) -b -m 0664 ./$(INSTALLED_DYLIB) $(DSTROOT)$(libdir)$(INSTALLED_DYLIB); \
- cd $(DSTROOT)$(libdir); \
- ln -fs $(INSTALLED_DYLIB) $(DYLIB);'
-
-debug-install: debug installhdrs $(SRCROOT)/icuSources/Makefile
- for subdir in $(EXTRA_LIBS); do \
- (cd $(SRCROOT)/icuSources/$$subdir; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV_DEBUG) install-library;) \
- done;
- if test ! -d $(DSTROOT)$(datadir)/; then \
- $(INSTALL) -d -m 0755 $(DSTROOT)$(datadir)/; \
- fi;
- if test -f $(SRCROOT)/icuSources/$(ICU_DATA_DIR)/$(B_DATA_FILE); then \
- $(INSTALL) -b -m 0644 $(SRCROOT)/icuSources/$(ICU_DATA_DIR)/$(B_DATA_FILE) $(DSTROOT)$(datadir)$(B_DATA_FILE); \
- else \
- $(INSTALL) -b -m 0644 $(SRCROOT)/icuSources/$(ICU_DATA_DIR)/$(L_DATA_FILE) $(DSTROOT)$(datadir)$(L_DATA_FILE); \
- fi;
- (cd $(SRCROOT)/icuSources; $(MAKE) -e DESTDIR=$(DSTROOT) $(ENV) distclean-local;)
- if test -f $(SRCROOT)/icuSources/config/icu-config; then \
- rm -rf $(SRCROOT)/icuSources/config/icu-config; \
- fi;
- if test -f $(SRCROOT)/icuSources/$(INSTALLED_DYLIB); then \
- rm -rf $(SRCROOT)/icuSources/$(INSTALLED_DYLIB); \
- fi;
+clean :
+ -rm -rf $(OBJROOT)