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