~ubuntu-branches/ubuntu/dapper/pmake/dapper

« back to all changes in this revision

Viewing changes to mk/bsd.lib.mk

  • Committer: Bazaar Package Importer
  • Author(s): Steve McIntyre
  • Date: 2002-03-12 21:59:55 UTC
  • Revision ID: james.westby@ubuntu.com-20020312215955-i183oxj3rpm464yh
Tags: 1.45-10
* Fixed broken '.Nm ""' directives in the man page. Closes: #137768
* Changed name from "make" to "pmake" in manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#       $NetBSD: bsd.lib.mk,v 1.152 1999/03/30 09:30:43 fair Exp $
 
2
#       @(#)bsd.lib.mk  8.3 (Berkeley) 4/22/94
 
3
 
 
4
.if !target(__initialized__)
 
5
__initialized__:
 
6
.if exists(${.CURDIR}/../Makefile.inc)
 
7
.include "${.CURDIR}/../Makefile.inc"
 
8
.endif
 
9
.include <bsd.own.mk>
 
10
.include <bsd.obj.mk>
 
11
.MAIN:          all
 
12
.endif
 
13
 
 
14
.PHONY:         checkver cleanlib libinstall
 
15
realinstall:    checkver libinstall
 
16
clean cleandir distclean: cleanlib
 
17
 
 
18
.if exists(${.CURDIR}/shlib_version)
 
19
SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
 
20
SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
 
21
 
 
22
# Check for higher installed library versions.
 
23
.if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
 
24
        exists(${BSDSRCDIR}/lib/checkver)
 
25
checkver:
 
26
        @(cd ${.CURDIR} && \
 
27
                ${BSDSRCDIR}/lib/checkver -d ${DESTDIR}${LIBDIR} ${LIB})
 
28
.else
 
29
checkver:
 
30
.endif
 
31
.else
 
32
checkver:
 
33
.endif
 
34
 
 
35
# add additional suffixes not exported.
 
36
# .po is used for profiling object files.
 
37
# .so is used for PIC object files.
 
38
.SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
 
39
.SUFFIXES: .sh .m4 .m
 
40
 
 
41
 
 
42
# Set PICFLAGS to cc flags for producing position-independent code,
 
43
# if not already set.  Includes -DPIC, if required.
 
44
 
 
45
# Data-driven table using make variables to control  how shared libraries
 
46
# are built for different platforms and object formats.
 
47
# OBJECT_FMT:           currently either "ELF" or "a.out", from <bsd.own.mk>
 
48
# SHLIB_SOVERSION:      version number to be compiled into a shared library
 
49
#                       via -soname. Usualy ${SHLIB_MAJOR} on ELF.
 
50
#                       NetBSD/pmax used to use ${SHLIB_MAJOR}.{SHLIB-MINOR}.
 
51
# SHLIB_SHFLAGS:        Flags to tell ${LD} to emit  shared library.
 
52
#                       with ELF, also set shared-lib version for ld.so.
 
53
# SHLIB_LDSTARTFILE:    support .o file, call C++ file-level constructors
 
54
# SHLIB_LDENDFILE:      support .o file, call C++ file-level destructors
 
55
# CPPICFLAGS:   flags for ${CPP} to preprocess  .[sS]  files for ${AS}
 
56
# CPICFLAGS:    flags for ${CC} to compile  .[cC] files to .so objects.
 
57
# CAPICFLAGS    flags for {$CC} to compiling .[Ss] files
 
58
#                       (usually just ${CPPPICFLAGS} ${CPICFLAGS})
 
59
# APICFLAGS:    flags for ${AS} to assemble .[sS]  to .so objects.
 
60
 
 
61
.if ${MACHINE_ARCH} == "alpha"
 
62
                # Alpha-specific shared library flags
 
63
CPICFLAGS ?= -fpic -DPIC
 
64
CPPPICFLAGS?= -DPIC 
 
