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