Allow relative pathnames in SRCS, so as to enable building software

which includes more than one file with the same name, in different
directories.

For example, setting:

SRCS+=	foo/foo.c bar/foo.c baz/foo.c

will now create separate objdirs 'foo', 'bar' and 'baz' for each of the
sources in the list, and use those objdirs for the corresponding object
files.

Reviewed by:	brooks, imp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D1984
This commit is contained in:
dim 2015-03-14 12:29:44 +00:00
parent 75e831bbaa
commit d202cb2c64
2 changed files with 18 additions and 7 deletions

View File

@ -89,6 +89,16 @@ obj: .PHONY
fi; \
${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \
fi
.for dir in ${SRCS:H:O:u}
@if ! test -d ${CANONICALOBJDIR}/${dir}/; then \
mkdir -p ${CANONICALOBJDIR}/${dir}; \
if ! test -d ${CANONICALOBJDIR}/${dir}/; then \
${ECHO} "Unable to create ${CANONICALOBJDIR}/${dir}."; \
exit 1; \
fi; \
${ECHO} "${CANONICALOBJDIR}/${dir} created for ${.CURDIR}"; \
fi
.endfor
.endif
.if !target(objlink)

View File

@ -242,21 +242,21 @@ YFLAGS ?= -d
${CTFCONVERT_CMD}
.c.o:
${CC} ${CFLAGS} -c ${.IMPSRC}
${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
.cc .cpp .cxx .C:
${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
.cc.o .cpp.o .cxx.o .C.o:
${CXX} ${CXXFLAGS} -c ${.IMPSRC}
${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
.m.o:
${OBJC} ${OBJCFLAGS} -c ${.IMPSRC}
${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
.p.o:
${PC} ${PFLAGS} -c ${.IMPSRC}
${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
.e .r .F .f:
@ -264,14 +264,15 @@ YFLAGS ?= -d
-o ${.TARGET}
.e.o .r.o .F.o .f.o:
${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC}
${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET}
.S.o:
${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
.asm.o:
${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC}
${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
-o ${.TARGET}
${CTFCONVERT_CMD}
.s.o: