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