Index: share/mk/bsd.obj.mk =================================================================== --- share/mk/bsd.obj.mk +++ share/mk/bsd.obj.mk @@ -26,6 +26,12 @@ # NO_OBJ Do not create object directories. This should not be set # if anything is built. # +# SRCS_SUBDIRS Additional subdirectories to create, for use when entries in +# SRCS contain subdirectories. For example, +# +# SRCS_SUBDIRS=dir1 dir2 +# SRCS=dir1/file.c dir2/file.c +# # +++ targets +++ # # clean: @@ -81,14 +87,16 @@ .if !defined(NO_OBJ) .if !target(obj) obj: .PHONY - @if ! test -d ${CANONICALOBJDIR}/; then \ - mkdir -p ${CANONICALOBJDIR}; \ - if ! test -d ${CANONICALOBJDIR}/; then \ - ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \ +.for dir in ${CANONICALOBJDIR} ${SRCS_SUBDIRS:S/^/${CANONICALOBJDIR}\/&/} + @if ! test -d ${dir}/; then \ + mkdir -p ${dir}; \ + if ! test -d ${dir}/; then \ + ${ECHO} "Unable to create ${dir}."; \ exit 1; \ fi; \ - ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \ + ${ECHO} "${dir} created for ${.CURDIR}${dir:S/^${CANONICALOBJDIR}//}"; \ fi +.endfor .endif .if !target(objlink) Index: share/mk/sys.mk =================================================================== --- share/mk/sys.mk +++ share/mk/sys.mk @@ -242,21 +242,21 @@ ${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 @@ -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: