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} ${FILES} 77.if !defined(NOMAN) 78all: all-man 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.if !target(beforeinstall) 98beforeinstall: 99.endif 100 101_INSTALLFLAGS:= ${INSTALLFLAGS} 102.for ie in ${INSTALLFLAGS_EDIT} 103_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 104.endfor 105 106.if !target(realinstall) 107realinstall: 108.if defined(PROG) 109.if defined(PROGNAME) 110 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 111 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 112.else 113 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 114 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 115.endif 116.endif 117.if defined(HIDEGAME) 118 (cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \ 119 chown -h ${BINOWN}:${ORIGBINGRP} ${PROG}) 120.endif 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) 144realinstall: beforeinstall 145 146.if defined(SCRIPTS) && !empty(SCRIPTS) 147realinstall: _scriptsinstall 148 149SCRIPTSDIR?= ${BINDIR} 150SCRIPTSOWN?= ${BINOWN} 151SCRIPTSGRP?= ${BINGRP} 152SCRIPTSMODE?= ${BINMODE} 153 154.for script in ${SCRIPTS} 155.if defined(SCRIPTSNAME) 156SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 157.else 158SCRIPTSNAME_${script:T}?= ${script:T:R} 159.endif 160SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 161SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 162SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 163SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 164_scriptsinstall: _SCRIPTSINS_${script:T} 165_SCRIPTSINS_${script:T}: ${script} 166 ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 167 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 168 ${.ALLSRC} \ 169 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 170.endfor 171.endif 172 173.if defined(FILES) && !empty(FILES) 174realinstall: _filesinstall 175 176FILESDIR?= ${BINDIR} 177FILESOWN?= ${SHAREOWN} 178FILESGRP?= ${SHAREGRP} 179FILESMODE?= ${SHAREMODE} 180 181.for file in ${FILES} 182.if defined(FILESNAME) 183FILESNAME_${file:T}?= ${FILESNAME} 184.else 185FILESNAME_${file:T}?= ${file:T} 186.endif 187FILESDIR_${file:T}?= ${FILESDIR} 188FILESOWN_${file:T}?= ${FILESOWN} 189FILESGRP_${file:T}?= ${FILESGRP} 190FILESMODE_${file:T}?= ${FILESMODE} 191_filesinstall: _FILESINS_${file:T} 192_FILESINS_${file:T}: ${file} 193 ${INSTALL} ${COPY} -o ${FILESOWN_${.ALLSRC:T}} \ 194 -g ${FILESGRP_${.ALLSRC:T}} -m ${FILESMODE_${.ALLSRC:T}} \ 195 ${.ALLSRC} \ 196 ${DESTDIR}${FILESDIR_${.ALLSRC:T}}/${FILESNAME_${.ALLSRC:T}} 197.endfor 198.endif 199 200install: afterinstall 201afterinstall: realinstall 202.if !defined(NOMAN) 203afterinstall: maninstall 204.endif 205.endif 206 207.if !target(lint) 208lint: ${SRCS} 209.if defined(PROG) 210 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1 211.endif 212.endif 213 214.if defined(NOTAGS) 215tags: 216.endif 217 218.if !target(tags) 219tags: ${SRCS} 220.if defined(PROG) 221 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 222.if defined(HTML) 223 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 224.endif 225.endif 226.endif 227 228.if !defined(NOMAN) 229.include <bsd.man.mk> 230.endif 231 232.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 233.include <bsd.libnames.mk> 234.endif 235 236.include <bsd.dep.mk> 237 238.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 239${OBJS}: ${SRCS:M*.h} 240.endif 241 242.include <bsd.obj.mk> 243 244.include <bsd.sys.mk> 245