freebsd-dev/share/mk/bsd.prog.mk

227 lines
4.8 KiB
Makefile
Raw Normal View History

# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
1999-08-28 00:22:10 +00:00
# $FreeBSD$
1994-05-30 19:09:18 +00:00
.if !target(__initialized__)
__initialized__:
.if exists(${.CURDIR}/../Makefile.inc)
1994-05-30 19:09:18 +00:00
.include "${.CURDIR}/../Makefile.inc"
.endif
.endif
1994-05-30 19:09:18 +00:00
.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
1994-05-30 19:09:18 +00:00
CFLAGS+=${COPTS} ${DEBUG_FLAGS}
.if defined(DESTDIR)
CFLAGS+= -I${DESTDIR}/usr/include
CXXINCLUDES+= -I${DESTDIR}/usr/include/g++
.endif
1994-05-30 19:09:18 +00:00
.if !defined(DEBUG_FLAGS)
1994-05-30 19:09:18 +00:00
STRIP?= -s
.endif
1994-05-30 19:09:18 +00:00
.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
LDFLAGS+= -static
.endif
1994-05-30 19:09:18 +00:00
.if defined(PROG)
.if defined(SRCS)
# If there are Objective C sources, link with Objective C libraries.
.if ${SRCS:M*.m} != ""
OBJCLIBS?= -lobjc
LDADD+= ${OBJCLIBS}
.endif
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
${PROG}: ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
.else !defined(SRCS)
1994-05-30 19:09:18 +00:00
.if !target(${PROG})
SRCS= ${PROG}.c
1994-05-30 19:09:18 +00:00
# Always make an intermediate object file because:
# - it saves time rebuilding when only the library has changed
# - the name of the object gets put into the executable symbol table instead of
# the name of a variable temporary object.
# - it's useful to keep objects around for crunching.
OBJS= ${PROG}.o
${PROG}: ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
1994-05-30 19:09:18 +00:00
.endif
.endif
1994-05-30 19:09:18 +00:00
.if !defined(NOMAN) && !defined(MAN) && \
!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
1994-05-30 19:09:18 +00:00
!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
2000-03-23 16:46:20 +00:00
!defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
!defined(MAN1aout)
MAN= ${PROG}.1
MAN1= ${MAN}
1994-05-30 19:09:18 +00:00
.endif
.endif
.MAIN: all
.if !defined(NOMAN)
all: objwarn ${PROG} ${SCRIPTS} all-man _SUBDIR
.else
all: objwarn ${PROG} ${SCRIPTS} _SUBDIR
.endif
1994-05-30 19:09:18 +00:00
CLEANFILES+= ${PROG} ${OBJS}
1994-05-30 19:09:18 +00:00
.if defined(PROG)
_EXTRADEPEND:
.if ${OBJFORMAT} == aout
echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
.else
echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
.endif
.endif
1994-05-30 19:09:18 +00:00
.if !target(install)
.if !target(beforeinstall)
beforeinstall:
.endif
_INSTALLFLAGS:= ${INSTALLFLAGS}
.for ie in ${INSTALLFLAGS_EDIT}
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
.endfor
realinstall: beforeinstall
1994-05-30 19:09:18 +00:00
.if defined(PROG)
.if defined(PROGNAME)
${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
.else
${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1994-05-30 19:09:18 +00:00
.endif
.endif
1994-05-30 19:09:18 +00:00
.if defined(HIDEGAME)
(cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \
chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
1994-05-30 19:09:18 +00:00
.endif
.if defined(LINKS) && !empty(LINKS)
@set ${LINKS}; \
while test $$# -ge 2; do \
l=${DESTDIR}$$1; \
shift; \
t=${DESTDIR}$$1; \
shift; \
${ECHO} $$t -\> $$l; \
ln -f $$l $$t; \
done; true
.endif
.if defined(SYMLINKS) && !empty(SYMLINKS)
@set ${SYMLINKS}; \
while test $$# -ge 2; do \
l=$$1; \
shift; \
t=${DESTDIR}$$1; \
shift; \
${ECHO} $$t -\> $$l; \
ln -fs $$l $$t; \
1994-05-30 19:09:18 +00:00
done; true
.endif
.if defined(SCRIPTS) && !empty(SCRIPTS)
realinstall: _scriptsinstall
SCRIPTSDIR?= ${BINDIR}
SCRIPTSOWN?= ${BINOWN}
SCRIPTSGRP?= ${BINGRP}
SCRIPTSMODE?= ${BINMODE}
.for script in ${SCRIPTS}
.if defined(SCRIPTSNAME)
SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME}
.else
SCRIPTSNAME_${script:T}?= ${script:T:R}
.endif
SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR}
SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN}
SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
_scriptsinstall: SCRIPTSINS_${script:T}
SCRIPTSINS_${script:T}: ${script}
${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
-g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
${_INSTALLFLAGS} ${.ALLSRC} \
${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
.endfor
.endif
install: afterinstall _SUBDIR
.if !defined(NOMAN)
afterinstall: realinstall maninstall
.else
1994-05-30 19:09:18 +00:00
afterinstall: realinstall
.endif
1994-05-30 19:09:18 +00:00
.endif
DISTRIBUTION?= bin
.if !target(distribute)
distribute: _SUBDIR
.for dist in ${DISTRIBUTION}
cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
.endfor
.endif
1994-05-30 19:09:18 +00:00
.if !target(lint)
lint: ${SRCS} _SUBDIR
1994-05-30 19:09:18 +00:00
.if defined(PROG)
@${LINT} ${LINTFLAGS} ${.ALLSRC} | more 2>&1
1994-05-30 19:09:18 +00:00
.endif
.endif
1997-04-13 06:44:25 +00:00
.if defined(NOTAGS)
tags:
.endif
1994-05-30 19:09:18 +00:00
.if !target(tags)
tags: ${SRCS} _SUBDIR
1994-05-30 19:09:18 +00:00
.if defined(PROG)
@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
1997-04-13 06:44:25 +00:00
.if defined(HTML)
@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
1997-04-13 06:44:25 +00:00
.endif
1994-05-30 19:09:18 +00:00
.endif
.endif
.if !defined(NOMAN)
.include <bsd.man.mk>
.else
.if !target(all-man)
all-man:
.endif
.if !target(maninstall)
1994-05-30 19:09:18 +00:00
maninstall:
.endif
.endif
.if !target(regress)
regress:
.endif
.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
.include <bsd.libnames.mk>
.endif
.include <bsd.dep.mk>
.if defined(PROG) && !exists(${DEPENDFILE})
${OBJS}: ${SRCS:M*.h}
.endif
.include <bsd.obj.mk>
.include <bsd.sys.mk>