65
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
 
66
APICFLAGS ?=
 
67
.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
 
68
                # mips-specific shared library flags
 
69
 
 
70
# On mips, all libs need to be compiled with ABIcalls, not just sharedlibs.
 
71
CPICFLAGS?=
 
72
APICFLAGS?=
 
73
#CPICFLAGS?= -fpic -DPIC
 
74
#APICFLAGS?= -DPIC
 
75
 
 
76
# so turn shlib PIC flags on for ${CPP}, ${CC}, and ${AS} as follows:
 
77
AINC+=-DPIC -DABICALLS
 
78
COPTS+= -fPIC ${AINC}
 
79
AFLAGS+= -fPIC
 
80
AS+=    -KPIC
 
81
 
 
82
.elif ${MACHINE_ARCH} == "sparc" && ${OBJECT_FMT} == "ELF"
 
83
 
 
84
CPICFLAGS ?= -fpic -DPIC
 
85
CPPPICFLAGS?= -DPIC 
 
86
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
 
87
APICFLAGS ?= -KPIC
 
88
 
 
89
.elif (${MACHINE} == "debian")
 
90
 
 
91
SHLIB_TYPE=ELF
 
92
SHLIB_LDSTARTFILE=
 
93
SHLIB_LDENDFILE=
 
94
SHLIB_SOVERSION=${SHLIB_MAJOR}
 
95
CPICFLAGS ?= -fPIC -DPIC
 
96
CPPPICFLAGS?= -DPIC
 
97
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
 
98
APICFLAGS ?=
 
99
 
 
100
.else
 
101
 
 
102
# Platform-independent flags for NetBSD a.out shared libraries (and PowerPC)
 
103
SHLIB_LDSTARTFILE=
 
104
SHLIB_LDENDFILE=
 
105
SHLIB_SHFLAGS=
 
106
SHLIB_SOVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
 
107
CPICFLAGS?= -fpic -DPIC
 
108
CPPPICFLAGS?= -DPIC 
 
109
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
 
110
APICFLAGS?= -k
 
111
 
 
112
.endif
 
113
 
 
114
# Platform-independent linker flags for ELF shared libraries
 
115
.if ${OBJECT_FMT} == "ELF"
 
116
SHLIB_SOVERSION=${SHLIB_MAJOR}
 
117
SHLIB_SHFLAGS=-soname lib${LIB}.so.${SHLIB_SOVERSION}
 
118
SHLIB_LDSTARTFILE= ${DESTDIR}/usr/lib/crtbeginS.o
 
119
SHLIB_LDENDFILE= ${DESTDIR}/usr/lib/crtendS.o
 
120
.endif
 
121
 
 
122
CFLAGS+=        ${COPTS}
 
123
 
 
124
.c.o:
 
125
        @echo ${COMPILE.c:Q} ${.IMPSRC}
 
126
        @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
 
127
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
128
        @rm -f ${.TARGET}.o
 
129
 
 
130
.c.po:
 
131
        @echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
 
