From acbbf55b4cc3105d332a0ba609ba77d78ce7328a Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Fri, 5 Mar 2004 01:06:50 +0000 Subject: [PATCH] Add patch infrastructure for contrib/ and similiar directories. This allows the inclusion of patches in SRCS in the following form: this,is,the,source.c.patch This will create ${.OBJDIR}/this/is/the/source.c by applying above patch to ${CONTRIBDIR}/this/is/the/source.c. The patched files are deleted on "make clean" and created by "make depend". --- share/mk/bsd.dep.mk | 15 ++++++++++++++- share/mk/bsd.lib.mk | 9 +++++++-- share/mk/bsd.prog.mk | 11 +++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index 7e41fa8368..dfaac07a2d 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -1,5 +1,5 @@ # $FreeBSD: src/share/mk/bsd.dep.mk,v 1.27.2.3 2002/12/23 16:33:37 ru Exp $ -# $DragonFly: src/share/mk/bsd.dep.mk,v 1.2 2003/06/17 04:37:02 dillon Exp $ +# $DragonFly: src/share/mk/bsd.dep.mk,v 1.3 2004/03/05 01:06:50 joerg Exp $ # # The include file handles Makefile dependencies. # @@ -67,6 +67,19 @@ tags: ${SRCS} .if defined(SRCS) CLEANFILES?= +.for _PSRC in ${SRCS:M*.patch} +.for _PC in ${_PSRC:T:S/.patch$//:S|,|/|g} + +${_PC}: ${CONTRIBDIR}/${_PC} ${_PSRC} + mkdir -p ${.TARGET:H} + patch -o ${.TARGET} -i ${.ALLSRC:M*.patch} ${CONTRIBDIR}/${.TARGET} + +SRCS:= ${SRCS:N${_PC}:S|${_PSRC}|${_PC}|} +CLEANFILES:= ${CLEANFILES} ${_PC} +.endfor +.endfor + + .for _LSRC in ${SRCS:M*.l:N*/*} .for _LC in ${_LSRC:S/.l/.c/} ${_LC}: ${_LSRC} diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index c83130a710..4d24334085 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -1,6 +1,6 @@ # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 # $FreeBSD: src/share/mk/bsd.lib.mk,v 1.91.2.15 2002/08/07 16:31:50 ru Exp $ -# $DragonFly: src/share/mk/bsd.lib.mk,v 1.3 2004/01/16 07:45:19 dillon Exp $ +# $DragonFly: src/share/mk/bsd.lib.mk,v 1.4 2004/03/05 01:06:50 joerg Exp $ # .include @@ -155,7 +155,12 @@ PO_FLAG=-pg all: objwarn .if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) -OBJS+= ${SRCS:N*.h:R:S/$/.o/} +OBJS+= ${SRCS:N*.h:N*.patch:R:S/$/.o/g} +.for _PATCH in ${SRCS:T:N*.h.patch:M*.patch} +.for _OBJ in ${_PATCH:R:R:S/$/.o/} +OBJS:= ${OBJS:N${_OBJ}} ${_OBJ} +.endfor +.endfor .endif .if defined(LIB) && !empty(LIB) diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 625373f18c..aa3317e7be 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -1,6 +1,6 @@ # from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 # $FreeBSD: src/share/mk/bsd.prog.mk,v 1.86.2.17 2002/12/23 16:33:37 ru Exp $ -# $DragonFly: src/share/mk/bsd.prog.mk,v 1.2 2003/06/17 04:37:02 dillon Exp $ +# $DragonFly: src/share/mk/bsd.prog.mk,v 1.3 2004/03/05 01:06:50 joerg Exp $ .include @@ -29,7 +29,14 @@ OBJCLIBS?= -lobjc LDADD+= ${OBJCLIBS} .endif -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} +OBJS+= ${SRCS:N*.h:N*.patch:R:S/$/.o/g} +_PATCHES= ${SRCS:M*.patch} +.for _PATCH in ${SRCS:T:N*.h.patch:M*.patch} +.for _OBJ in ${_PATCH:R:R:S/$/.o/} +OBJS:= ${OBJS:N${_OBJ}} ${_OBJ} +.endfor +.endfor +.undef _PATCHES ${PROG}: ${OBJS} .if defined(PROG_CXX) -- 2.35.2