bsdLib.rules revision 11d341ca
1XCOMM $Xorg: bsdLib.rules,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
2
3
4
5
6
7XCOMM $XFree86: xc/config/cf/bsdLib.rules,v 3.27 2003/11/20 00:41:37 dawes Exp $
8/*
9 * NetBSD/FreeBSD shared library rules
10 */
11
12#ifndef UseElfFormat
13#define UseElfFormat NO
14#endif
15
16#if !UseElfFormat
17/* a.out shared libs */
18#ifndef HasSharedLibraries
19# ifndef Arm32Architecture
20#  define HasSharedLibraries YES
21# endif
22#endif
23#ifndef SharedDataSeparation
24#define SharedDataSeparation NO
25#endif
26#ifndef SharedCodeDef
27#define SharedCodeDef
28#endif
29#ifndef SharedLibraryDef
30#define SharedLibraryDef -DBSDSHLIB
31#endif
32#ifndef ShLibIncludeFile
33#define ShLibIncludeFile <bsdLib.tmpl>
34#endif
35#ifndef SharedLibraryLoadFlags
36#define SharedLibraryLoadFlags -Bshareable
37#endif
38#ifndef PositionIndependentCFlags
39#define PositionIndependentCFlags -fpic
40#endif
41
42/*
43 * InstallSharedLibrary - generate rules to install the shared library.
44 */
45#ifndef InstallSharedLibrary
46#define InstallSharedLibrary(libname,rev,dest)				@@\
47install:: Concat(lib,libname.so.rev)					@@\
48	MakeDir($(DESTDIR)dest)						@@\
49	$(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest 
50@@\
51
52#endif /* InstallSharedLibrary */
53
54/*
55 * SharedLibraryTarget - generate rules to create a shared library;
56 * build it into a different name so that we do not hose people by having
57 * the library gone for long periods.
58 */
59#ifndef SharedLibraryTarget
60#define SharedLibraryTarget(libname,rev,solist,down,up)			@@\
61AllTarget(Concat(lib,libname.so.rev))					@@\
62									@@\
63Concat(lib,libname.so.rev):  solist $(EXTRALIBRARYDEPS)			@@\
64	$(RM) $@~							@@\
65	(cd down; $(LD) -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\
66	$(RM) $@							@@\
67	$(MV) $@~ $@							@@\
68	LinkBuildLibrary($@)						@@\
69									@@\
70clean::									@@\
71	$(RM) Concat(lib,libname.so.rev)
72
73#endif /* SharedLibraryTarget */
74
75/*
76 * SharedDepLibraryTarget - generate rules to create a shared library.
77 */
78#ifndef SharedDepLibraryTarget
79#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
80AllTarget(Concat(lib,libname.so.rev))					@@\
81									@@\
82Concat(lib,libname.so.rev):  deplist $(EXTRALIBRARYDEPS)		@@\
83	$(RM) $@~							@@\
84	(cd down; $(LD) -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\
85	$(RM) $@							@@\
86	$(MV) $@~ $@							@@\
87	LinkBuildLibrary($@)						@@\
88									@@\
89clean::									@@\
90	$(RM) Concat(lib,libname.so.rev)
91
92#endif /* SharedDepLibraryTarget */
93
94#ifndef SharedDepModuleTarget
95#define SharedDepModuleTarget(name,deps,solist)				@@\
96AllTarget(name)								@@\
97									@@\
98name: deps								@@\
99	$(RM) $@~							@@\
100	$(LD) -o $@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)		@@\
101	$(RM) $@							@@\
102	$(MV) $@~ $@							@@\
103									@@\
104clean::									@@\
105	$(RM) name
106
107#endif /* SharedDepModuleTarget */
108
109/*
110 * SharedLibraryDataTarget - generate rules to create shlib data file;
111 */
112#ifndef SharedLibraryDataTarget
113#define SharedLibraryDataTarget(libname,rev,salist)
114#endif /* SharedLibraryDataTarget */
115
116#ifndef InstallSharedLibraryData
117#define InstallSharedLibraryData(libname,rev,dest)
118#endif /* InstallSharedLibraryData */
119
120/*
121 * SharedLibReferences - variables for shared libraries
122 */
123#ifndef SharedLibReferences
124#define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
125revname = rev								@@\
126Concat3(DEP,varname,LIB) = SharedLibDependencies(libname,libsource,revname) @@\
127Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname)		@@\
128LintLibReferences(varname,libname,libsource)
129#endif
130
131 /*
132 * SharedFontLibReferences - shared font libraries
133 */
134#ifndef SharedFontLibReferences
135#define SharedFontLibReferences()					@@\
136SOFONTREV = SharedFontRev						@@\
137DEPFONTLIB = SharedLibDependencies(Xfont,$(FONTLIBSRC),SOFONTREV)	@@\
138FONTLIB = -L$(FREETYPELIBDIR) -L$(FONTLIBSRC) LoaderLibPrefix -lXfont	@@\
139LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
140#endif
141
142/*
143 * SharedDSLibReferences - variables for shared libraries
144 */
145#ifndef SharedDSLibReferences
146#define SharedDSLibReferences(varname,libname,libsource,revname,rev)	@@\
147revname = rev								@@\
148Concat3(DEP,varname,LIB) = SharedDSLibDependencies(libname,libsource,revname) @@\
149Concat(varname,LIB) = LoaderLibPrefix Concat(-l,libname) Concat3(Shared,libname,Reqs)		@@\
150LintLibReferences(varname,libname,libsource)
151#endif
152
153#else /* UseElfFormat */
154
155/*
156 * NetBSD/FreeBSD (ELF) shared library rules
157 * Cloned from Linux ELF rules, with the following major change:
158 *
159 * 	Shared libraries depend on -lc.  Since we don't have to worry
160 *	about libc vs. libg, etc., this is a good idea.  (This is actually
161 *	implied by using $(CC) to build the shared libraries.)  Adding it
162 *	explicitly will break threaded applications on platforms that use
163 *	libc_r for thread support.
164 */
165
166#ifndef HasSharedLibraries
167#define HasSharedLibraries YES
168#endif
169#ifndef ForceNormalLib
170#define ForceNormalLib YES
171#endif
172
173#ifndef UseRpath
174#define UseRpath YES
175#endif
176
177#ifndef BaseShLibReqs
178#define BaseShLibReqs		/* -lc */
179#endif
180
181#ifndef SharedDataSeparation
182#define SharedDataSeparation NO
183#endif
184#ifndef SharedCodeDef
185#define SharedCodeDef /**/
186#endif
187#ifndef SharedLibraryDef
188#define SharedLibraryDef /**/
189#endif
190#ifndef ShLibIncludeFile
191#define ShLibIncludeFile <bsdLib.tmpl>
192#endif
193#ifndef RpathLoadFlags
194#if UseRpath
195#define RpathLoadFlags -Wl,-rpath,$(USRLIBDIRPATH)
196#else
197#define RpathLoadFlags /**/
198#endif
199#endif
200#ifndef LibraryRpathLoadFlags
201#define LibraryRpathLoadFlags RpathLoadFlags
202#endif
203#ifndef SharedLibraryLoadFlags
204#define SharedLibraryLoadFlags -shared LibraryRpathLoadFlags
205#endif
206#ifndef PositionIndependentCFlags
207#define PositionIndependentCFlags -fPIC
208#endif
209#ifndef PositionIndependentCplusplusFlags
210#define PositionIndependentCplusplusFlags -fPIC
211#endif
212#ifndef ExtraLoadFlags
213#ifdef UseInstalled
214#define ExtraLoadFlags RpathLoadFlags
215#else
216#define ExtraLoadFlags RpathLoadFlags -Wl,-rpath-link,$(BUILDLIBDIR)
217#endif
218#endif
219
220#ifndef HardCodeLibdirFlag
221#define HardCodeLibdirFlag RpathLoadFlags
222#endif
223
224#if !defined(ShlibGlobalsFlags)
225#define ShlibGlobalsFlags -Wl,-Bsymbolic
226#endif
227
228/*
229 * InstallSharedLibrary - generate rules to install the shared library.
230 * NOTE: file must be executable, hence "INSTBINFLAGS"
231 */
232#if !defined(FreeBSDArchitecture) || defined(DragonFlyArchitecture)
233INSTALLMINORREV = true
234#else
235INSTALLMINORREV = false
236#endif
237
238#ifndef InstallSharedLibrary
239#define InstallSharedLibrary(libname,rev,dest)				@@\
240install:: Concat(lib,libname.so.rev) 					@@\
241	MakeDir($(DESTDIR)dest)						@@\
242	@T=`echo Concat(lib,libname.so.rev) | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`;\	@@\
243	if $(INSTALLMINORREV); then \					@@\
244	  INST=Concat(lib,libname.so.rev); \				@@\
245	  LINK=$$T; \							@@\
246	else \								@@\
247	  INST=$$T; \							@@\
248	fi; \								@@\
249	(set -x; \							@@\
250	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) $$INST $(DESTDIR)dest); \ @@\
251	if [ X"$$LINK" != X ]; then (set -x; \				@@\
252	  $(RM) $(DESTDIR)dest/$$LINK; \			@@\
253	  $(LN) $$INST $(DESTDIR)dest/$$LINK); \			@@\
254	fi; \								@@\
255	if $(SOSYMLINK); then (set -x; \				@@\
256	  $(RM) Concat($(DESTDIR)dest/lib,libname.so); \	@@\
257	  $(LN) $$T Concat($(DESTDIR)dest/lib,libname.so)); \		@@\
258	fi
259#endif /* InstallSharedLibrary */
260
261#ifndef InstallSharedLibtoolLibrary
262
263#define SetRevisions(rev) V=`expr rev : '\([^:]*\)'`; \			@@\
264		R=`expr rev : '.*:\([^:]*\):'`; \			@@\
265		A=`expr rev : '.*:\([^:]*\)'`; \			@@\
266		REV=$$V; \						@@\
267		REVLIST=""; \						@@\
268		i=$$A; \						@@\
269		while [ $$i -gt 0 ]; do \				@@\
270			REVLIST="$$REVLIST `expr $$REV - $$i`"; \	@@\
271			i=`expr $$i - 1`; \				@@\
272		done
273
274#define InstallSharedLibtoolLibrary(libname,rev,dest)			@@\
275install:: Concat(lib,libname.so) 					@@\
276	MakeDir($(DESTDIR)dest)						@@\
277	@set +e; SetRevisions(rev); \					@@\
278	set -e; \							@@\
279	T=Concat(lib,libname.so.$$REV); \				@@\
280	if $(INSTALLMINORREV); then \					@@\
281	  INST=$$T.0; \							@@\
282	  LINK=$$T; \							@@\
283	else \								@@\
284	  INST=$$T; \							@@\
285	fi; \								@@\
286	(set -x; \							@@\
287	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) $$INST $(DESTDIR)dest); \ @@\
288	if [ X"$$LINK" != X ]; then (set -x; \				@@\
289	  $(RM) $(DESTDIR)dest/$$LINK; \				@@\
290	  $(LN) $$INST $(DESTDIR)dest/$$LINK); \			@@\
291	fi; \								@@\
292	for i in $$REVLIST; do (set -x; \				@@\
293	  $(RM) Concat($(DESTDIR)dest/lib,libname.so.$$i); \		@@\
294	  $(LN) Concat(lib,libname.so.$$REV) Concat($(DESTDIR)dest/lib,libname.so.$$i)); \ @@\
295	done; \								@@\
296	if $(SOSYMLINK); then (set -x; \				@@\
297	  $(RM) Concat($(DESTDIR)dest/lib,libname.so); \		@@\
298	  $(LN) Concat(lib,libname.so.$$REV) Concat($(DESTDIR)dest/lib,libname.so)); \									@@\
299	fi
300#endif /* InstallSharedLibtoolLibrary */
301
302/*
303 * InstallSharedLibraryData - generate rules to install the shared library data
304 */
305#ifndef InstallSharedLibraryData
306#define InstallSharedLibraryData(libname,rev,dest)
307#endif /* InstallSharedLibraryData */
308
309
310/*
311 * SharedLibraryTarget - generate rules to create a shared library;
312 * build it into a different name so that we do not hose people by having
313 * the library gone for long periods.
314 */
315#ifndef SharedLibraryTarget
316#define SharedLibraryTarget(libname,rev,solist,down,up)			@@\
317AllTarget(Concat(lib,libname.so.rev))					@@\
318									@@\
319Concat(lib,libname.so.rev):  solist					@@\
320	$(RM) $@~							@@\
321	@SONAME=`echo $@ | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; \			@@\
322		(set -x; cd down; $(CC) -o up/$@~ $(SHLIBLDFLAGS) -Wl,-soname,$$SONAME solist $(REQUIREDLIBS) BaseShLibReqs); \ @@\
323		(set -x; $(RM) $$SONAME; $(LN) $@ $$SONAME); \		@@\
324		LinkBuildSonameLibrary($$SONAME)			@@\
325	$(RM) $@							@@\
326	$(MV) $@~ $@							@@\
327	LinkBuildLibrary($@)						@@\
328	@if $(SOSYMLINK); then (set -x; \				@@\
329	  $(RM) Concat(lib,libname.so); \				@@\
330	  $(LN) $@ Concat(lib,libname.so)); fi				@@\
331	LinkBuildLibraryMaybe(Concat(lib,libname.so),$(SOSYMLINK))	@@\
332									@@\
333clean::									@@\
334	@SONAME=`echo Concat(lib,libname.so.rev) | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; \ @@\
335	set -x; $(RM) $$SONAME						@@\
336	$(RM) Concat(lib,libname.so)					@@\
337	$(RM) Concat(lib,libname.so.rev)
338
339#endif /* SharedLibraryTarget */
340
341#ifndef SharedLibtoolLibraryTarget
342#define SharedLibtoolLibraryTarget(libname,rev,solist,down,up)		@@\
343AllTarget(Concat(lib,libname.so))					@@\
344									@@\
345Concat(lib,libname.so):  solist						@@\
346	$(RM) $@~							@@\
347	@set +e; SetRevisions(rev); \					@@\
348	SONAME=$@.$$REV; \						@@\
349	set -e; \							@@\
350	(set -x; cd down; $(CC) -o up/$$SONAME~ $(SHLIBLDFLAGS) -Wl,-soname,$$SONAME solist $(REQUIREDLIBS) BaseShLibReqs); \ @@\
351	(set -x; $(RM) $$SONAME; $(MV) $$SONAME~ $$SONAME); \		@@\
352	LinkBuildSonameLibrary($$SONAME); \				@@\
353	if $(INSTALLMINORREV); then (set -x; \				@@\
354	  $(RM) $$SONAME.0; \						@@\
355	  $(LN) $$SONAME $$SONAME.0); \					@@\
356	fi; \								@@\
357	if $(SOSYMLINK); then (set -x; \				@@\
358	  $(RM) $@; \							@@\
359	  $(LN) $$SONAME $@); \						@@\
360	  LinkBuildLibraryInline($@); \					@@\
361	fi								@@\
362									@@\
363clean::									@@\
364	@set +e; SetRevisions(rev); \					@@\
365		set -xe; \						@@\
366		$(RM) Concat(lib,libname.so.$$REV); \			@@\
367		$(RM) Concat(lib,libname.so.$$REV.0)			@@\
368	$(RM) Concat(lib,libname.so)
369
370#endif /* SharedLibtoolLibraryTarget */
371
372/*
373 * SharedDepLibraryTarget - generate rules to create a shared library.
374 */
375#ifndef SharedDepLibraryTarget
376#define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
377AllTarget(Concat(lib,libname.so.rev))					@@\
378									@@\
379Concat(lib,libname.so.rev):  deplist					@@\
380	$(RM) $@~							@@\
381	@SONAME=`echo $@ | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; set -x; \		@@\
382		(cd down; $(CC) -o up/$@~ $(SHLIBLDFLAGS) -Wl,-soname,$$SONAME solist $(REQUIREDLIBS) BaseShLibReqs); \ @@\
383		$(RM) $$SONAME; $(LN) $@ $$SONAME; \			@@\
384		LinkBuildSonameLibrary($$SONAME)			@@\
385	$(RM) $@							@@\
386	$(MV) $@~ $@							@@\
387	$(RM) Concat(lib,libname.so)					@@\
388	$(LN) $@ Concat(lib,libname.so)					@@\
389	LinkBuildLibrary($@)						@@\
390	LinkBuildLibrary(Concat(lib,libname.so))			@@\
391									@@\
392clean::									@@\
393	@SONAME=`echo Concat(lib,libname.so.rev) | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; \ @@\
394	set -x; $(RM) $$SONAME						@@\
395	$(RM) Concat(lib,libname.so)					@@\
396	$(RM) Concat(lib,libname.so.rev)
397
398#endif /* SharedDepLibraryTarget */
399
400/*
401 * SharedDepCplusplusLibraryTarget - generate rules to create a shared library.
402 */
403#ifndef SharedDepCplusplusLibraryTarget
404#define SharedDepCplusplusLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
405AllTarget(Concat(lib,libname.so.rev))					@@\
406									@@\
407Concat(lib,libname.so.rev):  deplist					@@\
408	$(RM) $@~							@@\
409	@SONAME=`echo $@ | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; set -x; \		@@\
410		(cd down; $(CXX) -o up/$@~ $(SHLIBLDFLAGS) -Wl,-soname,$$SONAME solist $(REQUIREDLIBS) BaseShLibReqs); \ @@\
411		$(RM) $$SONAME; $(LN) $@ $$SONAME; \			@@\
412		LinkBuildSonameLibrary($$SONAME)			@@\
413	$(RM) $@							@@\
414	$(MV) $@~ $@							@@\
415	$(RM) Concat(lib,libname.so)					@@\
416	$(LN) $@ Concat(lib,libname.so)					@@\
417	LinkBuildLibrary($@)						@@\
418	LinkBuildLibrary(Concat(lib,libname.so))			@@\
419									@@\
420clean::									@@\
421	@SONAME=`echo Concat(lib,libname.so.rev) | sed 's/\(lib[^\.]*\.so\.[0-9]*\)\(\.[0-9]*\)\{1,2\}/\1/'`; \ @@\
422	set -x; $(RM) $$SONAME						@@\
423	$(RM) Concat(lib,libname.so)					@@\
424	$(RM) Concat(lib,libname.so.rev)
425
426#endif /* SharedDepCplusplusLibraryTarget */
427
428#ifndef SharedDepModuleTarget
429#define SharedDepModuleTarget(name,deps,solist)				@@\
430AllTarget(name)								@@\
431									@@\
432name: deps								@@\
433	$(RM) $@~							@@\
434	$(CC) -o $@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)		@@\
435	$(RM) $@							@@\
436	$(MV) $@~ $@							@@\
437									@@\
438clean::									@@\
439	$(RM) name
440
441#endif /* SharedDepModuleTarget */
442
443#ifndef SharedDriModuleTarget
444#define SharedDriModuleTarget(name,deps,solist)				@@\
445AllTarget(name)								@@\
446									@@\
447name: deps								@@\
448	$(RM) $@~ $@.map						@@\
449	@(echo 'DRI_MODULE { global: __dri*; local: *; };' > $@.map)	@@\
450	$(CC) -o $@~ -Wl,--version-script=$@.map $(SHLIBLDFLAGS) solist $(REQUIREDLIBS) BaseShLibReqs @@\
451	$(RM) $@ $@.map							@@\
452	$(MV) $@~ $@							@@\
453									@@\
454clean::									@@\
455	$(RM) name							@@\
456	$(RM) name.map
457
458#endif /* SharedDriModuleTarget */
459
460/*
461 * SharedLibraryDataTarget - generate rules to create shlib data file;
462 */
463#ifndef SharedLibraryDataTarget
464#define SharedLibraryDataTarget(libname,rev,salist)
465#endif /* SharedLibraryTarget */
466
467#if defined(FreeBSDArchitecture)
468
469/*
470 * Support for building a.out compatibility libraries on a FreeBSD/ELF system.
471 */
472#ifndef BuildAoutLibraries
473#define BuildAoutLibraries NO
474#endif
475
476#if BuildAoutLibraries
477
478#define ExtraLibRules
479
480#ifndef AoutSharedLibraryDef
481#define AoutSharedLibraryDef -DBSDSHLIB
482#endif
483#ifndef AoutSharedLibraryLoadFlags
484#define AoutSharedLibraryLoadFlags -aout -Bshareable
485#endif
486#ifndef AoutPositionIndependentCFlags
487#define AoutPositionIndependentCFlags -fpic
488#endif
489
490/*
491 * InstallAoutSharedLibrary - generate rules to install the shared library.
492 */
493#ifndef InstallAoutSharedLibrary
494#define InstallAoutSharedLibrary(libname,rev,dest)			@@\
495install:: Concat(aout/lib,libname.so.rev)				@@\
496	MakeDir($(DESTDIR)dest)						@@\
497	$(INSTALL) -c $(INSTLIBFLAGS) Concat(aout/lib,libname.so.rev) $(DESTDIR)dest 
498@@\
499
500#endif /* InstallAoutSharedLibrary */
501
502/*
503 * AoutSharedLibraryTarget - generate rules to create a shared library;
504 * build it into a different name so that we do not hose people by having
505 * the library gone for long periods.
506 */
507#ifndef AoutSharedLibraryTarget
508#define AoutSharedLibraryTarget(libname,rev,solist,down,up)		@@\
509AllTarget(Concat(down/lib,libname.so.rev))				@@\
510									@@\
511Concat(down/lib,libname.so.rev):  solist $(EXTRALIBRARYDEPS)		@@\
512	$(RM) $@~							@@\
513	(cd down; $(LD) -o up/$@~ AoutSharedLibraryLoadFlags solist)	@@\
514	$(RM) $@							@@\
515	$(MV) $@~ $@							@@\
516									@@\
517clean::									@@\
518	$(RM) Concat(down/lib,libname.so.rev)
519
520#endif /* AoutSharedLibraryTarget */
521
522#define AoutCDebugFlags -aout DefaultCDebugFlags
523#define AoutCplusplusDebugFlags -aout DefaultCplusplusDebugFlags
524
525#define AoutLibObjCompile(options) LibObjCompile(aout,AoutCDebugFlags AoutSharedLibraryDef AoutPositionIndependentCFlags options)
526#define AoutLibObjCplusplusCompile(options) LibObjCompile(aout,AoutCplusplusDebugFlags options)
527
528#define ExtraLibMkdir() _LibMkdir(aout)
529#define ExtraObjCompile(options) AoutLibObjCompile(options)
530#define ExtraObjCplusplusCompile(options) AoutLibObjCplusplusCompile(options)
531#define ExtraCleanDir() LibCleanDir(aout)
532
533#define ExtraLibraryTarget(libname,so,objs) AoutSharedLibraryTarget(libname,so,objs,aout,..)
534#define ExtraInstallLibrary(libname,so) InstallAoutSharedLibrary(libname,so,$(SHLIBDIR)/aout)
535
536#endif
537#endif
538
539
540#endif /* UseElfFormat */
541