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