132
        @${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
 
133
        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
 
134
        @rm -f ${.TARGET}.o
 
135
 
 
136
.c.so:
 
137
        @echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
 
138
        @${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
 
139
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
140
        @rm -f ${.TARGET}.o
 
141
 
 
142
.c.ln:
 
143
        ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
 
144
 
 
145
.cc.o .C.o:
 
146
        @echo ${COMPILE.cc:Q} ${.IMPSRC}
 
147
        @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
 
148
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
149
        @rm -f ${.TARGET}.o
 
150
 
 
151
.cc.po .C.po:
 
152
        @echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
 
153
        @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
 
154
        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
 
155
        @rm -f ${.TARGET}.o
 
156
 
 
157
.cc.so .C.so:
 
158
        @echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
 
159
        @${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
 
160
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
161
        @rm -f ${.TARGET}.o
 
162
 
 
163
.m.o:
 
164
        @echo ${COMPILE.m:Q} ${.IMPSRC}
 
165
        @${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.o
 
166
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
167
        @rm -f ${.TARGET}.o
 
168
 
 
169
.m.po:
 
170
        @echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET}
 
171
        @${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o
 
172
        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
 
173
        @rm -f ${.TARGET}.o
 
174
 
 
175
.m.so:
 
176
        @echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
 
177
        @${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
 
178
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
179
        @rm -f ${.TARGET}.o
 
180
 
 
181
.S.o .s.o:
 
182
        @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
 
183
        @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
 
184
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
185
        @rm -f ${.TARGET}.o
 
186
 
 
187
.S.po .s.po:
 
188
        @echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
 
189
        @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
 
190
        @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
 
191
        @rm -f ${.TARGET}.o
 
192
 
 
193
.S.so .s.so:
 
194
        @echo ${COMPILE.S:Q} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
 
195
        @${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
 
196
        @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
 
197
        @rm -f ${.TARGET}.o
 
198
 
 
199
.if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
 
200
        || ${MKLINKLIB} != "no"
 
201
_LIBS=lib${LIB}.a
 
202
.else
 
203
_LIBS=
 
204
.endif
 
205
 
 
206
.if ${MKPROFILE} != "no"
 
207
_LIBS+=lib${LIB}_p.a
 
208
.endif
 
209
 
 
210
.if ${MKPIC} != "no"
 
211
_LIBS+=lib${LIB}_pic.a
 
212
.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
 
213
_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 
214
.endif
 
215
.endif
 
216
 
 
217
.if ${MKLINT} != "no" && ${MKLINKLIB} != "no"
 
218
_LIBS+=llib-l${LIB}.ln
 
219
.endif
 
220
 
 
221
all: ${SRCS} ${_LIBS}
 
222
 
 
223
__archivebuild: .USE
 
224
        @rm -f ${.TARGET}
 
225
        @${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
 
226
        ${RANLIB} ${.TARGET}
 
227
 
 
228
__archiveinstall: .USE
 
229
        ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} \
 
230
                -m 600 ${.ALLSRC} ${.TARGET}
 
231
        ${RANLIB} -t ${.TARGET}
 
232
        chmod ${LIBMODE} ${.TARGET}
 
233
 
 
234
DPSRCS+=        ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
 
235
CLEANFILES+=    ${DPSRCS}
 
236
.if defined(YHEADER)
 
237
CLEANFILES+=    ${SRCS:M*.y:.y=.h}
 
238
.endif
 
239
 
 
240
OBJS+=          ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
 
241
lib${LIB}.a:: ${OBJS} __archivebuild
 
242
        @echo building standard ${LIB} library
 
243
 
 
244
POBJS+=         ${OBJS:.o=.po}
 
245
lib${LIB}_p.a:: ${POBJS} __archivebuild
 
246
        @echo building profiled ${LIB} library
 
247
 
 
248
SOBJS+=         ${OBJS:.o=.so}
 
249
lib${LIB}_pic.a:: ${SOBJS} __archivebuild
 
250
        @echo building shared object ${LIB} library
 
251
 
 
252
lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD} \
 
253
    ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
 
254
        @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
 
255
        @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 
256
.if defined(DESTDIR)
 
257
        $(CC) -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
 
258
            ${SHLIB_LDSTARTFILE} \
 
259
            --whole-archive lib${LIB}_pic.a \
 
260
            -nostdlib -L${DESTDIR}${LIBDIR} -R${LIBDIR} \
 
261
            --no-whole-archive ${LDADD} \
 
262
            ${SHLIB_LDENDFILE}
 
263
.else
 
264
        $(CC) -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
 
265
            ${SHLIB_LDSTARTFILE} \
 
266
            --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
 
267
            ${SHLIB_LDENDFILE}
 
268
.endif
 
269
.if ${OBJECT_FMT} == "ELF"
 
270
        rm -f lib${LIB}.so.${SHLIB_MAJOR}
 
271
        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 
272
            lib${LIB}.so.${SHLIB_MAJOR}
 
273
        rm -f lib${LIB}.so
 
274
        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 
275
            lib${LIB}.so
 
276
.endif
 
277
 
 
278
LOBJS+=         ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
 
279
LLIBS?=         -lc
 
280
llib-l${LIB}.ln: ${LOBJS}
 
281
        @echo building llib-l${LIB}.ln
 
282
        @rm -f llib-l${LIB}.ln
 
283
        @${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
 
284
 
 
285
cleanlib:
 
286
        rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
 
287
        rm -f lib${LIB}.a ${OBJS}
 
288
        rm -f lib${LIB}_p.a ${POBJS}
 
289
        rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
 
290
        rm -f llib-l${LIB}.ln ${LOBJS}
 
291
 
 
292
.if defined(SRCS)
 
293
afterdepend: .depend
 
294
        @(TMP=/tmp/_depend$$$$; \
 
295
            sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
 
296
              < .depend > $$TMP; \
 
297
            mv $$TMP .depend)
 
298
.endif
 
299
 
 
300
.if !target(libinstall)
 
301
# Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
 
302
libinstall::
 
303
 
 
304
.if ${MKLINKLIB} != "no"
 
305
libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
 
306
.if !defined(UPDATE)
 
307
.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a
 
308
.endif
 
309
.if !defined(BUILD)
 
310
${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
 
311
.endif
 
312
 
 
313
.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
 
314
${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
 
315
.endif
 
316
 
 
317
.if ${MKPROFILE} != "no"
 
318
libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
 
319
.if !defined(UPDATE)
 
320
.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
 
321
.endif
 
322
.if !defined(BUILD)
 
323
${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
 
324
.endif
 
325
 
 
326
.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
 
327
${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
 
328
.endif
 
329
 
 
330
.if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
 
331
libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
 
332
.if !defined(UPDATE)
 
333
.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
 
334
.endif
 
335
.if !defined(BUILD)
 
336
${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
 
337
.endif
 
338
 
 
339
.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
 
340
${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
 
341
.endif
 
342
 
 
343
.if ${MKPIC} != "no" && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
 
344
libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 
345
.if !defined(UPDATE)
 
346
.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 
347
.endif
 
348
.if !defined(BUILD)
 
349
${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: .MADE
 
350
.endif
 
351
 
 
352
.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 
353
${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 
354
        ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} \
 
355
                -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
 
356
.if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
 
357
        /sbin/ldconfig -m ${LIBDIR}
 
358
.endif
 
359
.if ${OBJECT_FMT} == "ELF"
 
360
        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
 
361
        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 
362
            ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
 
363
        rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
 
364
.if ${MKLINKLIB} != "no"
 
365
        ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 
366
            ${DESTDIR}${LIBDIR}/lib${LIB}.so
 
367
.endif
 
368
.endif
 
369
.endif
 
370
 
 
371
.if ${MKLINT} != "no" && ${MKLINKLIB} != "no"
 
372
libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
 
373
.if !defined(UPDATE)
 
374
.PHONY: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
 
375
.endif
 
376
.if !defined(BUILD)
 
377
${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
 
378
.endif
 
379
 
 
380
.PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
 
381
${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
 
382
        ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} \
 
383
                -m ${LIBMODE} ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
 
384
.endif
 
385
.endif
 
386
 
 
387
.include <bsd.man.mk>
 
388
.include <bsd.nls.mk>
 
389
.include <bsd.files.mk>
 
390
.include <bsd.inc.mk>
 
391
.include <bsd.links.mk>
 
392
.include <bsd.dep.mk>
 
393
.include <bsd.sys.mk>
 
394
 
 
395
# Make sure all of the standard targets are defined, even if they do nothing.
 
396
lint regress: