1f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## -*-makefile-*-
2f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Copyright (c) 2003-2009 IBM, Ken Foskey, and others. All rights reserved.
3f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)##
4f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Aix-specific setup (for gcc)
5f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)##
6f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Please note: AIX does NOT have library versioning per se (there is no 'SONAME' capability). 
7f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## So, we are using 'windows' style library names, that is, libicuuc20.1.so instead of libicuuc.so.20.1
8f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
9f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)# Certain files don't compile in -ansi mode (e.g. umutex.c, toolutil.c, and cdatatst.c)
10f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)CFLAGS += -D_ALL_SOURCE
11f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
12f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Commands to generate dependency files
13f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)GEN_DEPS.c=	$(CC) -E -MM $(DEFS) $(CPPFLAGS)
14f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)GEN_DEPS.cc=	$(CXX) -E -MM $(DEFS) $(CPPFLAGS)
15f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
16f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Commands to link
17f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## We need to use the C++ linker, even when linking C programs, since
18f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)##  our libraries contain C++ code (C++ static init not called)
19f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LINK.c=		$(AIX_PREDELETE) $(CXX) $(CXXFLAGS) $(LDFLAGS) 
20f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LINK.cc=	$(AIX_PREDELETE) $(CXX) $(CXXFLAGS) $(LDFLAGS) 
21f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
22f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Shared library options
23f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LD_SOOPTIONS= -Wl,-bsymbolic
24f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
25f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Commands to make a shared library
26f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SHLIB.c=    $(AIX_PREDELETE) $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-bexpall $(LD_SOOPTIONS)
27f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SHLIB.cc=   $(AIX_PREDELETE) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -Wl,-bexpall $(LD_SOOPTIONS)
28f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
29f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Compiler switch to embed a runtime search path
30f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LD_RPATH=	-I
31f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LD_RPATH_PRE=	
32f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
33f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## enable the shared lib loader
34f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LDFLAGS += -Wl,-bbigtoc
35f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
36f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## These are the library specific LDFLAGS
37f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LDFLAGSICUDT=-nodefaultlibs -nostdlib
38f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
39f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## We need to delete things prior to linking, or else we'll get
40f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## SEVERE ERROR: output file in use ..  on AIX. 
41f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## But, shell script version should NOT delete target as we don't
42f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## have $@ in that context.  (SH = only shell script, icu-config)
43f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)AIX_PREDELETE=rm -f $@ ; 
44f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#SH# AIX_PREDELETE=
45f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
46f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Environment variable to set a runtime search path
47f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LDLIBRARYPATH_ENVVAR = LIBPATH
48f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
49f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Override Versioned target for a shared library.
50f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)FINAL_SO_TARGET=  $(basename $(SO_TARGET))$(SO_TARGET_VERSION).$(SO)
51f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)MIDDLE_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
52f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SHARED_OBJECT = $(notdir $(FINAL_SO_TARGET:.$(SO)=.$(SOBJ)))
53f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SHARED_OBJECT_NO_VERSION = $(basename $(SO_TARGET)).$(SOBJ)
54f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
55f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)# The following is for Makefile.inc's use.
56f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
57f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
58f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)# this one is for icudefs.mk's use
59f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)ifeq ($(ENABLE_SHARED),YES)
60f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SO_TARGET_VERSION_SUFFIX = $(SO_TARGET_VERSION_MAJOR)
61f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)endif
62f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
63f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Compiler switch to embed a library name. Not present on AIX.
64f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)LD_SONAME = 
65f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
66f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## The type of assembly needed when pkgdata is used for generating shared libraries.
67f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)GENCCODE_ASSEMBLY=-a xlc
68f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
69f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Shared object suffix
70f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SOBJ=   so
71f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)# without the -brtl option, the library names use .a. AIX is funny that way.
72f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)SO=	a
73f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)A=	a
74f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
75f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Non-shared intermediate object suffix
76f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)STATIC_O = o
77f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
78f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Special AIX rules
79f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
80f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Build archive from shared object
81f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.a : %.so
82f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	ln -f $< $(SHARED_OBJECT_NO_VERSION)
83f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(AR) $(ARFLAGS) $@ $(SHARED_OBJECT_NO_VERSION)
84f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	rm -f $(SHARED_OBJECT_NO_VERSION)
85f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)$(LIBDIR)/%.a : %.so
86f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	ln -f $< $(SHARED_OBJECT_NO_VERSION)
87f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(AR) $(ARFLAGS) $@ $(SHARED_OBJECT_NO_VERSION)
88f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	rm -f $(SHARED_OBJECT_NO_VERSION)
89f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
90f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Build import list from export list
91f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.e : %.exp
92f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	@echo "Building an import list for $<"
93f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	@$(SHELL) -ec "echo '#! $*.a($*.so)' | cat - $< > $@"
94f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
95f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Compilation rules
96f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.$(STATIC_O): $(srcdir)/%.c
97f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $<
98f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.o: $(srcdir)/%.c
99f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $<
100f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
101f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.$(STATIC_O): $(srcdir)/%.cpp
102f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $<
103f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.o: $(srcdir)/%.cpp
104f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<
105f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
106f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
107f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Dependency rules
108f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.d: $(srcdir)/%.c
109f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	@echo "generating dependency information for $<"
110f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	@$(SHELL) -ec '$(GEN_DEPS.c) $< \
111f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)		| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
112f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)		[ -s $@ ] || rm -f $@'
113f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
114f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.d: $(srcdir)/%.cpp
115f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	@echo "generating dependency information for $<"
116f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
117f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)		| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
118f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)		[ -s $@ ] || rm -f $@'
119f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
120f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## Versioned libraries rules
121f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
122f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(RM) $@ && ln -s ${*F}$(SO_TARGET_VERSION).$(SO) $@
123f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)%.$(SO): %$(SO_TARGET_VERSION).$(SO)
124f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)	$(RM) $@ && ln -s ${*F}$(SO_TARGET_VERSION).$(SO) $@
125f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
126f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
127f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)## BIR  - bind with internal references [so app data and icu data doesn't collide]
128f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)# LDflags that pkgdata will use
129f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)BIR_LDFLAGS= -Wl,-bE:$(NAME).map,-bnoexpall
130f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
131f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)# Dependencies [i.e. map files] for the final library
132f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)BIR_DEPS= $(NAME).map
133f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
134