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