1XCOMM $Xorg: ibmLib.rules,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
2XCOMM $XdotOrg: xc/config/cf/ibmLib.rules,v 1.1.4.3 2003/12/15 16:42:40 kaleb Exp $
3
4/*
5 * AIX shared library rules
6 */
7
8XCOMM $XFree86: xc/config/cf/ibmLib.rules,v 3.5 2000/02/13 06:15:18 dawes Exp $
9#ifndef HasSharedLibraries
10# define HasSharedLibraries YES
11#endif
12#ifndef ForceNormalLib
13# define ForceNormalLib NO
14#endif
15#ifndef SharedDataSeparation
16# define SharedDataSeparation NO
17#endif
18#ifndef SharedCodeDef
19# define SharedCodeDef -DSHAREDCODE
20#endif
21#if OSMajorVersion < 5
22# ifndef SharedLibraryDef
23#  define SharedLibraryDef -DAIXSHLIB
24# endif
25#else
26# define SharedLibraryDef /**/
27#endif
28#ifndef ShLibIncludeFile
29# define ShLibIncludeFile <ibmLib.tmpl>
30#endif
31#ifndef PositionIndependentCFlags
32# define PositionIndependentCFlags -bM\:SRE
33#endif
34#ifndef ExtraLoadFlags
35# define ExtraLoadFlags -bnodelcsect
36#endif
37#if !defined(LdPostLib) && !defined(UseInstalled) && OSMajorVersion > 3
38# if ThreadedX
39#  define LdPostLib -bnoipath -blibpath:$(USRLIBDIRPATH):/usr/lib/threads:/usr/lib:/lib
40# else
41#  define LdPostLib -bnoipath -blibpath:$(USRLIBDIRPATH):/usr/lib:/lib
42# endif
43# define SharedLibPostRef $(LDPOSTLIBS)
44#endif
45#ifndef SharedLibPostRef
46# define SharedLibPostRef $(LDPOSTLIBS)
47#endif
48#if ThreadedX
49# define BaseShLibReqs -lc_r -lm
50#else
51# define BaseShLibReqs -lc -lm
52#endif
53#ifndef UseExportLists
54# define UseExportLists YES
55#endif
56
57/*
58 * MakeExportList - generate an export list file for linking libraries.
59 */
60#ifndef MakeExportList
61# if UseExportLists
62#  define MakeExportList(libname,result) \
63	@-RemoveFile(result)						@@\
64	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
65		echo "#! $@ ($${shr4obj:-shr.o})" > result		@@\
66	if [ -f Concat(lib,libname.elist) ]; then \			@@\
67	    $(CPP) $(ALLINCLUDES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES) Concat(lib,libname.elist) | CppSedMagic > $@.list; \	@@\
68	    $(EXPORTLISTGEN) $@~ $@.list >> result; \			@@\
69	    RemoveFile($@.list); \					@@\
70	else \								@@\
71	    dump -g $@~ | sed -n -e 's/^[ 	]*[0-9][0-9]*[	 ]*\([^	 .][^	 ]*\)$$/\1/p' >> result; \	@@\
72	fi;
73# else
74#  define MakeExportList(libname,result) \
75	@-RemoveFile(result)						@@\
76	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
77		echo "#! $@ ($${shr4obj:-shr.o})" > result		@@\
78	dump -g $@~ | sed -n -e 's/^[ 	]*[0-9][0-9]*[	 ]*\([^	 .][^	 ]*\)$$/\1/p' >> result;
79# endif
80#endif /* MakeExportList */
81
82
83#if !defined(UseInstalled) && !defined(UseInstalledX11) \
84    && !defined(UseImports) && !defined(ImportX11)
85   /* we want this to be defined only when building X */
86
87# if OSMajorVersion < 5
88#  if OSMajorVersion < 4
89/*
90 * SharedLibReferences - variables for shared libraries
91 */
92
93#   ifndef SharedLibReferences
94#    define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
95Concat3(DEP,varname,LIB) = /**/						@@\
96Concat(varname,LIB) = _Use(Concat(-l,libname),Concat(libsource/lib,libname.a)) @@\
97LintLibReferences(varname,libname,libsource)
98#   endif
99
100#  else /* OSMajorVersion < 4 */
101
102#   ifndef SharedLibReferences
103#    define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
104Concat3(DEP,varname,LIB) = /**/						@@\
105Concat(varname,LIB) = _Use(Concat(-l,libname),Concat($(BUILDLIBDIR),/libname.imp) Concat3($(BUILDLIBDIR),/lib,libname.a)) @@\
106LintLibReferences(varname,libname,libsource)
107#   endif
108
109#  endif
110# else /* OSMajorVersion < 5 */
111
112#  ifndef SharedLibReferences
113#   define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
114Concat3(DEP,varname,LIB) = /**/						@@\
115Concat(varname,LIB) = _Use(Concat(-l,libname), Concat3($(BUILDLIBDIR),/lib,libname.so)) @@\
116LintLibReferences(varname,libname,libsource)
117#  endif
118
119# endif
120
121# if OSMajorVersion < 5
122#  if OSMajorVersion < 4
123/*
124 * SharedFontLibReferences - shared font libraries
125 */
126
127#   ifndef SharedFontLibReferences
128#    define SharedFontLibReferences()					@@\
129DEPFONTLIB = /**/							@@\
130FONTLIB = -L$(FREETYPELIBDIR) _Use(-lXfont,$(FONTLIBSRC)/libXfont.a)	@@\
131LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
132#   endif
133#  else
134#   ifndef SharedFontLibReferences
135#    define SharedFontLibReferences()					@@\
136DEPFONTLIB = /**/							@@\
137FONTLIB = -L$(FREETYPELIBDIR) _Use(-lXfont,$(BUILDLIBDIR)/font.imp) $(BUILDLIBDI)/libXfont.a)) @@\
138LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
139#   endif
140#  endif
141# else /* OSMajorVersion < 5 */
142#  ifndef SharedFontLibReferences
143#   define SharedFontLibReferences()					@@\
144DEPFONTLIB = /**/							@@\
145FONTLIB = -L$(FREETYPELIBDIR) _Use(-lXfont,$(BUILDLIBDI)/libXfont.so)) @@\
146LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
147#  endif
148
149# endif
150
151/*
152 * SharedDSLibReferences - variables for shared libraries
153 */
154# ifndef SharedDSLibReferences
155#  define SharedDSLibReferences(varname,libname,libsource,revname,rev)	@@\
156SharedLibReferences(varname,libname,libsource,revname,rev)
157# endif
158
159# if OSMajorVersion == 4
160/*
161 * UnsharedLibReferences - variables for unshared libraries
162 */
163#  ifndef UnsharedLibReferences
164#   define UnsharedLibReferences(varname,libname,libsource)		@@\
165Concat3(DEP,varname,LIB) = _UseCat($(USRLIBDIR)/lib,$(BUILDLIBDIR)/lib,libname.a)	@@\
166Concat(varname,LIB) = _Use(Concat(-l,libname),Concat($(BUILDLIBDIR)/lib,libname.a))	@@\
167LintLibReferences(varname,libname,libsource)
168#  endif
169# endif
170
171#endif /* !defined(UseInstalled) && !defined(UseInstalledX11) ... */
172
173
174/*
175 * InstallSharedLibrary - generate rules to install the shared library.
176 */
177#ifndef InstallSharedLibrary
178# if OSMajorVersion < 5
179#  define InstallSharedLibrary(libname,rev,dest)			@@\
180InstallLibrary(libname,dest)
181# else /* OSMajorVersion < 5 */
182#  define InstallSharedLibrary(libname,rev,dest)			@@\
183install:: Concat(lib,libname.so)					@@\
184	MakeDir($(DESTDIR)dest)						@@\
185	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.so) $(DESTDIR)dest
186# endif /* OSMajorVersion < 5 */
187#endif /* InstallSharedLibrary */
188
189/*
190 * InstallSharedLibraryData - generate rules to install the shared library data
191 */
192#ifndef InstallSharedLibraryData
193# define InstallSharedLibraryData(libname,rev,dest)
194#endif /* InstallSharedLibraryData */
195
196/*
197 * SharedLibraryTarget - generate rules to create a shared library;
198 * build it into a different name so that the we do not hose people by having
199 * the library gone for long periods.
200 *
201 * IBM uses an unusual shared object file name (shr4.o) in some libraries.
202 * Duplicate this behavior to preserve compatibility with IBM's libraries.
203 */
204#if OSMajorVersion < 5
205# if OSMajorVersion < 4
206
207#  ifndef SharedLibraryTarget
208#   define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
209AllTarget(Concat(lib,libname.a))					@@\
210									@@\
211Concat(lib,libname.a):  solist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
212	$(RM) $@~ shr.o shr4.o						@@\
213	(cd down; $(AR) up/$@~ solist)					@@\
214	dump -g $@~ | sed -n -e 's/^[ 	]*[0-9][0-9]*[	 ]*\([^	 .][^	 ]*\)$$/\1/p' > $@.syms	@@\
215	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:$@.syms $(REQUIREDLIBS) BaseShLibReqs SharedLibPostRef	@@\
216	$(LN) shr.o shr4.o						@@\
217	$(RM) $@~							@@\
218	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
219		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
220	$(RM) $@.syms $@ shr.o shr4.o					@@\
221	$(MV) $@~ $@							@@\
222	LinkBuildLibrary($@)						@@\
223									@@\
224clean::									@@\
225	$(RM) Concat(lib,libname.a)
226#  endif /* SharedLibraryTarget */
227
228# else /* OSMajorVersion < 4 */
229
230#  ifndef SharedLibraryTarget
231#   define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
232AllTarget(Concat(lib,libname.a))					@@\
233									@@\
234Concat(lib,libname.a):  solist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
235	RemoveFiles($@~ shr.o shr4.o)					@@\
236	(cd down; $(AR) up/$@~ solist)					@@\
237	MakeExportList(libname,libname.imp)				@@\
238	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:libname.imp -bnoentry $(REQUIREDLIBS) BaseShLibReqs $(LDPOSTLIBS)	@@\
239	$(LN) shr.o shr4.o						@@\
240	RemoveFile($@~)							@@\
241	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
242		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
243	RemoveFile($@)							@@\
244	$(MV) $@~ $@							@@\
245	LinkBuildLibrary($@)						@@\
246	LinkBuildLibrary(libname.imp)					@@\
247									@@\
248clean::									@@\
249	$(RM) Concat(lib,libname.a)
250#  endif /* SharedLibraryTarget */
251# endif /* OSMajorVersion < 4 */
252#else /* OSMajorVersion < 5 */
253# ifndef SharedLibraryTarget
254#  define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
255AllTarget(Concat(lib,libname.so))					@@\
256									@@\
257Concat(lib,libname.so): solist $(EXTRALIBRARYDEPS)			@@\
258	$(RM) $@~							@@\
259	$(AR) $*.a solist						@@\
260	dump -g $*.a | sed -n -e 's/^[  ]*[0-9][0-9]*[[:space:]]*\([_[:alpha:]][[:alnum:]]*\)/\1/p' | egrep -v \\\. | sort | uniq > $*.syms	@@\
261	$(LD) -bnoipath -bnoentry -bM\:SRE -bE\:$*.syms -o $@~ solist $(REQUIREDLIBS) BaseShLibReqs -lc	@@\
262	$(RM) $@ $*.a $*.syms						@@\
263	$(MV) $@~ $@							@@\
264	LinkBuildLibrary($@)						@@\
265									@@\
266clean::									@@\
267	$(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so)
268
269# endif /* SharedLibraryTarget */
270#endif /* OSMajorVersion < 5 */
271
272/*
273 * SharedDepLibraryTarget - generate rules to create a shared library.
274 */
275#if OSMajorVersion < 5
276# if OSMajorVersion < 4
277
278#  ifndef SharedDepLibraryTarget
279#   define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
280AllTarget(Concat(lib,libname.a))					@@\
281									@@\
282Concat(lib,libname.a):  deplist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
283	$(RM) $@~ shr.o shr4.o						@@\
284	(cd down; $(AR) up/$@~ solist)					@@\
285	dump -g $@~ | sed -n -e 's/^[   ]*[0-9][0-9]*[   ]*\([^  .][^    ]*\)$$/\1/p' > $@.syms	@@\
286	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:$@.syms $(REQUIREDLIBS) BaseShLibReqs SharedLibPostRef	@@\
287	$(LN) shr.o shr4.o						@@\
288	$(RM) $@~							@@\
289	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
290		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
291	$(RM) $@.syms $@ shr.o shr4.o					@@\
292	$(MV) $@~ $@							@@\
293	LinkBuildLibrary($@)						@@\
294									@@\
295clean::									@@\
296	$(RM) Concat(lib,libname.a)
297#  endif /* SharedDepLibraryTarget */
298
299# else /* OSMajorVersion < 4 */
300
301#  ifndef SharedDepLibraryTarget
302#   define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
303AllTarget(Concat(lib,libname.a))					@@\
304									@@\
305Concat(lib,libname.a):  deplist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
306	RemoveFiles($@~ shr.o shr4.o)					@@\
307	(cd down; $(AR) up/$@~ solist)					@@\
308	MakeExportList(libname,libname.imp)				@@\
309	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:libname.imp -bnoentry $(REQUIREDLIBS) BaseShLibReqs $(LDPOSTLIBS)	@@\
310	$(LN) shr.o shr4.o						@@\
311	RemoveFile($@~)							@@\
312	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
313		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
314	RemoveFile($@)							@@\
315	$(MV) $@~ $@							@@\
316	LinkBuildLibrary($@)						@@\
317	LinkBuildLibrary(libname.imp)					@@\
318									@@\
319clean::									@@\
320	$(RM) Concat(lib,libname.a)
321#  endif /* SharedDepLibraryTarget */
322
323# endif /* OSMajorVersion < 4 */
324#else /* OSMajorVersion < 5 */
325# ifndef SharedDepLibraryTarget
326#  define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
327AllTarget(Concat(lib,libname.so))					@@\
328									@@\
329Concat(lib,libname.so):  deplist $(EXTRALIBRARYDEPS)			@@\
330	$(RM) $@~							@@\
331	$(AR) $*.a solist						@@\
332	dump -g $*.a | sed -n -e 's/^[  ]*[0-9][0-9]*[[:space:]]*\([_[:alpha:]][[:alnum:]]*\)/\1/p' | egrep -v \\\. | sort | uniq > $*.syms	@@\
333	$(LD) -bnoipath -bnoentry -bsymbolic -bM\:SRE -bE\:$*.syms -o $@~ solist $(REQUIREDLIBS) BaseShLibReqs -lc	@@\
334	$(RM) $@ $*.a $*.syms						@@\
335	$(MV) $@~ $@							@@\
336	LinkBuildLibrary($@)						@@\
337									@@\
338clean::									@@\
339	$(RM) Concat(lib,libname.so) Concat(lib,libname.so)
340
341# endif /* SharedDepLibraryTarget */
342#endif /* OSMajorVersion < 5 */
343
344/*
345 * SharedLibraryDataTarget - generate rules to create shlib data file;
346 */
347#ifndef SharedLibraryDataTarget
348# define SharedLibraryDataTarget(libname,rev,salist)
349#endif /* SharedLibraryTarget */
350