Deleted Added
full compact
bsd.lib.mk (18052) bsd.lib.mk (18340)
1# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
1# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
2# $Id: bsd.lib.mk,v 1.42 1996/08/25 05:16:56 jkh Exp $
2# $Id: bsd.lib.mk,v 1.43 1996/09/05 18:05:06 bde Exp $
3#
4
5.if exists(${.CURDIR}/../Makefile.inc)
6.include "${.CURDIR}/../Makefile.inc"
7.endif
8
9.if exists(${.CURDIR}/shlib_version)
10SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
11SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
12.endif
13
14.if defined(DESTDIR)
15CFLAGS+= -I${DESTDIR}/usr/include
16CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
17.endif
18
19.if defined(DEBUG_FLAGS)
20CFLAGS+= ${DEBUG_FLAGS}
21.endif
22
23.if !defined(DEBUG_FLAGS)
24STRIP?= -s
25.endif
26
27.MAIN: all
28
29# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
30# .so used for PIC object files
31.SUFFIXES:
32.SUFFIXES: .out .o .po .so .s .S .c .cc .cxx .m .C .f .y .l
33
34.c.o:
35 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
36 @${LD} -O ${.TARGET} -x -r ${.TARGET}
37
38.c.po:
39 ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
40 @${LD} -O ${.TARGET} -X -r ${.TARGET}
41
42.c.so:
43 ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
44 @${LD} -O ${.TARGET} -x -r ${.TARGET}
45
46.cc.o .C.o .cxx.o:
47 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
48 @${LD} -O ${.TARGET} -x -r ${.TARGET}
49
50.cc.po .C.po .cxx.po:
51 ${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
52 @${LD} -O ${.TARGET} -X -r ${.TARGET}
53
54.cc.so .C.so .cxx.so:
55 ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
56 @${LD} -O ${.TARGET} -x -r ${.TARGET}
57
58.f.o:
59 ${FC} ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
60 @${LD} -O ${.TARGET} -x -r ${.TARGET}
61
62.f.po:
63 ${FC} -p ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
64 @${LD} -O ${.TARGET} -X -r ${.TARGET}
65
66.f.so:
67 ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
68 @${LD} -O ${.TARGET} -x -r ${.TARGET}
69
70.s.o:
71 ${CC} -x asssembler-with-cpp ${CFLAGS:M-[ID]*} ${AINC} -c \
72 ${.IMPSRC} -o ${.TARGET}
73 @${LD} -O ${.TARGET} -x -r ${.TARGET}
74
75.s.po:
76 ${CC} -x assembler-with-cpp -DPROF ${CFLAGS:M-[ID]*} ${AINC} -c \
77 ${.IMPSRC} -o ${.TARGET}
78 @${LD} -O ${.TARGET} -X -r ${.TARGET}
79
80.s.so:
81 ${CC} -x assembler-with-cpp -fpic -DPIC ${CFLAGS:M-[ID]*} ${AINC} -c \
82 ${.IMPSRC} -o ${.TARGET}
83 @${LD} -O ${.TARGET} -x -r ${.TARGET}
84
85.S.o:
86 ${CC} ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
87
88.S.po:
89 ${CC} -DPROF ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
90
91.S.so:
92 ${CC} -fpic -DPIC ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
93 @${LD} -O ${.TARGET} -x -r ${.TARGET}
94
95.m.po:
96 ${CC} ${CFLAGS} -p -c ${.IMPSRC} -o ${.TARGET}
97 @${LD} -O ${.TARGET} -X -r ${.TARGET}
98
99.m.o:
100 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
101 @${LD} -O ${.TARGET} -X -r ${.TARGET}
102
103.if !defined(INTERNALLIB) || defined(INTERNALSTATICLIB)
104.if !defined(NOPROFILE) && !defined(INTERNALLIB)
105_LIBS=lib${LIB}.a lib${LIB}_p.a
106.else
107_LIBS=lib${LIB}.a
108.endif
109.endif
110
111.if !defined(NOPIC)
112.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
113_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
114.endif
115.if defined(INSTALL_PIC_ARCHIVE)
116_LIBS+=lib${LIB}_pic.a
117.endif
118.endif
119
120.if !defined(PICFLAG)
121PICFLAG=-fpic
122.endif
123
3#
4
5.if exists(${.CURDIR}/../Makefile.inc)
6.include "${.CURDIR}/../Makefile.inc"
7.endif
8
9.if exists(${.CURDIR}/shlib_version)
10SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
11SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
12.endif
13
14.if defined(DESTDIR)
15CFLAGS+= -I${DESTDIR}/usr/include
16CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
17.endif
18
19.if defined(DEBUG_FLAGS)
20CFLAGS+= ${DEBUG_FLAGS}
21.endif
22
23.if !defined(DEBUG_FLAGS)
24STRIP?= -s
25.endif
26
27.MAIN: all
28
29# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
30# .so used for PIC object files
31.SUFFIXES:
32.SUFFIXES: .out .o .po .so .s .S .c .cc .cxx .m .C .f .y .l
33
34.c.o:
35 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
36 @${LD} -O ${.TARGET} -x -r ${.TARGET}
37
38.c.po:
39 ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
40 @${LD} -O ${.TARGET} -X -r ${.TARGET}
41
42.c.so:
43 ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
44 @${LD} -O ${.TARGET} -x -r ${.TARGET}
45
46.cc.o .C.o .cxx.o:
47 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
48 @${LD} -O ${.TARGET} -x -r ${.TARGET}
49
50.cc.po .C.po .cxx.po:
51 ${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
52 @${LD} -O ${.TARGET} -X -r ${.TARGET}
53
54.cc.so .C.so .cxx.so:
55 ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
56 @${LD} -O ${.TARGET} -x -r ${.TARGET}
57
58.f.o:
59 ${FC} ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
60 @${LD} -O ${.TARGET} -x -r ${.TARGET}
61
62.f.po:
63 ${FC} -p ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
64 @${LD} -O ${.TARGET} -X -r ${.TARGET}
65
66.f.so:
67 ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
68 @${LD} -O ${.TARGET} -x -r ${.TARGET}
69
70.s.o:
71 ${CC} -x asssembler-with-cpp ${CFLAGS:M-[ID]*} ${AINC} -c \
72 ${.IMPSRC} -o ${.TARGET}
73 @${LD} -O ${.TARGET} -x -r ${.TARGET}
74
75.s.po:
76 ${CC} -x assembler-with-cpp -DPROF ${CFLAGS:M-[ID]*} ${AINC} -c \
77 ${.IMPSRC} -o ${.TARGET}
78 @${LD} -O ${.TARGET} -X -r ${.TARGET}
79
80.s.so:
81 ${CC} -x assembler-with-cpp -fpic -DPIC ${CFLAGS:M-[ID]*} ${AINC} -c \
82 ${.IMPSRC} -o ${.TARGET}
83 @${LD} -O ${.TARGET} -x -r ${.TARGET}
84
85.S.o:
86 ${CC} ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
87
88.S.po:
89 ${CC} -DPROF ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
90
91.S.so:
92 ${CC} -fpic -DPIC ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET}
93 @${LD} -O ${.TARGET} -x -r ${.TARGET}
94
95.m.po:
96 ${CC} ${CFLAGS} -p -c ${.IMPSRC} -o ${.TARGET}
97 @${LD} -O ${.TARGET} -X -r ${.TARGET}
98
99.m.o:
100 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
101 @${LD} -O ${.TARGET} -X -r ${.TARGET}
102
103.if !defined(INTERNALLIB) || defined(INTERNALSTATICLIB)
104.if !defined(NOPROFILE) && !defined(INTERNALLIB)
105_LIBS=lib${LIB}.a lib${LIB}_p.a
106.else
107_LIBS=lib${LIB}.a
108.endif
109.endif
110
111.if !defined(NOPIC)
112.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
113_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
114.endif
115.if defined(INSTALL_PIC_ARCHIVE)
116_LIBS+=lib${LIB}_pic.a
117.endif
118.endif
119
120.if !defined(PICFLAG)
121PICFLAG=-fpic
122.endif
123
124all: ${_LIBS} all-man _SUBDIR # llib-l${LIB}.ln
124all: objwarn ${_LIBS} all-man _SUBDIR # llib-l${LIB}.ln
125
126OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
127
128lib${LIB}.a:: ${OBJS}
129 @${ECHO} building standard ${LIB} library
130 @rm -f lib${LIB}.a
131 @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q` ${ARADD}
132 ${RANLIB} lib${LIB}.a
133
134.if !defined(NOPROFILE)
135POBJS+= ${OBJS:.o=.po}
136lib${LIB}_p.a:: ${POBJS}
137 @${ECHO} building profiled ${LIB} library
138 @rm -f lib${LIB}_p.a
139 @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q` ${ARADD}
140 ${RANLIB} lib${LIB}_p.a
141.endif
142
143.if defined(DESTDIR)
144LDDESTDIR?= -L${DESTDIR}/usr/lib
145.endif
146
147.if !defined(NOPIC)
148.if defined(CPLUSPLUSLIB) && !make(clean) && !make(cleandir)
149SOBJS+= ${DESTDIR}/usr/lib/c++rt0.o
150.endif
151
152SOBJS+= ${OBJS:.o=.so}
153lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS}
154 @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
155 @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
156 @${LD} -Bshareable -x \
157 -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
158 `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD}
159
160lib${LIB}_pic.a:: ${SOBJS}
161 @${ECHO} building special pic ${LIB} library
162 @rm -f lib${LIB}_pic.a
163 @${AR} cq lib${LIB}_pic.a ${SOBJS} ${ARADD}
164 ${RANLIB} lib${LIB}_pic.a
165.endif
166
167llib-l${LIB}.ln: ${SRCS}
168 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
169
170.if !target(clean)
171clean: _SUBDIR
172 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS}
173 rm -f lib${LIB}.a llib-l${LIB}.ln
174 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a
175 rm -f ${SOBJS} shared/*.o
176 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a
177.if defined(CLEANDIRS) && !empty(CLEANDIRS)
178 rm -rf ${CLEANDIRS}
179.endif
180.endif
181
182.if defined(SRCS)
183afterdepend:
184 @(TMP=/tmp/_depend$$$$; \
185 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' < .depend > $$TMP; \
186 mv $$TMP .depend)
187.endif
188
189.if !target(install)
190.if !target(beforeinstall)
191beforeinstall:
192.endif
193
194.if defined(PRECIOUSLIB)
195SHLINSTALLFLAGS+= -fschg
196.endif
197
198realinstall: beforeinstall
199.if !defined(INTERNALLIB)
200 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
201 ${INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
202.if !defined(NOPROFILE)
203 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
204 ${INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
205.endif
206.endif
207.if !defined(NOPIC)
208.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
209 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
210 ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \
211 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
212 ${DESTDIR}${SHLIBDIR}
213.endif
214.if defined(INSTALL_PIC_ARCHIVE)
215 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
216 ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
217.endif
218.endif
219.if defined(LINKS) && !empty(LINKS)
220 @set ${LINKS}; \
221 while test $$# -ge 2; do \
222 l=${DESTDIR}$$1; \
223 shift; \
224 t=${DESTDIR}$$1; \
225 shift; \
226 ${ECHO} $$t -\> $$l; \
227 rm -f $$t; \
228 ln ${LN_FLAGS} $$l $$t; \
229 done; true
230.endif
231
232install: afterinstall _SUBDIR
233.if !defined(NOMAN)
234afterinstall: realinstall maninstall
235.else
236afterinstall: realinstall
237.endif
238.endif
239
240DISTRIBUTION?= bin
241.if !target(distribute)
242distribute: _SUBDIR
243 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
244.endif
245
246.if !target(lint)
247lint:
248.endif
249
250.if !target(tags)
251tags: ${SRCS} _SUBDIR
252 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
253 sed "s;\${.CURDIR}/;;" > tags
254.endif
255
256.if !defined(NOMAN)
257.include <bsd.man.mk>
258.elif !target(maninstall)
259maninstall:
260all-man:
261.endif
262
263.include <bsd.dep.mk>
264.include <bsd.libnames.mk>
265.include <bsd.obj.mk>
125
126OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
127
128lib${LIB}.a:: ${OBJS}
129 @${ECHO} building standard ${LIB} library
130 @rm -f lib${LIB}.a
131 @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q` ${ARADD}
132 ${RANLIB} lib${LIB}.a
133
134.if !defined(NOPROFILE)
135POBJS+= ${OBJS:.o=.po}
136lib${LIB}_p.a:: ${POBJS}
137 @${ECHO} building profiled ${LIB} library
138 @rm -f lib${LIB}_p.a
139 @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q` ${ARADD}
140 ${RANLIB} lib${LIB}_p.a
141.endif
142
143.if defined(DESTDIR)
144LDDESTDIR?= -L${DESTDIR}/usr/lib
145.endif
146
147.if !defined(NOPIC)
148.if defined(CPLUSPLUSLIB) && !make(clean) && !make(cleandir)
149SOBJS+= ${DESTDIR}/usr/lib/c++rt0.o
150.endif
151
152SOBJS+= ${OBJS:.o=.so}
153lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS}
154 @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
155 @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
156 @${LD} -Bshareable -x \
157 -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
158 `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD}
159
160lib${LIB}_pic.a:: ${SOBJS}
161 @${ECHO} building special pic ${LIB} library
162 @rm -f lib${LIB}_pic.a
163 @${AR} cq lib${LIB}_pic.a ${SOBJS} ${ARADD}
164 ${RANLIB} lib${LIB}_pic.a
165.endif
166
167llib-l${LIB}.ln: ${SRCS}
168 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
169
170.if !target(clean)
171clean: _SUBDIR
172 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS}
173 rm -f lib${LIB}.a llib-l${LIB}.ln
174 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a
175 rm -f ${SOBJS} shared/*.o
176 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a
177.if defined(CLEANDIRS) && !empty(CLEANDIRS)
178 rm -rf ${CLEANDIRS}
179.endif
180.endif
181
182.if defined(SRCS)
183afterdepend:
184 @(TMP=/tmp/_depend$$$$; \
185 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' < .depend > $$TMP; \
186 mv $$TMP .depend)
187.endif
188
189.if !target(install)
190.if !target(beforeinstall)
191beforeinstall:
192.endif
193
194.if defined(PRECIOUSLIB)
195SHLINSTALLFLAGS+= -fschg
196.endif
197
198realinstall: beforeinstall
199.if !defined(INTERNALLIB)
200 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
201 ${INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
202.if !defined(NOPROFILE)
203 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
204 ${INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
205.endif
206.endif
207.if !defined(NOPIC)
208.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
209 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
210 ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \
211 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
212 ${DESTDIR}${SHLIBDIR}
213.endif
214.if defined(INSTALL_PIC_ARCHIVE)
215 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
216 ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
217.endif
218.endif
219.if defined(LINKS) && !empty(LINKS)
220 @set ${LINKS}; \
221 while test $$# -ge 2; do \
222 l=${DESTDIR}$$1; \
223 shift; \
224 t=${DESTDIR}$$1; \
225 shift; \
226 ${ECHO} $$t -\> $$l; \
227 rm -f $$t; \
228 ln ${LN_FLAGS} $$l $$t; \
229 done; true
230.endif
231
232install: afterinstall _SUBDIR
233.if !defined(NOMAN)
234afterinstall: realinstall maninstall
235.else
236afterinstall: realinstall
237.endif
238.endif
239
240DISTRIBUTION?= bin
241.if !target(distribute)
242distribute: _SUBDIR
243 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
244.endif
245
246.if !target(lint)
247lint:
248.endif
249
250.if !target(tags)
251tags: ${SRCS} _SUBDIR
252 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
253 sed "s;\${.CURDIR}/;;" > tags
254.endif
255
256.if !defined(NOMAN)
257.include <bsd.man.mk>
258.elif !target(maninstall)
259maninstall:
260all-man:
261.endif
262
263.include <bsd.dep.mk>
264.include <bsd.libnames.mk>
265.include <bsd.obj.mk>