From 78e7e3ecb5c1043a8d580f0f6cf4cf6b5b1a15f9 Mon Sep 17 00:00:00 2001 From: Max Khon Date: Tue, 29 Nov 2011 16:34:44 +0000 Subject: [PATCH] - fix WITH_CTF when specified in /etc/src.conf [1] - CTFCONVERT_CMD=... is a hack (should be defined to empty string instead): make(1) should be taught to ignore empty commands silently in compat mode (as it does in !compat mode, GNU make also silently ignores empty commands) and to skip printing empty commands in !compat mode - config(8) should generate ${NORMAL_CTFCONVERT} invocation without '@': this will allow to simplify kern.pre.mk even more and lessen the number of shell invocations during kernel build when CTF is turned off - WITH_CTF can now be converted to usual MK_CTF=yes/no infrastructure Pointy hat to: fjoe [1] --- share/mk/bsd.lib.mk | 49 +++++++------------------- share/mk/bsd.own.mk | 6 ++++ share/mk/bsd.prog.mk | 11 ++---- share/mk/sys.mk | 82 ++++++++++--------------------------------- sys/conf/kern.mk | 7 ---- sys/conf/kern.post.mk | 6 ++-- sys/conf/kern.pre.mk | 5 +-- sys/conf/kmod.mk | 5 --- 8 files changed, 45 insertions(+), 126 deletions(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 6132a757b220..a575536a4ae7 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -33,15 +33,10 @@ 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} -.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") +.if defined(WITH_CTF) && (${DEBUG_FLAGS:M-g} != "") CTFFLAGS+= -g .endif .endif @@ -69,21 +64,15 @@ PO_FLAG=-pg .c.o: ${CC} ${STATIC_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} - @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ - (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) + ${CTFCONVERT_CMD} .c.po: ${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .c.So: ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .cc.o: ${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} @@ -96,47 +85,33 @@ PO_FLAG=-pg .f.po: ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f.So: ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .s.po .s.So: ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .asm.po: ${CC} -x assembler-with-cpp -DPROF ${PO_CFLAGS} ${ACFLAGS} \ -c ${.IMPSRC} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .asm.So: ${CC} -x assembler-with-cpp ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \ -c ${.IMPSRC} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .S.po: ${CC} -DPROF ${PO_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .S.So: ${CC} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} all: objwarn @@ -211,7 +186,7 @@ ${SHLIB_NAME}: ${SOBJS} -o ${.TARGET} -Wl,-soname,${SONAME} \ `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD} .endif -.if !defined(NO_CTF) +.if defined(WITH_CTF) ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} .endif .endif diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 82ccefc226db..47916126d678 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -189,6 +189,12 @@ STRIP?= -s COMPRESS_CMD?= gzip -cn COMPRESS_EXT?= .gz +.if defined(WITH_CTF) +CTFCONVERT_CMD= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.else +CTFCONVERT_CMD= ... +.endif + .if !defined(_WITHOUT_SRCCONF) # # Define MK_* variables (which are either "yes" or "no") for users diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 193ebb1ae358..f9801b067579 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -15,16 +15,11 @@ 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} -.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") +.if defined(WITH_CTF) && (${DEBUG_FLAGS:M-g} != "") CTFFLAGS+= -g .endif .endif @@ -60,7 +55,7 @@ ${PROG}: ${OBJS} .else ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .endif -.if !defined(NO_CTF) +.if defined(WITH_CTF) ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif @@ -90,7 +85,7 @@ ${PROG}: ${OBJS} .else ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .endif -.if !defined(NO_CTF) +.if defined(WITH_CTF) ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif .endif diff --git a/share/mk/sys.mk b/share/mk/sys.mk index d5577b16978d..e8ec4c141930 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -59,12 +59,6 @@ CFLAGS += -fno-strict-aliasing .endif PO_CFLAGS ?= ${CFLAGS} -# Turn CTF conversion off by default for now. This default could be -# changed later if DTrace becomes popular. -.if !defined(WITH_CTF) -NO_CTF = 1 -.endif - # C Type Format data is required for DTrace CTFFLAGS ?= -L VERSION @@ -158,15 +152,11 @@ YFLAGS ?= -d # SINGLE SUFFIX RULES .c: ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f: ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .sh: cp -f ${.IMPSRC} ${.TARGET} @@ -176,33 +166,25 @@ YFLAGS ?= -d .c.o: ${CC} ${CFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f.o: ${FC} ${FFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .y.o: ${YACC} ${YFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} -c y.tab.c rm -f y.tab.c mv y.tab.o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .l.o: ${LEX} ${LFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} -c lex.yy.c rm -f lex.yy.c mv lex.yy.o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .y.c: ${YACC} ${YFLAGS} ${.IMPSRC} @@ -240,15 +222,11 @@ YFLAGS ?= -d .c: ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .c.o: ${CC} ${CFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .cc .cpp .cxx .C: ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} @@ -258,15 +236,11 @@ YFLAGS ?= -d .m.o: ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .p.o: ${PC} ${PFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .e .r .F .f: ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ @@ -277,38 +251,28 @@ YFLAGS ?= -d .S.o: ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .asm.o: ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .s.o: ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # XXX not -j safe .y.o: ${YACC} ${YFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} rm -f y.tab.c -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .l.o: ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} rm -f ${.PREFIX}.tmp.c -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # XXX not -j safe .y.c: @@ -320,34 +284,26 @@ YFLAGS ?= -d .s.out .c.out .o.out: ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f.out .F.out .r.out .e.out: ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ ${LDLIBS} -o ${.TARGET} rm -f ${.PREFIX}.o -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # XXX not -j safe .y.out: ${YACC} ${YFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} rm -f y.tab.c -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .l.out: ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} rm -f ${.PREFIX}.tmp.c -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. __MAKE_CONF?=/etc/make.conf diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index a69b2ec6054c..9537e7072a8f 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -126,10 +126,3 @@ CFLAGS+= -ffreestanding ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" CFLAGS+= -fstack-protector .endif - -# -# Enable CTF conversion on request -# -.if defined(WITH_CTF) -.undef NO_CTF -.endif diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 6ae2a859c8cb..330ac49c93de 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -94,7 +94,7 @@ ${FULLKERNEL}: ${SYSTEM_DEP} vers.o @rm -f ${.TARGET} @echo linking ${.TARGET} ${SYSTEM_LD} -.if !defined(NO_CTF) +.if defined(WITH_CTF) ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o .endif .if !defined(DEBUG) @@ -249,9 +249,7 @@ kernel-reinstall: config.o env.o hints.o vers.o vnode_if.o: ${NORMAL_C} -.if !defined(NO_CTF) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + @${NORMAL_CTFCONVERT} config.ln env.ln hints.ln vers.ln vnode_if.ln: ${NORMAL_LINT} diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index 73aa3267c956..e9ca8ed354dc 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -123,8 +123,9 @@ NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c -.if !defined(NO_CTF) -NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.if defined(WITH_CTF) +CTFCONVERT_CMD= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +NORMAL_CTFCONVERT= ${ECHO} ${CTFCONVERT_CMD} && ${CTFCONVERT_CMD} .else NORMAL_CTFCONVERT= : .endif diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 6e7b71e486fa..422d74c0e398 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -72,11 +72,6 @@ OBJCOPY?= objcopy .error "Do not use KMODDEPS on 5.0+; use MODULE_VERSION/MODULE_DEPEND" .endif -# Enable CTF conversion on request. -.if defined(WITH_CTF) -.undef NO_CTF -.endif - .include .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S