Index: bsd.prog.mk =================================================================== --- bsd.prog.mk (revision 286260) +++ bsd.prog.mk (working copy) @@ -16,6 +16,18 @@ NO_WERROR= .endif +_PROGS= ${PROG} ${PROGS} +_PROGS_CXX= ${PROG_CXX} ${PROGS_CXX} +_PROGS_LIST= ${_PROGS} ${_PROGS_CXX} + +.if defined(PROG) +SRCS.${PROG}:= ${SRCS} +.endif +.if defined(PROG_CXX) +SRCS.${PROG_CXX}:= ${SRCS} +.endif +.undef SRCS + .if defined(DEBUG_FLAGS) CFLAGS+=${DEBUG_FLAGS} CXXFLAGS+=${DEBUG_FLAGS} @@ -25,10 +37,6 @@ .endif .endif -.if defined(PROG_CXX) -PROG= ${PROG_CXX} -.endif - .if !empty(LDFLAGS:M-Wl,*--oformat,*) || !empty(LDFLAGS:M-static) MK_DEBUG_FILES= no .endif @@ -51,8 +59,9 @@ LDFLAGS+= -static .endif +.for p in ${_PROGS_LIST} .if ${MK_DEBUG_FILES} != "no" -PROG_FULL=${PROG}.full +PROG_FULL.$p=$p.full # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory .if defined(BINDIR) && (\ ${BINDIR} == "/bin" ||\ @@ -66,70 +75,41 @@ DEBUGMKDIR= .endif .else -PROG_FULL= ${PROG} +PROG_FULL.$p= $p .endif -.if defined(PROG) -PROGNAME?= ${PROG} - -.if defined(SRCS) - -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -.if target(beforelinking) -beforelinking: ${OBJS} -${PROG_FULL}: beforelinking +.if ${_PROGS:M$p} +SRCS.$p?= $p.c +CC.$p= ${CC} +FLAGS.$p= ${CFLAGS} +.elif ${_PROGS_CXX:M$p} +SRCS.$p?= $p.cc +CC.$p= ${CXX} +FLAGS.$p= ${CXXFLAGS} .endif -${PROG_FULL}: ${OBJS} -.if defined(PROG_CXX) - ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} -.else - ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} -.endif -.if ${MK_CTF} != "no" - ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} -.endif -.else # !defined(SRCS) +PROGNAME_$p?= $p +SRCS+= ${SRCS.$p} +OBJS.$p= ${SRCS.$p:N*.h:R:S/$/.o/g} +OBJS+= ${OBJS.$p} -.if !target(${PROG}) -.if defined(PROG_CXX) -SRCS= ${PROG}.cc -.else -SRCS= ${PROG}.c -.endif - -# 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) -beforelinking: ${OBJS} -${PROG_FULL}: beforelinking +beforelinking: ${OBJS.$p} +${PROG_FULL.$p}: beforelinking .endif -${PROG_FULL}: ${OBJS} -.if defined(PROG_CXX) - ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} -.else - ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} -.endif +${PROG_FULL.$p}: ${OBJS.$p} + ${CC.$p} ${FLAGS.$p} ${LDFLAGS} -o ${.TARGET} ${OBJS.$p} ${LDADD} ${LDADD.$p} .if ${MK_CTF} != "no" - ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS.$p} .endif -.endif # !target(${PROG}) -.endif # !defined(SRCS) - .if ${MK_DEBUG_FILES} != "no" -${PROG}: ${PROG_FULL} ${PROGNAME}.debug - ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \ - ${PROG_FULL} ${.TARGET} +$p: ${PROG_FULL.$p} ${PROGNAME.$p}.debug + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME.$p}.debug \ + ${PROG_FULL.$p} ${.TARGET} -${PROGNAME}.debug: ${PROG_FULL} - ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET} +${PROGNAME.$p}.debug: ${PROG_FULL.$p} + ${OBJCOPY} --only-keep-debug ${PROG_FULL.$p} ${.TARGET} .endif .if ${MK_MAN} != "no" && !defined(MAN) && \ @@ -136,15 +116,20 @@ !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ !defined(MAN7) && !defined(MAN8) && !defined(MAN9) -MAN= ${PROG}.1 +MAN= $p.1 MAN1= ${MAN} .endif -.endif # defined(PROG) +CLEANFILES+= $p +.if ${MK_DEBUG_FILES} != "no" +CLEANFILES+= ${PROG_FULL.$p} ${PROGNAME.$p}.debug +.endif +.endfor # for(_PROGS_LIST) + .if defined(_SKIP_BUILD) all: .else -all: beforebuild .WAIT ${PROG} ${SCRIPTS} +all: beforebuild .WAIT ${_PROGS_LIST} ${SCRIPTS} beforebuild: objwarn .if ${MK_MAN} != "no" all: _manpages @@ -151,13 +136,6 @@ .endif .endif -.if defined(PROG) -CLEANFILES+= ${PROG} -.if ${MK_DEBUG_FILES} != "no" -CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug -.endif -.endif - .if defined(OBJS) CLEANFILES+= ${OBJS} .endif @@ -164,23 +142,25 @@ .include -.if defined(PROG) +.if defined(_PROGS_LIST) _EXTRADEPEND: +.for p in ${_PROGS} .if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) -.if defined(DPADD) && !empty(DPADD) - echo ${PROG_FULL}: ${DPADD} >> ${DEPENDFILE} +.if (defined(DPADD) && !empty(DPADD)) || (defined(DPADD.$p) && !empty(DPADD.$p)) + echo ${PROG_FULL.$p}: ${DPADD} ${DPADD.$p} >> ${DEPENDFILE} +. endif +.else + echo ${PROG_FULL.$p}: ${LIBC} ${DPADD} ${DPADD.$p} >> ${DEPENDFILE} .endif -.else - echo ${PROG_FULL}: ${LIBC} ${DPADD} >> ${DEPENDFILE} -.if defined(PROG_CXX) +.endfor +.for p in ${_PROGS_CXX} .if ${COMPILER_TYPE} == "clang" && empty(CXXFLAGS:M-stdlib=libstdc++) - echo ${PROG_FULL}: ${LIBCPLUSPLUS} >> ${DEPENDFILE} + echo ${PROG_FULL.$p}: ${LIBCPLUSPLUS} >> ${DEPENDFILE} .else - echo ${PROG_FULL}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} + echo ${PROG_FULL.$p}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} .endif +.endfor .endif -.endif -.endif .if !target(install) @@ -200,17 +180,17 @@ realinstall: _proginstall .ORDER: beforeinstall _proginstall _proginstall: -.if defined(PROG) +.for p in ${_PROGS_LIST} ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} + ${_INSTALLFLAGS} ${PROG.$p} ${DESTDIR}${BINDIR}/${PROGNAME.$p} .if ${MK_DEBUG_FILES} != "no" .if defined(DEBUGMKDIR) ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR} .endif ${INSTALL} -T debug -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \ - ${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug + ${PROGNAME.$p}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME.$p}.debug .endif -.endif +.endfor .endif # !target(realinstall) .if defined(SCRIPTS) && !empty(SCRIPTS) @@ -262,7 +242,7 @@ .if !target(lint) lint: ${SRCS:M*.c} -.if defined(PROG) +.if defined(_PROGS_LIST) ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} .endif .endif @@ -273,7 +253,7 @@ .include -.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) +.if defined(_PROGS_LIST) && !exists(${.OBJDIR}/${DEPENDFILE}) ${OBJS}: ${SRCS:M*.h} .endif Index: bsd.test.mk =================================================================== --- bsd.test.mk (revision 286260) +++ bsd.test.mk (working copy) @@ -101,11 +101,7 @@ MK_STAGING= no .endif -.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) -.include -.endif -.include - +.include .if !defined(PROG) && ${MK_STAGING} != "no" .if !defined(_SKIP_BUILD) # this will handle staging if needed @@ -116,7 +112,6 @@ .if !empty(PROGS) stage_files.prog: ${PROGS} .endif -.include .endif .if !target(objwarn)