bsd.prog.mk revision 94497
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2# $FreeBSD: head/share/mk/bsd.prog.mk 94497 2002-04-12 08:17:24Z ru $ 3 4.if !target(__initialized__) 5__initialized__: 6.if exists(${.CURDIR}/../Makefile.inc) 7.include "${.CURDIR}/../Makefile.inc" 8.endif 9.endif 10 11.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S 12 13CFLAGS+=${COPTS} ${DEBUG_FLAGS} 14 15.if !defined(DEBUG_FLAGS) 16STRIP?= -s 17.endif 18 19.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 20LDFLAGS+= -static 21.endif 22 23.if defined(PROG_CXX) 24PROG= ${PROG_CXX} 25.endif 26 27.if defined(PROG) 28.if defined(SRCS) 29 30# If there are Objective C sources, link with Objective C libraries. 31.if ${SRCS:M*.m} != "" 32OBJCLIBS?= -lobjc 33LDADD+= ${OBJCLIBS} 34.endif 35 36OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 37 38.else !defined(SRCS) 39 40.if !target(${PROG}) 41.if defined(PROG_CXX) 42SRCS= ${PROG}.cc 43.else 44SRCS= ${PROG}.c 45.endif 46 47# Always make an intermediate object file because: 48# - it saves time rebuilding when only the library has changed 49# - the name of the object gets put into the executable symbol table instead of 50# the name of a variable temporary object. 51# - it's useful to keep objects around for crunching. 52OBJS= ${PROG}.o 53.endif 54 55${PROG}: ${OBJS} 56.if defined(PROG_CXX) 57 ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 58.else 59 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 60.endif 61 62.endif 63 64.if !defined(NOMAN) && !defined(MAN) && \ 65 !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 66 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 67 !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 68 !defined(MAN1aout) 69MAN= ${PROG}.1 70MAN1= ${MAN} 71.endif 72.endif 73 74.MAIN: all 75all: objwarn ${PROG} ${SCRIPTS} ${FILES} 76.if !defined(NOMAN) 77all: all-man 78.endif 79all: _SUBDIR 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 106realinstall: beforeinstall 107.if defined(PROG) 108.if defined(PROGNAME) 109 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 110 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 111.else 112 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 113 ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 114.endif 115.endif 116.if defined(HIDEGAME) 117 (cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \ 118 chown -h ${BINOWN}:${ORIGBINGRP} ${PROG}) 119.endif 120.if defined(LINKS) && !empty(LINKS) 121 @set ${LINKS}; \ 122 while test $$# -ge 2; do \ 123 l=${DESTDIR}$$1; \ 124 shift; \ 125 t=${DESTDIR}$$1; \ 126 shift; \ 127 ${ECHO} $$t -\> $$l; \ 128 ln -f $$l $$t; \ 129 done; true 130.endif 131.if defined(SYMLINKS) && !empty(SYMLINKS) 132 @set ${SYMLINKS}; \ 133 while test $$# -ge 2; do \ 134 l=$$1; \ 135 shift; \ 136 t=${DESTDIR}$$1; \ 137 shift; \ 138 ${ECHO} $$t -\> $$l; \ 139 ln -fs $$l $$t; \ 140 done; true 141.endif 142 143.if defined(SCRIPTS) && !empty(SCRIPTS) 144realinstall: _scriptsinstall 145 146SCRIPTSDIR?= ${BINDIR} 147SCRIPTSOWN?= ${BINOWN} 148SCRIPTSGRP?= ${BINGRP} 149SCRIPTSMODE?= ${BINMODE} 150 151.for script in ${SCRIPTS} 152.if defined(SCRIPTSNAME) 153SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 154.else 155SCRIPTSNAME_${script:T}?= ${script:T:R} 156.endif 157SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 158SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 159SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 160SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 161_scriptsinstall: _SCRIPTSINS_${script:T} 162_SCRIPTSINS_${script:T}: ${script} 163 ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 164 -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 165 ${_INSTALLFLAGS} ${.ALLSRC} \ 166 ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 167.endfor 168.endif 169 170.if defined(FILES) && !empty(FILES) 171realinstall: _filesinstall 172 173FILESDIR?= ${BINDIR} 174FILESOWN?= ${SHAREOWN} 175FILESGRP?= ${SHAREGRP} 176FILESMODE?= ${SHAREMODE} 177 178.for file in ${FILES} 179.if defined(FILESNAME) 180FILESNAME_${file:T}?= ${FILESNAME} 181.else 182FILESNAME_${file:T}?= ${file:T} 183.endif 184FILESDIR_${file:T}?= ${FILESDIR} 185FILESOWN_${file:T}?= ${FILESOWN} 186FILESGRP_${file:T}?= ${FILESGRP} 187FILESMODE_${file:T}?= ${FILESMODE} 188_filesinstall: _FILESINS_${file:T} 189_FILESINS_${file:T}: ${file} 190 ${INSTALL} ${COPY} -o ${FILESOWN_${.ALLSRC:T}} \ 191 -g ${FILESGRP_${.ALLSRC:T}} -m ${FILESMODE_${.ALLSRC:T}} \ 192 ${_INSTALLFLAGS} ${.ALLSRC} \ 193 ${DESTDIR}${FILESDIR_${.ALLSRC:T}}/${FILESNAME_${.ALLSRC:T}} 194.endfor 195.endif 196 197install: afterinstall _SUBDIR 198.if !defined(NOMAN) 199afterinstall: realinstall maninstall 200.else 201afterinstall: realinstall 202.endif 203.endif 204 205DISTRIBUTION?= bin 206.if !target(distribute) 207distribute: _SUBDIR 208.for dist in ${DISTRIBUTION} 209 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 210.endfor 211.endif 212 213.if !target(lint) 214lint: ${SRCS} _SUBDIR 215.if defined(PROG) 216 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1 217.endif 218.endif 219 220.if defined(NOTAGS) 221tags: 222.endif 223 224.if !target(tags) 225tags: ${SRCS} _SUBDIR 226.if defined(PROG) 227 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 228.if defined(HTML) 229 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 230.endif 231.endif 232.endif 233 234.if !defined(NOMAN) 235.include <bsd.man.mk> 236.else 237.if !target(all-man) 238all-man: 239.endif 240.if !target(maninstall) 241maninstall: 242.endif 243.endif 244 245.if !target(regress) 246regress: 247.endif 248 249.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 250.include <bsd.libnames.mk> 251.endif 252 253.include <bsd.dep.mk> 254 255.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 256${OBJS}: ${SRCS:M*.h} 257.endif 258 259.include <bsd.obj.mk> 260 261.include <bsd.sys.mk> 262