Annotation of src/share/mk/bsd.lib.mk, Revision 1.21
1.21 ! niklas 1: # $OpenBSD: bsd.lib.mk,v 1.20 1999/05/26 19:10:28 espie Exp $
1.5 mickey 2: # $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $
1.1 deraadt 3: # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
4:
5: .if exists(${.CURDIR}/../Makefile.inc)
6: .include "${.CURDIR}/../Makefile.inc"
7: .endif
8:
9: .include <bsd.own.mk> # for 'NOPIC' definition
10:
11: .if exists(${.CURDIR}/shlib_version)
12: SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
13: SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
14: .endif
15:
16: .MAIN: all
17:
18: # prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
19: # .so used for PIC object files. .ln used for lint output files.
1.20 espie 20: # .m for objective c files.
1.1 deraadt 21: .SUFFIXES:
1.21 ! niklas 22: .SUFFIXES: .out .o .go .po .so .S .s .c .cc .C .cxx .f .y .l .ln .m4 .m
1.1 deraadt 23:
24: .c.o:
1.14 grr 25: @echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
1.1 deraadt 26: @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
27: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
28: @rm -f ${.TARGET}.o
29:
1.21 ! niklas 30: .c.go:
! 31: @echo "${COMPILE.c} -g ${.IMPSRC} -o ${.TARGET}"
! 32: @${COMPILE.c} -g ${.IMPSRC} -o ${.TARGET}.o
! 33: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
! 34: @rm -f ${.TARGET}.o
! 35:
1.1 deraadt 36: .c.po:
37: @echo "${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}"
38: @${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}.o
39: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
40: @rm -f ${.TARGET}.o
41:
42: .c.so:
43: @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
44: @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
45: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
46: @rm -f ${.TARGET}.o
47:
48: .c.ln:
49: ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
50:
1.16 deraadt 51: .cc.o .C.o .cxx.o:
1.19 espie 52: @echo "${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}"
1.1 deraadt 53: @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
54: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
55: @rm -f ${.TARGET}.o
56:
1.21 ! niklas 57: .cc.go .C.go .cxx.go:
! 58: @echo "${COMPILE.cc} -g ${.IMPSRC} -o ${.TARGET}"
! 59: @${COMPILE.cc} -g ${.IMPSRC} -o ${.TARGET}.o
! 60: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
! 61: @rm -f ${.TARGET}.o
! 62:
1.16 deraadt 63: .cc.po .C.po .cxx.po:
1.1 deraadt 64: @echo "${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}"
65: @${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}.o
66: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
67: @rm -f ${.TARGET}.o
68:
1.16 deraadt 69: .cc.so .C.so .cxx.so:
1.1 deraadt 70: @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
71: @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
72: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
73: @rm -f ${.TARGET}.o
74:
75: .S.o .s.o:
76: @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
77: ${AS} -o ${.TARGET}"
78: @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
79: ${AS} -o ${.TARGET}.o
80: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
81: @rm -f ${.TARGET}.o
82:
1.21 ! niklas 83: .S.go .s.go:
! 84: @echo "${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
! 85: ${AS} -o ${.TARGET}"
! 86: @${CPP} ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
! 87: ${AS} -o ${.TARGET}.o
! 88: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
! 89: @rm -f ${.TARGET}.o
! 90:
1.1 deraadt 91: .S.po .s.po:
92: @echo "${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} |\
93: ${AS} -o ${.TARGET}"
94: @${CPP} -DPROF ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
95: ${AS} -o ${.TARGET}.o
96: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
97: @rm -f ${.TARGET}.o
98:
99: .S.so .s.so:
100: @echo "${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
101: ${AS} -k -o ${.TARGET}"
102: @${CPP} -DPIC ${CPPFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
103: ${AS} -k -o ${.TARGET}.o
104: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
105: @rm -f ${.TARGET}.o
1.7 deraadt 106:
1.18 millert 107: CFLAGS+= ${COPTS}
1.1 deraadt 108:
1.6 pefo 109: .if !defined(PICFLAG) && (${MACHINE_ARCH} != "mips")
1.1 deraadt 110: PICFLAG=-fpic
1.15 niklas 111: .if ${MACHINE_ARCH} == "m68k"
112: # Function CSE makes gas -k not recognize external function calls as lazily
113: # resolvable symbols, thus sometimes making ld.so report undefined symbol
114: # errors on symbols found in shared library members that would never be
115: # called. Ask niklas@openbsd.org for details.
116: PICFLAG+=-fno-function-cse
117: .endif
1.1 deraadt 118: .endif
119:
1.21 ! niklas 120: _LIBS=lib${LIB}.a
! 121: .if defined(DEBUGLIBS)
! 122: _LIBS+=lib${LIB}_g.a
! 123: .endif
1.1 deraadt 124: .if !defined(NOPROFILE)
1.21 ! niklas 125: _LIBS+=lib${LIB}_p.a
1.1 deraadt 126: .endif
127:
128: .if !defined(NOPIC)
1.6 pefo 129: .if (${MACHINE_ARCH} != "mips")
1.1 deraadt 130: _LIBS+=lib${LIB}_pic.a
1.6 pefo 131: .endif
1.1 deraadt 132: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
133: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
134: .endif
135: .endif
136:
137: .if !defined(NOLINT)
138: _LIBS+=llib-l${LIB}.ln
139: .endif
140:
141: all: ${_LIBS} _SUBDIRUSE
142:
143: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
144:
145: lib${LIB}.a:: ${OBJS}
146: @echo building standard ${LIB} library
147: @rm -f lib${LIB}.a
1.12 niklas 148: @${AR} cq lib${LIB}.a `${LORDER} ${OBJS} | tsort -q`
1.1 deraadt 149: ${RANLIB} lib${LIB}.a
150:
1.21 ! niklas 151: GOBJS+= ${OBJS:.o=.go}
! 152: lib${LIB}_g.a:: ${GOBJS}
! 153: @echo building debugging ${LIB} library
! 154: @rm -f lib${LIB}_g.a
! 155: @${AR} cq lib${LIB}_g.a `${LORDER} ${GOBJS} | tsort -q`
! 156: ${RANLIB} lib${LIB}_g.a
! 157:
1.1 deraadt 158: POBJS+= ${OBJS:.o=.po}
159: lib${LIB}_p.a:: ${POBJS}
160: @echo building profiled ${LIB} library
161: @rm -f lib${LIB}_p.a
1.12 niklas 162: @${AR} cq lib${LIB}_p.a `${LORDER} ${POBJS} | tsort -q`
1.1 deraadt 163: ${RANLIB} lib${LIB}_p.a
164:
165: SOBJS+= ${OBJS:.o=.so}
166: lib${LIB}_pic.a:: ${SOBJS}
167: @echo building shared object ${LIB} library
168: @rm -f lib${LIB}_pic.a
1.12 niklas 169: @${AR} cq lib${LIB}_pic.a `${LORDER} ${SOBJS} | tsort -q`
1.1 deraadt 170: ${RANLIB} lib${LIB}_pic.a
171:
1.6 pefo 172: .if (${MACHINE_ARCH} != "mips")
1.1 deraadt 173: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
174: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
175: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
176: $(LD) -x -Bshareable -Bforcearchive \
177: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
1.6 pefo 178: .else
179: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.a ${DPADD}
180: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
181: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
182: $(LD) -x -shared --whole-archive -soname lib${LIB}.so.${SHLIB_MAJOR} \
183: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}.a ${LDADD}
184: .endif
1.1 deraadt 185:
186: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
187: # the following looks XXX to me... -- cgd
188: LLIBS?= -lc
189: llib-l${LIB}.ln: ${LOBJS}
190: @echo building llib-l${LIB}.ln
191: @rm -f llib-l${LIB}.ln
192: @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
193:
194: .if !target(clean)
195: clean: _SUBDIRUSE
196: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
197: rm -f lib${LIB}.a ${OBJS}
1.21 ! niklas 198: rm -f lib${LIB}_g.a ${GOBJS}
1.1 deraadt 199: rm -f lib${LIB}_p.a ${POBJS}
200: rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
201: rm -f llib-l${LIB}.ln ${LOBJS}
202: .endif
203:
204: cleandir: _SUBDIRUSE clean
205:
206: .if defined(SRCS)
207: afterdepend: .depend
1.11 deraadt 208: @(TMP=`mktemp -q /tmp/_dependXXXXXXXXXX`; \
209: if [ $$? -ne 0 ]; then \
210: echo "$$0: cannot create temp file, exiting..."; \
211: exit 1; \
212: fi; \
213: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
1.1 deraadt 214: < .depend > $$TMP; \
1.11 deraadt 215: mv $$TMP .depend)
1.1 deraadt 216: .endif
217:
218: .if !target(install)
219: .if !target(beforeinstall)
220: beforeinstall:
221: .endif
222:
223: realinstall:
224: # ranlib lib${LIB}.a
1.13 millert 225: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.1 deraadt 226: ${DESTDIR}${LIBDIR}
1.13 millert 227: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 228: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.8 millert 229: .endif
1.1 deraadt 230: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.21 ! niklas 231: .if defined(DEBUGLIBS)
! 232: # ranlib lib${LIB}_g.a
! 233: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
! 234: lib${LIB}_g.a ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
! 235: .if (${INSTALL_COPY} != "-p")
! 236: ${RANLIB} -t ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
! 237: .endif
! 238: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/debug/lib${LIB}.a
! 239: .endif
1.1 deraadt 240: .if !defined(NOPROFILE)
241: # ranlib lib${LIB}_p.a
1.13 millert 242: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 243: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
1.13 millert 244: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 245: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8 millert 246: .endif
1.1 deraadt 247: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
248: .endif
1.6 pefo 249: .if !defined(NOPIC) && (${MACHINE_ARCH} != "mips")
1.1 deraadt 250: # ranlib lib${LIB}_pic.a
1.13 millert 251: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 deraadt 252: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
1.13 millert 253: .if (${INSTALL_COPY} != "-p")
1.1 deraadt 254: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.8 millert 255: .endif
1.1 deraadt 256: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
257: .endif
258: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.13 millert 259: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 deraadt 260: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
261: .endif
262: .if !defined(NOLINT)
1.13 millert 263: ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 deraadt 264: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
265: .endif
266: .if defined(LINKS) && !empty(LINKS)
267: @set ${LINKS}; \
268: while test $$# -ge 2; do \
1.9 mickey 269: l=${DESTDIR}${BINDIR}/$$1; \
1.1 deraadt 270: shift; \
1.9 mickey 271: t=${DESTDIR}${BINDIR}/$$1; \
1.1 deraadt 272: shift; \
273: echo $$t -\> $$l; \
274: rm -f $$t; \
275: ln $$l $$t; \
276: done; true
277: .endif
278:
279: install: maninstall _SUBDIRUSE
280: maninstall: afterinstall
281: afterinstall: realinstall
282: realinstall: beforeinstall
283: .endif
284:
285: .if !defined(NOMAN)
286: .include <bsd.man.mk>
287: .endif
288:
289: .if !defined(NONLS)
290: .include <bsd.nls.mk>
291: .endif
292:
293: .include <bsd.obj.mk>
294: .include <bsd.dep.mk>
295: .include <bsd.subdir.mk>
1.2 deraadt 296: .include <bsd.sys.mk>