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