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

244 lines
5.1 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
.include <bsd.init.mk>
1994-05-30 19:09:18 +00:00
.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm
1994-05-30 19:09:18 +00:00
# XXX The use of COPTS in modern makefiles is discouraged.
.if defined(COPTS)
CFLAGS+=${COPTS}
.endif
.if ${MK_ASSERT_DEBUG} == "no"
CFLAGS+= -DNDEBUG
NO_WERROR=
.endif
# Enable CTF conversion on request.
.if defined(WITH_CTF)
.undef NO_CTF
.endif
.if defined(DEBUG_FLAGS)
CFLAGS+=${DEBUG_FLAGS}
CXXFLAGS+=${DEBUG_FLAGS}
Add support for the Compact C Type (CTF) conversions throughout FreeBSD's system makefiles. Note that the CTF conversion defaults to off. We may choose to change this default later if DTrace proves popular and people are prepared to wear the compilation performance impact of compiling with debug symbols all the time. Setting NO_CTF in the make args or user environment turns off CTF conversion. Even if we choose to default CTF generation to on later, we still need NO_CTF so that the buildworld process can bootstrap the tools without needlessly generating CTF data for temporary tools. Setting WITH_CTF in the make args or user environment (and _NOT_ in /etc/make.conf) is the only way to enable CTF data conversion. Nore that this can't be implemented the same way that the WITH_ and WITHOUT_ stuff is implemented throughout the buildworld because the CTF conversion needs to work when building a simple object without a Makefile, using the default rules in sys.mk. Typing 'make test.o' with no makefile and just a source file test.c should work. Also, typing 'make WITH_CTF=1 test.o without a makefile and just a source file test.c should work and produce an object with a CTF elf section. Typing 'make WITH_CTF=1 CFLAGS=-g test.o' without a makefile and just a source file test.c should produce an object with both a CTF elf section and the debug elf sections. In the FreeBSD build where more .mk files are used than just sys.mk which is included my make by default, the use of DEBUG_FLAGS is the correct way to enable a debug build. The important thing to note here is that it is the DEBUG_FLAGS setting that prevents libraries and programs from being stripped on installation. So, for the addition of CTF data conversion, setting DEBUG_FLAGS to contain -g, without NO_CTF, will cause the ctfconvert and ctfmerge build programs to be executed also with the -g arg so that debug symbols are retained rather than being removed after the CTF data elf section has been added. Add DTrace libraries to the list of libnames.
2008-05-22 01:14:43 +00:00
.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "")
CTFFLAGS+= -g
.endif
.endif
.if defined(CRUNCH_CFLAGS)
CFLAGS+=${CRUNCH_CFLAGS}
.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
2004-12-21 09:59:45 +00:00
.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
LDFLAGS+= -static
.endif
1994-05-30 19:09:18 +00:00
.if defined(PROG_CXX)
PROG= ${PROG_CXX}
.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 !empty(SRCS:M*.m)
.if defined(OBJCLIBS)
LDADD+= ${OBJCLIBS}
.else
DPADD+= ${LIBOBJC} ${LIBPTHREAD}
LDADD+= -lobjc -lpthread
.endif
.endif
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
.if target(beforelinking)
${PROG}: ${OBJS} beforelinking
.else
2010-09-10 17:00:48 +00:00
${PROG}: ${OBJS}
.endif
.if defined(PROG_CXX)
${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.else
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.endif
@[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \
(${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} && \
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS})
.else # !defined(SRCS)
1994-05-30 19:09:18 +00:00
.if !target(${PROG})
.if defined(PROG_CXX)
SRCS= ${PROG}.cc
.else
SRCS= ${PROG}.c
.endif
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
.if target(beforelinking)
${PROG}: ${OBJS} beforelinking
.else
${PROG}: ${OBJS}
.endif
.if defined(PROG_CXX)
${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.else
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
1994-05-30 19:09:18 +00:00
.endif
@[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \
(${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} && \
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS})
.endif
.endif
1994-05-30 19:09:18 +00:00
.if ${MK_MAN} != "no" && !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
all: objwarn ${PROG} ${SCRIPTS}
.if ${MK_MAN} != "no"
all: _manpages
.endif
1994-05-30 19:09:18 +00:00
.if defined(PROG)
CLEANFILES+= ${PROG}
.endif
.if defined(OBJS)
CLEANFILES+= ${OBJS}
.endif
1994-05-30 19:09:18 +00:00
.include <bsd.libnames.mk>
.if defined(PROG)
_EXTRADEPEND:
.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
.if defined(DPADD) && !empty(DPADD)
echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
.endif
.else
echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
.if defined(PROG_CXX)
echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
.endif
.endif
.endif
1994-05-30 19:09:18 +00:00
.if !target(install)
2004-11-12 13:24:34 +00:00
.if defined(PRECIOUSPROG)
2004-12-21 09:53:14 +00:00
.if !defined(NO_FSCHG)
INSTALLFLAGS+= -fschg
.endif
2004-11-12 13:24:34 +00:00
INSTALLFLAGS+= -S
.endif
_INSTALLFLAGS:= ${INSTALLFLAGS}
.for ie in ${INSTALLFLAGS_EDIT}
_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
.endfor
.if !target(realinstall) && !defined(INTERNALPROG)
realinstall: _proginstall
.ORDER: beforeinstall _proginstall
_proginstall:
1994-05-30 19:09:18 +00:00
.if defined(PROG)
.if defined(PROGNAME)
${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
.else
${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1994-05-30 19:09:18 +00:00
.endif
.endif
.endif # !target(realinstall)
1994-05-30 19:09:18 +00:00
.if defined(SCRIPTS) && !empty(SCRIPTS)
realinstall: _scriptsinstall
.ORDER: beforeinstall _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} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
-g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
${.ALLSRC} \
${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
.endfor
.endif
NLSNAME?= ${PROG}
.include <bsd.nls.mk>
.include <bsd.files.mk>
.include <bsd.incs.mk>
.include <bsd.links.mk>
.if ${MK_MAN} != "no"
realinstall: _maninstall
.ORDER: beforeinstall _maninstall
.endif
1994-05-30 19:09:18 +00:00
.endif
.if !target(lint)
lint: ${SRCS:M*.c}
1994-05-30 19:09:18 +00:00
.if defined(PROG)
${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
1994-05-30 19:09:18 +00:00
.endif
.endif
.if ${MK_MAN} != "no"
1994-05-30 19:09:18 +00:00
.include <bsd.man.mk>
.endif
.include <bsd.dep.mk>
.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${SRCS:M*.h}
.endif
.include <bsd.obj.mk>
.include <bsd.sys.mk>
.if defined(PORTNAME)
.include <bsd.pkg.mk>
.endif