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

162 lines
3.4 KiB
Makefile
Raw Normal View History

# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
# $Id: bsd.prog.mk,v 1.60 1998/02/07 17:19:06 helbig Exp $
1994-05-30 19:09:18 +00:00
.if exists(${.CURDIR}/../Makefile.inc)
1994-05-30 19:09:18 +00:00
.include "${.CURDIR}/../Makefile.inc"
.endif
# Default executable format
BINFORMAT?= aout
.SUFFIXES: .out .o .c .cc .cxx .C .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 !target(${PROG})
1994-05-30 19:09:18 +00:00
.if defined(SRCS)
DPSRCS+= ${SRCS:M*.h}
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
${PROG}: ${DPSRCS} ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
.else !defined(SRCS)
1994-05-30 19:09:18 +00:00
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}: ${DPSRCS} ${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(MAN1) && !defined(MAN2) && !defined(MAN3) && \
!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
MAN1= ${PROG}.1
1994-05-30 19:09:18 +00:00
.endif
.endif
.MAIN: all
all: objwarn ${PROG} all-man _SUBDIR
1994-05-30 19:09:18 +00:00
.if !target(clean)
clean: _SUBDIR
if [ -n "${PROG}" -o -n "${OBJS}" -o -n "${CLEANFILES}" ] ; then \
rm -f ${PROG} ${OBJS} ${CLEANFILES} ; \
fi
.if defined(CLEANDIRS) && !empty(CLEANDIRS)
rm -rf ${CLEANDIRS}
.endif
1994-05-30 19:09:18 +00:00
.endif
.if defined(PROG) && !defined(NOEXTRADEPEND)
_EXTRADEPEND:
.if ${BINFORMAT} == aout
echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
.else
.if defined(DPADD) && !empty(DPADD)
echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
.endif
.endif
.endif
1994-05-30 19:09:18 +00:00
.if !target(install)
.if !target(beforeinstall)
beforeinstall:
.endif
realinstall: beforeinstall
1994-05-30 19:09:18 +00:00
.if defined(PROG)
${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1994-05-30 19:09:18 +00:00
.endif
.if defined(HIDEGAME)
(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
chown games:bin ${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; \
1994-05-30 19:09:18 +00:00
rm -f $$t; \
ln ${LN_FLAGS} $$l $$t; \
1994-05-30 19:09:18 +00:00
done; true
.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} ${CFLAGS} ${.ALLSRC} | more 2>&1
.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)
1997-04-13 06:44:25 +00:00
@cd ${.CURDIR} && gtags ${GTAGSFLAGS}
.if defined(HTML)
@cd ${.CURDIR} && htags ${HTAGSFLAGS}
.endif
1994-05-30 19:09:18 +00:00
.endif
.endif
.if !defined(NOMAN)
.include <bsd.man.mk>
.elif !target(maninstall)
1994-05-30 19:09:18 +00:00
maninstall:
all-man:
1994-05-30 19:09:18 +00:00
.endif
.if ${BINFORMAT} != aout || make(checkdpadd)
.include <bsd.libnames.mk>
.endif
.include <bsd.dep.mk>
.include <bsd.obj.mk>