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