1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $FreeBSD: src/share/mk/bsd.prog.mk,v 1.86.2.17 2002/12/23 16:33:37 ru Exp $ 3 4.include <bsd.init.mk> 5 6.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S 7 8CFLAGS+=${COPTS} ${DEBUG_FLAGS} 9 10PRIVATELIB_BLDFLAGS?= -rpath /lib/priv -L /usr/lib/priv 11PRIVATELIB_LDFLAGS?= -rpath /lib/priv -L ${_SHLIBDIRPREFIX}/usr/lib/priv 12 13.if !defined(DEBUG_FLAGS) 14STRIP?= -s 15.endif 16 17.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 18LDFLAGS+= -static 19.endif 20 21.if defined(PROG_CXX) 22PROG= ${PROG_CXX} 23.endif 24 25.include <bsd.patch.mk> 26 27.if defined(PROG) 28.if defined(SRCS) 29 30# If there are Objective C sources, link with Objective C libraries. 31.if ${SRCS:M*.m} != "" 32OBJCLIBS?= -lobjc 33LDADD+= ${OBJCLIBS} 34.endif 35 36.if !empty(SRCS) 37OBJS+= ${SRCS:N*.h:N*.patch:R:S/$/.o/g} 38.endif 39 40.if !target(${PROG}) 41${PROG}: ${OBJS} 42.if defined(PROG_CXX) 43 ${CXX_LINK} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 44.else 45 ${CC_LINK} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 46.endif 47.endif 48 49.else # !defined(SRCS) 50 51.if !target(${PROG}) 52.if defined(PROG_CXX) 53SRCS= ${PROG}.cc 54.else 55SRCS= ${PROG}.c 56.endif 57 58# Always make an intermediate object file because: 59# - it saves time rebuilding when only the library has changed 60# - the name of the object gets put into the executable symbol table instead of 61# the name of a variable temporary object. 62# - it's useful to keep objects around for crunching. 63OBJS= ${PROG}.o 64 65${PROG}: ${OBJS} 66.if defined(PROG_CXX) 67 ${CXX_LINK} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 68.else 69 ${CC_LINK} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 70.endif 71.endif 72 73.endif 74 75.if !defined(NOMAN) && !defined(MAN) && \ 76 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 77 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 78 !defined(MAN7) && !defined(MAN8) && !defined(MAN9) 79MAN= ${PROG}.1 80MAN1= ${MAN} 81.endif 82.endif 83 84all: objwarn ${PROG} ${SCRIPTS} 85.if !defined(NOMAN) 86all: _manpages 87.endif 88 89CLEANFILES+= ${PROG} ${OBJS} 90 91.if defined(PROG) 92_EXTRADEPEND: 93 echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 94.if defined(PROG_CXX) 95 echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 96.endif 97.endif 98 99.if !target(install) 100 101_INSTALLFLAGS:= ${INSTALLFLAGS} 102.for ie in ${INSTALLFLAGS_EDIT} 103_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 104.endfor 105 106.if !target(realinstall) && !defined(INTERNALPROG) 107realinstall: _proginstall 108.ORDER: beforeinstall _proginstall 109_proginstall: 110.if defined(PROG) 111.if defined(PROGNAME) 112 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 113 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 114.else 115 ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 116 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 117.endif 118.endif 119.endif # !target(realinstall) && !defined(INTERNALPROG) 120 121.if defined(SCRIPTS) && !empty(SCRIPTS) 122realinstall: _scriptsinstall 123.ORDER: beforeinstall _scriptsinstall 124 125SCRIPTSDIR?= ${BINDIR} 126SCRIPTSOWN?= ${BINOWN} 127SCRIPTSGRP?= ${BINGRP} 128SCRIPTSMODE?= ${BINMODE} 129 130.for script in ${SCRIPTS} 131.if defined(SCRIPTSNAME) 132SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 133.else 134SCRIPTSNAME_${script:T}?= ${script:T:R} 135.endif 136SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 137SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 138SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 139SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 140_scriptsinstall: _SCRIPTSINS_${script:T} 141_SCRIPTSINS_${script:T}: ${script} 142 ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 143 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 144 ${.ALLSRC} \ 145 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 146.endfor 147.endif 148 149NLSNAME?= ${PROG} 150 151.include <bsd.nls.mk> 152.include <bsd.files.mk> 153.include <bsd.incs.mk> 154.include <bsd.links.mk> 155 156.if !defined(NOMAN) 157realinstall: _maninstall 158.ORDER: beforeinstall _maninstall 159.endif 160 161.endif 162 163.if !target(lint) 164lint: ${SRCS} 165.if defined(PROG) 166 -@${LINT} ${LINTFLAGS} ${CFLAGS:M-I*:S/-I/-I /g} ${.ALLSRC} 167.endif 168.endif 169 170.if !defined(NOMAN) 171.include <bsd.man.mk> 172.endif 173 174.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 175.include <bsd.libnames.mk> 176.endif 177 178.include <bsd.dep.mk> 179 180.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 181${OBJS}: ${SRCS:M*.h} 182.endif 183 184.include <bsd.obj.mk> 185 186.include <bsd.sys.mk> 187 188