Annotation of src/share/mk/bsd.lib.mk, Revision 1.288
1.288 ! christos 1: # $NetBSD: bsd.lib.mk,v 1.287 2008/10/17 17:29:39 christos Exp $
1.92 mikel 2: # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
1.1 cgd 3:
1.188 tv 4: .include <bsd.init.mk>
1.207 thorpej 5: .include <bsd.shlib.mk>
1.219 thorpej 6: .include <bsd.gcc.mk>
1.227 lukem 7: # Pull in <bsd.sys.mk> here so we can override its .c.o rule
8: .include <bsd.sys.mk>
1.97 mycroft 9:
1.282 lukem 10: LIBISMODULE?= no
1.281 lukem 11: LIBISPRIVATE?= no
12:
1.282 lukem 13: _LIB_PREFIX= lib
14:
15: .if ${LIBISMODULE} != "no"
16: _LIB_PREFIX= # empty
17: MKDEBUGLIB:= no
18: MKLINT:= no
19: MKPICINSTALL:= no
20: MKPROFILE:= no
21: MKSTATICLIB:= no
22: .endif
23:
1.281 lukem 24: .if ${LIBISPRIVATE} != "no"
1.280 lukem 25: MKDEBUGLIB:= no
26: MKLINT:= no
27: MKPIC:= no
28: MKPROFILE:= no
29: .endif
30:
1.188 tv 31: ##### Basic targets
1.246 lukem 32: .PHONY: checkver libinstall
1.143 erh 33: realinstall: checkver libinstall
1.183 tv 34: clean: cleanlib
1.232 erh 35:
36: ##### LIB specific flags.
1.287 christos 37: # XXX: This is needed for programs that link with .a libraries
38: # Perhaps a more correct solution is to always generate _pic.a
39: # files or always have a shared library.
40: .if defined(MKPIE) && (${MKPIE} != "no")
41: CFLAGS+= ${PIE_CFLAGS}
1.288 ! christos 42: AFLAGS+= ${PIE_AFLAGS}
1.287 christos 43: .endif
1.267 mrg 44: COPTS+= ${COPTS.lib${LIB}}
1.232 erh 45: CPPFLAGS+= ${CPPFLAGS.lib${LIB}}
46: CXXFLAGS+= ${CXXFLAGS.lib${LIB}}
1.267 mrg 47: OBJCOPTS+= ${OBJCOPTS.lib${LIB}}
1.232 erh 48: LDADD+= ${LDADD.lib${LIB}}
1.233 erh 49: LDFLAGS+= ${LDFLAGS.lib${LIB}}
50: LDSTATIC+= ${LDSTATIC.lib${LIB}}
1.1 cgd 51:
1.256 lukem 52: ##### Libraries that this may depend upon.
53: .if defined(LIBDPLIBS) && ${MKPIC} != "no" # {
54: .for _lib _dir in ${LIBDPLIBS}
55: .if !defined(LIBDO.${_lib})
56: LIBDO.${_lib}!= cd ${_dir} && ${PRINTOBJDIR}
57: .MAKEOVERRIDES+=LIBDO.${_lib}
58: .endif
59: LDADD+= -L${LIBDO.${_lib}} -l${_lib}
60: DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so
61: .endfor
62: .endif # }
63:
1.188 tv 64: ##### Build and install rules
1.285 christos 65: MKDEP_SUFFIXES?= .o .po .so .go .ln
1.192 thorpej 66: CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.225 mrg 67: CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
1.190 tv 68:
1.252 lukem 69: .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # {
1.154 simonb 70: SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
71: SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
1.171 christos 72: SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
1.143 erh 73:
74: # Check for higher installed library versions.
1.145 erh 75: .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
1.201 lukem 76: exists(${NETBSDSRCDIR}/lib/checkver)
1.143 erh 77: checkver:
1.144 erh 78: @(cd ${.CURDIR} && \
1.239 lukem 79: ${HOST_SH} ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
1.195 lukem 80: -d ${DESTDIR}${_LIBSODIR} ${LIB})
1.173 christos 81: .endif
1.252 lukem 82: .endif # }
1.173 christos 83:
84: .if !target(checkver)
1.143 erh 85: checkver:
86: .endif
1.173 christos 87:
1.169 thorpej 88: print-shlib-major:
1.185 tv 89: .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
1.169 thorpej 90: @echo ${SHLIB_MAJOR}
1.173 christos 91: .else
92: @false
93: .endif
1.169 thorpej 94:
95: print-shlib-minor:
1.185 tv 96: .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
1.169 thorpej 97: @echo ${SHLIB_MINOR}
1.173 christos 98: .else
99: @false
100: .endif
1.171 christos 101:
102: print-shlib-teeny:
1.185 tv 103: .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
1.171 christos 104: @echo ${SHLIB_TEENY}
1.143 erh 105: .else
1.169 thorpej 106: @false
1.173 christos 107: .endif
1.169 thorpej 108:
1.252 lukem 109: .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) # {
1.173 christos 110: .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
111: .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
112: SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
113: .else
114: SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
115: .endif
116: .else
117: SHLIB_FULLVERSION=${SHLIB_MAJOR}
118: .endif
1.252 lukem 119: .endif # }
1.1 cgd 120:
1.101 mycroft 121: # add additional suffixes not exported.
122: # .po is used for profiling object files.
123: # .so is used for PIC object files.
1.266 christos 124: .SUFFIXES: .out .a .ln .so .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
1.118 lukem 125: .SUFFIXES: .sh .m4 .m
1.82 mikel 126:
1.86 jonathan 127:
128: # Set PICFLAGS to cc flags for producing position-independent code,
129: # if not already set. Includes -DPIC, if required.
130:
1.164 simonb 131: # Data-driven table using make variables to control how shared libraries
1.86 jonathan 132: # are built for different platforms and object formats.
1.125 jonathan 133: # OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
1.164 simonb 134: # SHLIB_SOVERSION: version number to be compiled into a shared library
135: # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
1.173 christos 136: # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
137: # [.${SHLIB_TEENY}]]
1.164 simonb 138: # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
1.123 jonathan 139: # with ELF, also set shared-lib version for ld.so.
140: # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
141: # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
1.179 dmcmahil 142: # FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
1.271 tsutsui 143: # CPPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
1.205 yamt 144: # CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
145: # CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
146: # (usually includes ${CPICFLAGS})
147: # CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
1.107 jonathan 148: # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
1.164 simonb 149: # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
1.86 jonathan 150:
1.252 lukem 151: .if ${MACHINE_ARCH} == "alpha" # {
1.209 thorpej 152:
1.179 dmcmahil 153: FPICFLAGS ?= -fPIC
1.165 dmcmahil 154: CPICFLAGS ?= -fPIC -DPIC
1.222 lukem 155: CPPPICFLAGS?= -DPIC
1.107 jonathan 156: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
157: APICFLAGS ?=
1.209 thorpej 158:
1.175 mrg 159: .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
1.252 lukem 160: ${OBJECT_FMT} == "ELF" # } {
1.209 thorpej 161:
1.222 lukem 162: # If you use -fPIC you need to define BIGPIC to turn on 32-bit
1.202 eeh 163: # relocations in asm code
1.179 dmcmahil 164: FPICFLAGS ?= -fPIC
1.165 dmcmahil 165: CPICFLAGS ?= -fPIC -DPIC
1.202 eeh 166: CPPPICFLAGS?= -DPIC -DBIGPIC
1.150 christos 167: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
1.203 eeh 168: APICFLAGS ?= -KPIC
1.204 fredette 169:
1.252 lukem 170: .else # } {
1.86 jonathan 171:
1.244 skrll 172: # Platform-independent flags for NetBSD shared libraries
1.171 christos 173: SHLIB_SOVERSION=${SHLIB_FULLVERSION}
1.125 jonathan 174: SHLIB_SHFLAGS=
1.179 dmcmahil 175: FPICFLAGS ?= -fPIC
1.165 dmcmahil 176: CPICFLAGS?= -fPIC -DPIC
1.222 lukem 177: CPPPICFLAGS?= -DPIC
1.107 jonathan 178: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
179: APICFLAGS?= -k
1.86 jonathan 180:
1.252 lukem 181: .endif # }
1.160 simonb 182:
1.205 yamt 183: .if ${MKPICLIB} != "no"
184: CSHLIBFLAGS+= ${CPICFLAGS}
185: .endif
186:
187: .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
188: MKSHLIBOBJS= yes
189: .else
190: MKSHLIBOBJS= no
191: .endif
192:
1.123 jonathan 193: # Platform-independent linker flags for ELF shared libraries
1.148 lukem 194: .if ${OBJECT_FMT} == "ELF"
1.182 mrg 195: SHLIB_SOVERSION= ${SHLIB_MAJOR}
1.282 lukem 196: SHLIB_SHFLAGS= -Wl,-soname,${_LIB_PREFIX}${LIB}.so.${SHLIB_SOVERSION}
1.272 christos 197: SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel
1.219 thorpej 198: SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
199: SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
1.123 jonathan 200: .endif
1.86 jonathan 201:
1.82 mikel 202: CFLAGS+= ${COPTS}
1.267 mrg 203: OBJCFLAGS+= ${OBJCOPTS}
1.257 simonb 204: AFLAGS+= ${COPTS}
1.179 dmcmahil 205: FFLAGS+= ${FOPTS}
1.1 cgd 206:
207: .c.o:
1.238 lukem 208: ${_MKTARGET_COMPILE}
1.263 dsl 209: ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.270 martin 210: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 211: ${OBJCOPY} -x ${.TARGET}
1.153 christos 212: .endif
1.1 cgd 213:
214: .c.po:
1.238 lukem 215: ${_MKTARGET_COMPILE}
1.263 dsl 216: ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
1.270 martin 217: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 218: ${OBJCOPY} -X ${.TARGET}
1.153 christos 219: .endif
1.17 mycroft 220:
1.266 christos 221: .c.go:
222: ${_MKTARGET_COMPILE}
223: ${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
224:
1.27 pk 225: .c.so:
1.238 lukem 226: ${_MKTARGET_COMPILE}
1.263 dsl 227: ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.270 martin 228: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 229: ${OBJCOPY} -x ${.TARGET}
1.153 christos 230: .endif
1.27 pk 231:
1.223 lukem 232: .cc.o .cpp.o .cxx.o .C.o:
1.238 lukem 233: ${_MKTARGET_COMPILE}
1.263 dsl 234: ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.270 martin 235: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 236: ${OBJCOPY} -x ${.TARGET}
1.153 christos 237: .endif
1.17 mycroft 238:
1.266 christos 239: .cc.po .cpp.po .cxx.po .C.po:
1.238 lukem 240: ${_MKTARGET_COMPILE}
1.263 dsl 241: ${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
1.270 martin 242: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 243: ${OBJCOPY} -X ${.TARGET}
1.153 christos 244: .endif
1.28 cgd 245:
1.266 christos 246: .cc.go .cpp.go .cxx.go .C.go:
247: ${_MKTARGET_COMPILE}
248: ${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
249:
1.223 lukem 250: .cc.so .cpp.so .cxx.so .C.so:
1.238 lukem 251: ${_MKTARGET_COMPILE}
1.263 dsl 252: ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.270 martin 253: .if !defined(CFLAGS) || empty(CFLAGS:M*-g*)
1.263 dsl 254: ${OBJCOPY} -x ${.TARGET}
1.153 christos 255: .endif
1.118 lukem 256:
1.179 dmcmahil 257: .f.o:
1.238 lukem 258: ${_MKTARGET_COMPILE}
1.263 dsl 259: ${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
260: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
261: ${OBJCOPY} -x ${.TARGET}
1.179 dmcmahil 262: .endif
263:
264: .f.po:
1.238 lukem 265: ${_MKTARGET_COMPILE}
1.263 dsl 266: ${COMPILE.f} ${PROFFLAGS} -pg ${.IMPSRC} -o ${.TARGET}
267: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
268: ${OBJCOPY} -X ${.TARGET}
1.179 dmcmahil 269: .endif
270:
1.266 christos 271: .f.go:
272: ${_MKTARGET_COMPILE}
273: ${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
274:
1.179 dmcmahil 275: .f.so:
1.238 lukem 276: ${_MKTARGET_COMPILE}
1.263 dsl 277: ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
278: .if !defined(FOPTS) || empty(FOPTS:M*-g*)
279: ${OBJCOPY} -x ${.TARGET}
1.179 dmcmahil 280: .endif
281:
282: .f.ln:
1.238 lukem 283: ${_MKTARGET_COMPILE}
1.217 wiz 284: @echo Skipping lint for Fortran libraries.
1.179 dmcmahil 285:
1.118 lukem 286: .m.o:
1.238 lukem 287: ${_MKTARGET_COMPILE}
1.267 mrg 288: ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263 dsl 289: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
290: ${OBJCOPY} -x ${.TARGET}
1.153 christos 291: .endif
1.118 lukem 292:
293: .m.po:
1.238 lukem 294: ${_MKTARGET_COMPILE}
1.267 mrg 295: ${COMPILE.m} ${PROFFLAGS} -pg ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263 dsl 296: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
297: ${OBJCOPY} -X ${.TARGET}
1.153 christos 298: .endif
1.118 lukem 299:
1.266 christos 300: .m.go:
301: ${_MKTARGET_COMPILE}
1.267 mrg 302: ${COMPILE.m} ${DEBUGFLAGS} -g ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.266 christos 303: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
304: ${OBJCOPY} -X ${.TARGET}
305: .endif
306:
1.118 lukem 307: .m.so:
1.238 lukem 308: ${_MKTARGET_COMPILE}
1.267 mrg 309: ${COMPILE.m} ${CSHLIBFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
1.263 dsl 310: .if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
311: ${OBJCOPY} -x ${.TARGET}
1.153 christos 312: .endif
1.1 cgd 313:
1.251 lukem 314: .s.o:
1.238 lukem 315: ${_MKTARGET_COMPILE}
1.263 dsl 316: ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
317: ${OBJCOPY} -x ${.TARGET}
1.1 cgd 318:
1.251 lukem 319: .S.o:
320: ${_MKTARGET_COMPILE}
1.263 dsl 321: ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
322: ${OBJCOPY} -x ${.TARGET}
1.251 lukem 323:
324: .s.po:
325: ${_MKTARGET_COMPILE}
1.263 dsl 326: ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
327: ${OBJCOPY} -X ${.TARGET}
1.251 lukem 328:
329: .S.po:
1.238 lukem 330: ${_MKTARGET_COMPILE}
1.263 dsl 331: ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
332: ${OBJCOPY} -X ${.TARGET}
1.1 cgd 333:
1.266 christos 334: .s.go:
335: ${_MKTARGET_COMPILE}
336: ${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
337:
338: .S.go:
339: ${_MKTARGET_COMPILE}
340: ${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
341:
1.251 lukem 342: .s.so:
343: ${_MKTARGET_COMPILE}
1.263 dsl 344: ${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
345: ${OBJCOPY} -x ${.TARGET}
1.251 lukem 346:
347: .S.so:
1.238 lukem 348: ${_MKTARGET_COMPILE}
1.263 dsl 349: ${COMPILE.S} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
350: ${OBJCOPY} -x ${.TARGET}
1.27 pk 351:
1.252 lukem 352: .if defined(LIB) # {
1.234 lukem 353: .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
354: || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
1.130 tv 355: _LIBS=lib${LIB}.a
356: .else
357: _LIBS=
358: .endif
1.58 cgd 359:
1.167 matt 360: OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.158 christos 361:
1.255 thorpej 362: STOBJS+=${OBJS}
363:
1.280 lukem 364: LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
365:
1.281 lukem 366: .if ${LIBISPRIVATE} != "no"
1.252 lukem 367: # No installation is required
368: libinstall::
1.281 lukem 369: .else # ${LIBISPRIVATE} == "no" # {
1.252 lukem 370:
1.268 lukem 371: .if ${MKDEBUGLIB} != "no"
1.266 christos 372: _LIBS+=lib${LIB}_g.a
373: GOBJS+=${OBJS:.o=.go}
374: DEBUGFLAGS?=-DDEBUG
375: .endif
376:
1.149 lukem 377: .if ${MKPROFILE} != "no"
1.130 tv 378: _LIBS+=lib${LIB}_p.a
1.167 matt 379: POBJS+=${OBJS:.o=.po}
1.262 christos 380: PROFFLAGS?=-DGPROF -DPROF
1.1 cgd 381: .endif
382:
1.252 lukem 383: .if ${MKPIC} != "no" # {
1.160 simonb 384: .if ${MKPICLIB} == "no"
1.205 yamt 385: .if ${MKSHLIBOBJS} != "no"
386: # make _pic.a, which isn't really pic,
387: # since it's needed for making shared lib.
388: # but don't install it.
389: SOLIB=lib${LIB}_pic.a
390: SOBJS+=${OBJS:.o=.so}
391: .else
1.160 simonb 392: SOLIB=lib${LIB}.a
1.205 yamt 393: .endif
1.160 simonb 394: .else
395: SOLIB=lib${LIB}_pic.a
396: _LIBS+=${SOLIB}
1.167 matt 397: SOBJS+=${OBJS:.o=.so}
1.160 simonb 398: .endif
1.171 christos 399: .if defined(SHLIB_FULLVERSION)
400: _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
1.27 pk 401: .endif
1.252 lukem 402: .endif # }
1.27 pk 403:
1.279 lukem 404: .if ${MKLINT} != "no" && !empty(LOBJS)
1.58 cgd 405: _LIBS+=llib-l${LIB}.ln
1.215 christos 406: .endif
1.27 pk 407:
1.281 lukem 408: .endif # ${LIBISPRIVATE} == "no" # }
1.252 lukem 409:
1.234 lukem 410: ALLOBJS=
411: .if (${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
412: || ${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
1.255 thorpej 413: ALLOBJS+=${STOBJS}
1.179 dmcmahil 414: .endif
1.234 lukem 415: ALLOBJS+=${POBJS} ${SOBJS}
1.279 lukem 416: .if ${MKLINT} != "no" && !empty(LOBJS)
1.179 dmcmahil 417: ALLOBJS+=${LOBJS}
1.216 christos 418: .endif
1.252 lukem 419: .else # !defined(LIB) # } {
1.216 christos 420: LOBJS=
421: SOBJS=
1.252 lukem 422: .endif # !defined(LIB) # }
1.186 tv 423:
1.254 lukem 424: _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.253 christos 425:
426: .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
1.158 christos 427:
1.162 mycroft 428: realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
1.1 cgd 429:
1.243 rtr 430: .if !target(__archivebuild)
1.90 christos 431: __archivebuild: .USE
1.238 lukem 432: ${_MKTARGET_BUILD}
1.236 lukem 433: rm -f ${.TARGET}
1.228 lukem 434: ${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1.89 christos 435: ${RANLIB} ${.TARGET}
1.243 rtr 436: .endif
1.89 christos 437:
1.243 rtr 438: .if !target(__archiveinstall)
1.89 christos 439: __archiveinstall: .USE
1.238 lukem 440: ${_MKTARGET_INSTALL}
1.198 lukem 441: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.269 dbj 442: ${empty(PRESERVE):?-a "${RANLIB} -t":} ${.ALLSRC} ${.TARGET}
1.243 rtr 443: .endif
1.89 christos 444:
1.197 mycroft 445: __archivesymlinkpic: .USE
1.238 lukem 446: ${_MKTARGET_INSTALL}
1.264 jwise 447: ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
1.197 mycroft 448:
1.253 christos 449: DPSRCS+= ${_YLSRCS}
450: CLEANFILES+= ${_YLSRCS}
1.230 lukem 451:
1.266 christos 452: ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
1.103 mycroft 453:
1.255 thorpej 454: lib${LIB}.a:: ${STOBJS} __archivebuild
1.1 cgd 455:
1.89 christos 456: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1 cgd 457:
1.89 christos 458: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27 pk 459:
1.266 christos 460: lib${LIB}_g.a:: ${GOBJS} __archivebuild
461:
1.235 lukem 462:
463: _LIBLDOPTS=
464: .if ${SHLIBDIR} != "/usr/lib"
465: _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
466: -R${SHLIBDIR} \
467: -L${DESTDIR}${SHLIBDIR}
468: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
469: _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
470: -L${DESTDIR}${SHLIBINSTALLDIR}
471: .endif
472:
1.277 christos 473: # gcc -shared now adds -lc automatically. For libraries other than libc and
474: # libgcc* we add as a dependency the installed shared libc. For libc and
475: # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
476: # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
477: # to add standard libraries, not the linker.
1.276 christos 478: .if !defined(LIB)
1.274 christos 479: DPLIBC ?= ${DESTDIR}${LIBC_SO}
1.276 christos 480: .else
1.278 simonb 481: .if ${LIB} != "c" && ${LIB:Mgcc*} == ""
1.276 christos 482: DPLIBC ?= ${DESTDIR}${LIBC_SO}
1.277 christos 483: .else
1.278 simonb 484: LDLIBC ?= -nodefaultlibs
485: .if ${LIB} == "c"
486: LDADD+= -lgcc_pic
487: .endif
1.276 christos 488: .endif
1.274 christos 489: .endif
490:
491: lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
1.88 cgd 492: ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.238 lukem 493: ${_MKTARGET_BUILD}
1.236 lukem 494: rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
1.152 fair 495: .if defined(DESTDIR)
1.277 christos 496: ${CC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
1.235 lukem 497: ${_LIBLDOPTS} \
1.231 lukem 498: -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
1.221 drochner 499: -Wl,--whole-archive ${SOLIB} \
500: -Wl,--no-whole-archive ${LDADD} \
1.277 christos 501: -L${_GCC_LIBGCCDIR}
1.221 drochner 502: .else
1.277 christos 503: ${CC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \
504: -o ${.TARGET} ${_LIBLDOPTS} \
505: -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
1.152 fair 506: .endif
1.148 lukem 507: .if ${OBJECT_FMT} == "ELF"
1.196 lukem 508: # We don't use INSTALL_SYMLINK here because this is just
509: # happening inside the build directory/objdir. XXX Why does
510: # this spend so much effort on libraries that aren't live??? XXX
1.284 lukem 511: .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
512: "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
1.241 matt 513: ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
1.177 mycroft 514: mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
1.283 lukem 515: .endif
1.241 matt 516: ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
1.177 mycroft 517: mv -f lib${LIB}.so.tmp lib${LIB}.so
1.133 tv 518: .endif
1.286 joerg 519: .if ${MKSTRIPIDENT} != "no"
520: ${OBJCOPY} -R .ident ${.TARGET}
521: .endif
1.35 pk 522:
1.252 lukem 523: .if !empty(LOBJS) # {
1.103 mycroft 524: LLIBS?= -lc
1.58 cgd 525: llib-l${LIB}.ln: ${LOBJS}
1.238 lukem 526: ${_MKTARGET_COMPILE}
1.236 lukem 527: rm -f llib-l${LIB}.ln
1.206 thorpej 528: .if defined(DESTDIR)
1.228 lukem 529: ${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
1.206 thorpej 530: .else
1.228 lukem 531: ${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
1.206 thorpej 532: .endif
1.252 lukem 533: .endif # }
1.1 cgd 534:
1.280 lukem 535: lint: ${LOBJS}
536: .if defined(LOBJS) && !empty(LOBJS)
537: ${LINT} ${LINTFLAGS} ${LOBJS}
538: .endif
539:
1.246 lukem 540: cleanlib: .PHONY
1.48 mycroft 541: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.255 thorpej 542: rm -f lib${LIB}.a ${STOBJS}
1.59 cgd 543: rm -f lib${LIB}_p.a ${POBJS}
1.266 christos 544: rm -f lib${LIB}_g.a ${GOBJS}
1.133 tv 545: rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
1.266 christos 546: rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
1.59 cgd 547: rm -f llib-l${LIB}.ln ${LOBJS}
1.1 cgd 548:
1.252 lukem 549:
550: .if !target(libinstall) # {
1.148 lukem 551: # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
1.139 tv 552: libinstall::
553:
1.234 lukem 554: .if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
1.89 christos 555: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.168 mycroft 556: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.197 mycroft 557:
1.269 dbj 558: .if ${MKUPDATE} == "no"
1.197 mycroft 559: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
560: ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
1.89 christos 561: .endif
1.197 mycroft 562: ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
563: .else
1.157 fredb 564: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
1.89 christos 565: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
566: .endif
567: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
1.130 tv 568: .endif
1.197 mycroft 569: .endif
1.89 christos 570:
1.149 lukem 571: .if ${MKPROFILE} != "no"
1.89 christos 572: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.168 mycroft 573: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.197 mycroft 574:
1.269 dbj 575: .if ${MKUPDATE} == "no"
1.197 mycroft 576: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
577: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
1.32 pk 578: .endif
1.197 mycroft 579: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
580: .else
1.157 fredb 581: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
1.89 christos 582: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
583: .endif
584: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
585: .endif
1.197 mycroft 586: .endif
1.89 christos 587:
1.268 lukem 588: .if ${MKDEBUGLIB} != "no"
1.266 christos 589: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
590: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
591:
1.269 dbj 592: .if ${MKUPDATE} == "no"
1.266 christos 593: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
594: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
595: .endif
596: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
597: .else
598: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
599: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
600: .endif
601: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
602: .endif
603: .endif
604:
1.149 lukem 605: .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
1.168 mycroft 606: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.160 simonb 607: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.197 mycroft 608:
1.269 dbj 609: .if ${MKUPDATE} == "no"
1.197 mycroft 610: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
611: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
1.89 christos 612: .endif
1.197 mycroft 613: .if ${MKPICLIB} == "no"
614: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
615: .else
616: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
617: .endif
618: .else
1.157 fredb 619: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
1.89 christos 620: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33 pk 621: .endif
1.160 simonb 622: .if ${MKPICLIB} == "no"
1.197 mycroft 623: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
1.160 simonb 624: .else
1.89 christos 625: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
1.160 simonb 626: .endif
1.89 christos 627: .endif
1.197 mycroft 628: .endif
1.89 christos 629:
1.171 christos 630: .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
1.282 lukem 631: _LIB_SO_TGT= ${DESTDIR}${_LIBSODIR}/${_LIB_PREFIX}${LIB}.so
632: _LIB_SO_TGTLIBDIR= ${DESTDIR}${LIBDIR}/${_LIB_PREFIX}${LIB}.so
633:
634: libinstall:: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}
635: .PRECIOUS: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}
1.197 mycroft 636:
1.269 dbj 637: .if ${MKUPDATE} == "no"
1.197 mycroft 638: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.282 lukem 639: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}! .MADE
1.89 christos 640: .endif
1.282 lukem 641: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
1.197 mycroft 642: .else
1.171 christos 643: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.282 lukem 644: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: .MADE
1.89 christos 645: .endif
1.282 lukem 646: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
1.197 mycroft 647: .endif
1.238 lukem 648: ${_MKTARGET_INSTALL}
1.188 tv 649: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264 jwise 650: ${.ALLSRC} ${.TARGET}
1.195 lukem 651: .if ${_LIBSODIR} != ${LIBDIR}
1.282 lukem 652: ${INSTALL_SYMLINK} -l r \
653: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
654: ${_LIB_SO_TGTLIBDIR}.${SHLIB_FULLVERSION}
1.195 lukem 655: .endif
1.148 lukem 656: .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
1.195 lukem 657: /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
1.146 thorpej 658: .endif
1.148 lukem 659: .if ${OBJECT_FMT} == "ELF"
1.284 lukem 660: .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
661: "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
1.264 jwise 662: ${INSTALL_SYMLINK} \
1.284 lukem 663: ${_LIB_PREFIX}${LIB}.so.${SHLIB_FULLVERSION} \
1.282 lukem 664: ${_LIB_SO_TGT}.${SHLIB_MAJOR}
1.195 lukem 665: .if ${_LIBSODIR} != ${LIBDIR}
1.282 lukem 666: ${INSTALL_SYMLINK} -l r \
667: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
668: ${_LIB_SO_TGTLIBDIR}.${SHLIB_MAJOR}
1.195 lukem 669: .endif
1.284 lukem 670: .endif
1.148 lukem 671: .if ${MKLINKLIB} != "no"
1.264 jwise 672: ${INSTALL_SYMLINK} \
1.284 lukem 673: ${_LIB_PREFIX}${LIB}.so.${SHLIB_FULLVERSION} \
1.282 lukem 674: ${_LIB_SO_TGT}
1.195 lukem 675: .if ${_LIBSODIR} != ${LIBDIR}
1.282 lukem 676: ${INSTALL_SYMLINK} -l r \
677: ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \
678: ${_LIB_SO_TGTLIBDIR}
1.195 lukem 679: .endif
1.83 cgd 680: .endif
1.12 cgd 681: .endif
1.139 tv 682: .endif
1.89 christos 683:
1.279 lukem 684: .if ${MKLINT} != "no" && !empty(LOBJS)
1.89 christos 685: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.168 mycroft 686: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.197 mycroft 687:
1.269 dbj 688: .if ${MKUPDATE} == "no"
1.197 mycroft 689: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
690: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
1.89 christos 691: .endif
1.197 mycroft 692: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
693: .else
1.157 fredb 694: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
1.89 christos 695: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
696: .endif
1.95 mycroft 697: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.197 mycroft 698: .endif
1.238 lukem 699: ${_MKTARGET_INSTALL}
1.188 tv 700: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.264 jwise 701: ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
1.58 cgd 702: .endif
1.252 lukem 703: .endif # !target(libinstall) # }
1.1 cgd 704:
1.188 tv 705: ##### Pull in related .mk logic
1.1 cgd 706: .include <bsd.man.mk>
1.57 jtc 707: .include <bsd.nls.mk>
1.91 christos 708: .include <bsd.files.mk>
1.89 christos 709: .include <bsd.inc.mk>
1.109 cjs 710: .include <bsd.links.mk>
1.24 mycroft 711: .include <bsd.dep.mk>
1.117 mycroft 712:
1.188 tv 713: ${TARGETS}: # ensure existence
CVSweb <webmaster@jp.NetBSD.org>