bsd.lib.mk revision 119730
116359Sasami# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 216359Sasami# $FreeBSD: head/share/mk/bsd.lib.mk 119730 2003-09-04 04:29:11Z peter $ 316359Sasami# 416359Sasami 516359Sasami.include <bsd.init.mk> 616359Sasami 716359Sasami# Set up the variables controlling shared libraries. After this section, 816359Sasami# SHLIB_NAME will be defined only if we are to create a shared library. 916359Sasami# SHLIB_LINK will be defined only if we are to create a link to it. 1016359Sasami# INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive. 1116359Sasami.if defined(NOPIC) 1216359Sasami.undef SHLIB_NAME 1316359Sasami.undef INSTALL_PIC_ARCHIVE 1416359Sasami.else 1516359Sasami.if !defined(SHLIB_NAME) && defined(LIB) && defined(SHLIB_MAJOR) 1616359SasamiSHLIB_NAME= lib${LIB}.so.${SHLIB_MAJOR} 1716359Sasami.endif 1816359Sasami.if defined(SHLIB_NAME) && ${SHLIB_NAME:M*.so.*} 1916359SasamiSHLIB_LINK?= ${SHLIB_NAME:R} 2016359Sasami.endif 2116359SasamiSONAME?= ${SHLIB_NAME} 2216359Sasami.endif 2316359Sasami 2416359Sasami.if defined(CRUNCH_CFLAGS) 2516359SasamiCFLAGS+= ${CRUNCH_CFLAGS} 2616359Sasami.endif 2716359Sasami 2816359Sasami.if defined(DEBUG_FLAGS) 2916359SasamiCFLAGS+= ${DEBUG_FLAGS} 3016359Sasami.endif 3116359Sasami 3216359Sasami.if !defined(DEBUG_FLAGS) 3316359SasamiSTRIP?= -s 3418846Sasami.endif 3516359Sasami 3616359Sasami.include <bsd.libnames.mk> 3716359Sasami 3816359Sasami# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries 3916359Sasami# .So used for PIC object files 4016359Sasami.SUFFIXES: 4116359Sasami.SUFFIXES: .out .o .po .So .S .asm .s .c .cc .cpp .cxx .m .C .f .y .l .ln 4216359Sasami 4316359Sasami.if !defined(PICFLAG) 4416359Sasami.if ${MACHINE_ARCH} == "sparc64" 4516359SasamiPICFLAG=-fPIC 4616359Sasami.else 4716359SasamiPICFLAG=-fpic 4816359Sasami.endif 4916359Sasami.endif 5016359Sasami 5116359Sasami.c.po: 5216359Sasami ${CC} -pg ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 5316359Sasami 5416359Sasami.c.So: 5516359Sasami ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 5616359Sasami 5716359Sasami.cc.po .C.po .cpp.po .cxx.po: 5816359Sasami ${CXX} -pg ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 5916359Sasami 6016359Sasami.cc.So .C.So .cpp.So .cxx.So: 6116359Sasami ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 6216359Sasami 6316359Sasami.f.po: 6416359Sasami ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 6516359Sasami 6616359Sasami.f.So: 6716359Sasami ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 6816359Sasami 6916359Sasami.m.po: 7016359Sasami ${OBJC} ${OBJCFLAGS} -pg -c ${.IMPSRC} -o ${.TARGET} 7116359Sasami 7216359Sasami.m.So: 7316359Sasami ${OBJC} ${PICFLAG} -DPIC ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} 7416359Sasami 7516359Sasami.s.po .s.So: 7616359Sasami ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 7716359Sasami 7816359Sasami.asm.po: 7916359Sasami ${CC} -x assembler-with-cpp -DPROF ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 8016359Sasami 8116359Sasami.asm.So: 8216359Sasami ${CC} -x assembler-with-cpp ${PICFLAG} -DPIC ${CFLAGS} \ 8316359Sasami -c ${.IMPSRC} -o ${.TARGET} 8416359Sasami 8516359Sasami.S.po: 8616359Sasami ${CC} -DPROF ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 8716359Sasami 8816359Sasami.S.So: 8916359Sasami ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 9016359Sasami 9116359Sasamiall: objwarn 9216359Sasami 9316359Sasami.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) 9416359SasamiOBJS+= ${SRCS:N*.h:R:S/$/.o/} 9516359Sasami.endif 9616359Sasami 9716359Sasami.if defined(LIB) && !empty(LIB) 9816359Sasami_LIBS= lib${LIB}.a 9916359Sasami 10016359Sasamilib${LIB}.a: ${OBJS} ${STATICOBJS} 10116359Sasami @${ECHO} building static ${LIB} library 10216359Sasami @rm -f ${.TARGET} 10316359Sasami @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} 10416359Sasami ${RANLIB} ${.TARGET} 10516359Sasami.endif 10616359Sasami 10716359Sasami.if !defined(INTERNALLIB) 10816359Sasami 10916359Sasami.if !defined(NOPROFILE) && defined(LIB) && !empty(LIB) 11016359Sasami_LIBS+= lib${LIB}_p.a 11116359SasamiPOBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po} 11216359Sasami 11316359Sasamilib${LIB}_p.a: ${POBJS} 11416359Sasami @${ECHO} building profiled ${LIB} library 11516359Sasami @rm -f ${.TARGET} 11616359Sasami @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD} 11716359Sasami ${RANLIB} ${.TARGET} 11816359Sasami.endif 11916359Sasami 12016359Sasami.if defined(SHLIB_NAME) || \ 12116359Sasami defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 12216359SasamiSOBJS+= ${OBJS:.o=.So} 12316359Sasami.endif 12416359Sasami 12516359Sasami.if defined(SHLIB_NAME) 12616359Sasami_LIBS+= ${SHLIB_NAME} 12716359Sasami 12816359Sasami${SHLIB_NAME}: ${SOBJS} 12916359Sasami @${ECHO} building shared library ${SHLIB_NAME} 13016359Sasami @rm -f ${.TARGET} ${SHLIB_LINK} 13116359Sasami.if defined(SHLIB_LINK) 13216359Sasami @ln -fs ${.TARGET} ${SHLIB_LINK} 13316359Sasami.endif 13416359Sasami @${CC} ${LDFLAGS} -shared -Wl,-x \ 13516359Sasami -o ${.TARGET} -Wl,-soname,${SONAME} \ 13616359Sasami `lorder ${SOBJS} | tsort -q` ${LDADD} 13716359Sasami.endif 13816359Sasami 13916359Sasami.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 14016359Sasami_LIBS+= lib${LIB}_pic.a 14118095Sasami 14218010Sasamilib${LIB}_pic.a: ${SOBJS} 14316359Sasami @${ECHO} building special pic ${LIB} library 14418265Sasami @rm -f ${.TARGET} 14516359Sasami @${AR} cq ${.TARGET} ${SOBJS} ${ARADD} 14616359Sasami ${RANLIB} ${.TARGET} 14716359Sasami.endif 14816359Sasami 14918265Sasami.if defined(WANT_LINT) && !defined(NOLINT) && defined(LIB) && !empty(LIB) 15016359SasamiLINTLIB= llib-l${LIB}.ln 15116359Sasami_LIBS+= ${LINTLIB} 15216359SasamiLINTOBJS+= ${SRCS:M*.c:.c=.ln} 15316359Sasami 15416359Sasami${LINTLIB}: ${LINTOBJS} 15516359Sasami @${ECHO} building lint library ${.TARGET} 15616359Sasami @rm -f ${.TARGET} 15716359Sasami ${LINT} ${LINTLIBFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 15816359Sasami.endif 15916359Sasami 16016359Sasami.endif !defined(INTERNALLIB) 16116359Sasami 16216359Sasamiall: ${_LIBS} 16316359Sasami 16416359Sasami.if !defined(NOMAN) 16516359Sasamiall: _manpages 16616359Sasami.endif 16716359Sasami 16816359Sasami_EXTRADEPEND: 16916359Sasami @TMP=_depend$$$$; \ 17016359Sasami sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.So:/' < ${DEPENDFILE} \ 17116359Sasami > $$TMP; \ 17216359Sasami mv $$TMP ${DEPENDFILE} 17316359Sasami.if !defined(NOEXTRADEPEND) && defined(SHLIB_NAME) 17416359Sasami.if defined(DPADD) && !empty(DPADD) 17516359Sasami echo ${SHLIB_NAME}: ${DPADD} >> ${DEPENDFILE} 17616359Sasami.endif 17716359Sasami.endif 17816359Sasami 17916359Sasami.if !target(install) 18016359Sasami 18116359Sasami.if defined(PRECIOUSLIB) && !defined(NOFSCHG) 18216359SasamiSHLINSTALLFLAGS+= -fschg 18316359Sasami.endif 18416359Sasami 18516359Sasami_INSTALLFLAGS:= ${INSTALLFLAGS} 18616359Sasami.for ie in ${INSTALLFLAGS_EDIT} 18716359Sasami_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 18816359Sasami.endfor 18916359Sasami_SHLINSTALLFLAGS:= ${SHLINSTALLFLAGS} 19016359Sasami.for ie in ${INSTALLFLAGS_EDIT} 19116359Sasami_SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}} 19216359Sasami.endfor 19316359Sasami 19416359Sasami.if !defined(INTERNALLIB) 19516359Sasamirealinstall: _libinstall 19616359Sasami.ORDER: beforeinstall _libinstall 19716359Sasami_libinstall: 19816359Sasami.if defined(LIB) && !empty(LIB) && !defined(NOINSTALLLIB) 19916359Sasami ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 20016359Sasami ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} 20116359Sasami.endif 20216359Sasami.if !defined(NOPROFILE) && defined(LIB) && !empty(LIB) 20316359Sasami ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 20416359Sasami ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} 20516359Sasami.endif 20616359Sasami.if defined(SHLIB_NAME) 20716359Sasami ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 20816359Sasami ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ 20916359Sasami ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} 21016359Sasami.if defined(SHLIB_LINK) 21116359Sasami ln -fs ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}/${SHLIB_LINK} 21216359Sasami.if (${LIBDIR} != ${SHLIBDIR}) 21316359Sasami ln -fs ${LIBDIR:C|/[^/]+|/..|g:S|^/||}${SHLIBDIR}/${SHLIB_NAME} \ 21416359Sasami ${DESTDIR}${LIBDIR}/${SHLIB_LINK} 21516359Sasami.endif 21616359Sasami.endif 21716359Sasami.endif 21816359Sasami.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 21916359Sasami ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 22016359Sasami ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 22116359Sasami.endif 22216359Sasami.if defined(WANT_LINT) && !defined(NOLINT) && defined(LIB) && !empty(LIB) 22316359Sasami ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 22416359Sasami ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR} 22516359Sasami.endif 22616359Sasami.endif !defined(INTERNALLIB) 22716359Sasami 22816359Sasami.include <bsd.files.mk> 22916359Sasami.include <bsd.incs.mk> 23016359Sasami.include <bsd.links.mk> 23116359Sasami 23216359Sasami.if !defined(NOMAN) 23316359Sasamirealinstall: _maninstall 23416359Sasami.ORDER: beforeinstall _maninstall 23516359Sasami.endif 23616359Sasami 23716359Sasami.endif 23816359Sasami 23916359Sasami.if !target(lint) 24016359Sasamilint: ${SRCS:M*.c} 24116359Sasami ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 24216359Sasami.endif 24316359Sasami 24416359Sasami.if !defined(NOMAN) 24516359Sasami.include <bsd.man.mk> 24616359Sasami.endif 24716359Sasami 24816359Sasami.include <bsd.dep.mk> 24916359Sasami 25016359Sasami.if !exists(${.OBJDIR}/${DEPENDFILE}) 25116359Sasami.if defined(LIB) && !empty(LIB) 25216359Sasami${OBJS} ${STATICOBJS} ${POBJS}: ${SRCS:M*.h} 25316359Sasami.endif 25416359Sasami.if defined(SHLIB_NAME) || \ 25516359Sasami defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 25616359Sasami${SOBJS}: ${SRCS:M*.h} 25716359Sasami.endif 25816359Sasami.endif 25916359Sasami 26016359Sasami.if !target(clean) 26116359Sasamiclean: 26216359Sasami.if defined(CLEANFILES) && !empty(CLEANFILES) 26316359Sasami rm -f ${CLEANFILES} 26416359Sasami.endif 26516359Sasami.if defined(LIB) && !empty(LIB) 26616359Sasami rm -f a.out ${OBJS} ${OBJS:S/$/.tmp/} ${STATICOBJS} 26716359Sasami.endif 26816359Sasami.if !defined(INTERNALLIB) 26916359Sasami.if !defined(NOPROFILE) && defined(LIB) && !empty(LIB) 27016359Sasami rm -f ${POBJS} ${POBJS:S/$/.tmp/} 27116359Sasami.endif 27216359Sasami.if defined(SHLIB_NAME) || \ 27316359Sasami defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 27416359Sasami rm -f ${SOBJS} ${SOBJS:.So=.so} ${SOBJS:S/$/.tmp/} 27516359Sasami.endif 27616359Sasami.if defined(SHLIB_NAME) 27716359Sasami.if defined(SHLIB_LINK) 27816359Sasami rm -f ${SHLIB_LINK} 27916359Sasami.endif 28016359Sasami.if defined(LIB) && !empty(LIB) 28116359Sasami rm -f lib${LIB}.so.* lib${LIB}.so 28216359Sasami.endif 28316359Sasami.endif 28416359Sasami.if defined(WANT_LINT) && defined(LIB) && !empty(LIB) 28516359Sasami rm -f ${LINTOBJS} 28616359Sasami.endif 28716359Sasami.endif !defined(INTERNALLIB) 28816359Sasami.if defined(_LIBS) && !empty(_LIBS) 28916359Sasami rm -f ${_LIBS} 29016359Sasami.endif 29116359Sasami.if defined(CLEANDIRS) && !empty(CLEANDIRS) 29216359Sasami rm -rf ${CLEANDIRS} 29316359Sasami.endif 29416359Sasami.endif 29516359Sasami 29616359Sasami.include <bsd.obj.mk> 29716359Sasami 29816359Sasami.include <bsd.sys.mk> 29916359Sasami