1## -*-makefile-*-
2## Aix-specific setup (for Visual Age 5+)
3## Copyright (c) 1999-2010, International Business Machines Corporation and
4## others. All Rights Reserved.
5
6## Commands to generate dependency files
7GEN_DEPS.c=	$(CC) -E -M $(DEFS) $(CPPFLAGS)
8GEN_DEPS.cc=	$(CXX) -E -M $(DEFS) $(CPPFLAGS)
9
10# -qroconst make the strings readonly, which is usually the default.
11#           This helps in the data library,
12# -qproto assumes all functions are prototyped (for optimization)
13# -qrtti turns on compiler RTTI, required beginning with ICU 4.6
14CFLAGS += -qproto -qroconst
15CXXFLAGS += -qproto -qroconst -qrtti
16
17# If you readd this line, you must change the SO value
18#LDFLAGS += -brtl
19
20ifeq ($(UCLN_NO_AUTO_CLEANUP),0)
21# set up init point.
22UCLN_FINI =  ucln_fini$(TARGET_STUBNAME)_$(SO_TARGET_VERSION_MAJOR)$(ICULIBSUFFIXCNAME)
23CPPFLAGS_FINI = -DUCLN_FINI=$(UCLN_FINI)
24LDFLAGS_FINI = -binitfini::$(UCLN_FINI)
25
26CPPFLAGSICUUC += $(CPPFLAGS_FINI)
27LDFLAGSICUUC += $(LDFLAGS_FINI)
28CPPFLAGSICUIO += $(CPPFLAGS_FINI)
29LDFLAGSICUIO += $(LDFLAGS_FINI)
30CPPFLAGSICUI18N += $(CPPFLAGS_FINI)
31LDFLAGSICUI18N += $(LDFLAGS_FINI)
32CPPFLAGSCTESTFW += $(CPPFLAGS_FINI)
33LDFLAGSCTESTFW += $(LDFLAGS_FINI)
34
35# ICUUC, ICUIO, ICUI18N, CTESTFW
36endif
37
38## We need to delete things prior to linking, or else we'll get
39## SEVERE ERROR: output file in use ..  on AIX. 
40## But, shell script version should NOT delete target as we don't
41## have $@ in that context.  (SH = only shell script, icu-config)
42AIX_PREDELETE=rm -f $@ ; 
43#SH# AIX_PREDELETE=
44
45## Commands to link
46## We need to use the C++ linker, even when linking C programs, since
47##  our libraries contain C++ code (C++ static init not called)
48LINK.c=		$(AIX_PREDELETE) $(CXX) $(CXXFLAGS) $(LDFLAGS)
49LINK.cc=	$(AIX_PREDELETE) $(CXX) $(CXXFLAGS) $(LDFLAGS)
50
51## Commands to make a shared library
52## -G means -berok -brtl -bnortllib -bnosymbolic -bnoautoexp
53## -bh:8 means halt on errors or worse.  We don't display warnings about
54##      duplicate inline symbols.
55SHLIB.c=	$(AIX_PREDELETE) $(CXX) -qmkshrobj -G $(LDFLAGS)
56SHLIB.cc=	$(AIX_PREDELETE) $(CXX) -qmkshrobj -G $(LDFLAGS)
57
58## Compiler switch to embed a runtime search path
59LD_RPATH=	-I
60LD_RPATH_PRE=	
61
62## Environment variable to set a runtime search path
63LDLIBRARYPATH_ENVVAR = LIBPATH
64
65# The following is for Makefile.inc's use.
66ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
67
68# this one is for icudefs.mk's use
69ifeq ($(ENABLE_SHARED),YES)
70SO_TARGET_VERSION_SUFFIX = $(SO_TARGET_VERSION_MAJOR)
71endif
72
73LD_SONAME = 
74
75## The type of assembly needed when pkgdata is used for generating shared libraries.
76GENCCODE_ASSEMBLY=-a xlc
77
78## Shared object suffix
79SOBJ=	so
80# without the -brtl option, the library names use .a. AIX is funny that way.
81SO=	a
82## Non-shared intermediate object suffix
83STATIC_O = o
84
85## Override Versioned target for a shared library.
86FINAL_SO_TARGET=  $(basename $(SO_TARGET))$(SO_TARGET_VERSION).$(SO)
87MIDDLE_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
88SHARED_OBJECT = $(notdir $(FINAL_SO_TARGET:.$(SO)=.$(SOBJ)))
89SHARED_OBJECT_NO_VERSION=  $(basename $(SO_TARGET)).$(SOBJ)
90
91## Build archive from shared object
92%.a : %.so
93	ln -f $< $(SHARED_OBJECT_NO_VERSION) 
94	$(AIX_PREDELETE) $(AR) $(ARFLAGS) $@ $(SHARED_OBJECT_NO_VERSION)
95	rm -f $(SHARED_OBJECT_NO_VERSION)
96$(LIBDIR)/%.a : %.so
97	ln -f $< $(SHARED_OBJECT_NO_VERSION) 
98	$(AIX_PREDELETE) $(AR) $(ARFLAGS) $@ $(SHARED_OBJECT_NO_VERSION)
99	rm -f $(SHARED_OBJECT_NO_VERSION)
100
101## Build import list from export list
102%.e : %.exp
103	@echo "Building an import list for $<"
104	@$(SHELL) -ec "echo '#! $*.a($*.so)' | cat - $< > $@"
105
106## Compilation rules
107%.$(STATIC_O): $(srcdir)/%.c
108	$(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $<
109%.o: $(srcdir)/%.c
110	$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $<
111
112%.$(STATIC_O): $(srcdir)/%.cpp
113	$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $<
114%.o: $(srcdir)/%.cpp
115	$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<
116
117
118## Dependency rules
119%.d : %.u
120	@$(SHELL) -ec 'cat $<  \
121		| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
122		[ -s $@ ] || rm -f $@ ; rm -f $<'
123
124%.u : $(srcdir)/%.c
125	@echo "generating dependency information for $<"
126	@$(GEN_DEPS.c) $< > /dev/null
127
128%.u : $(srcdir)/%.cpp
129	@echo "generating dependency information for $<"
130	@$(GEN_DEPS.cc) $< > /dev/null
131
132## Versioned libraries rules
133%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
134	$(RM) $@ && ln -s ${*F}$(SO_TARGET_VERSION).$(SO) $@
135%.$(SO): %$(SO_TARGET_VERSION).$(SO)
136	$(RM) $@ && ln -s ${*F}$(SO_TARGET_VERSION).$(SO) $@
137
138## End Aix-specific setup
139