1 # $DragonFly: src/share/mk/bsd.patch.mk,v 1.2 2006/02/13 14:21:46 corecode Exp $
3 # The include file <bsd.patch.mk> handles patching of files and sources.
5 # It is advisable to include this file before a rule which deduces ${OBJS}
10 # SRCS List of source files, especially patches (*.patch)
12 # CONTRIBDIR Location of source files to which the patch files are relative
14 # Patch files are added to ${SRCS} and follow the following patterns:
15 # *.no_obj.patch The patched source file won't be added to ${SRCS}.
16 # *.h.patch The patched source file is a header and will be
18 # *.patch The patched source file will be compiled to an object
19 # and will be added to ${SRCS}.
21 # All commas contained in the patch filename will be replaced to slashes to
22 # form a path in a subdir.
26 # CONTRIBDIR= ${.CURDIR}/../../contrib/foo-1.4/src
27 # SRCS+= foomain.c.patch include,fooconf.h.patch
29 # This will patch ${CONTRIBDIR}/foomain.c with foomain.c.patch and add
30 # the patched foomain.c to ${SRCS}.
31 # The file ${CONTRIBDIR}/include/fooconf.h will be patched with
32 # include,fooconf.h.patch; the patched file will be created in
33 # ${.OBJDIR}/include/fooconf.h and will be added to ${SRCS}.
36 .if !target(__<bsd.init.mk>__)
37 .error bsd.patch.mk cannot be included directly.
43 .for _PSRC in ${SRCS:M*.no_obj.patch}
44 .for _PC in ${_PSRC:T:C/(\.no_obj)?\.patch$//:S|,|/|g}
46 ${_PC}: ${CONTRIBDIR}/${_PC} ${_PSRC}
48 patch -o ${.TARGET} -i ${.ALLSRC:M*.patch} ${CONTRIBDIR}/${.TARGET}
52 SRCS:= ${SRCS:N${_PSRC}}
53 CLEANFILES:= ${CLEANFILES} ${_PC}
57 .for _PSRC in ${SRCS:N*.no_obj.patch:M*.patch}
58 .for _PC in ${_PSRC:T:C/(\.no_obj)?\.patch$//:S|,|/|g}
60 ${_PC}: ${CONTRIBDIR}/${_PC} ${_PSRC}
62 patch -o ${.TARGET} -i ${.ALLSRC:M*.patch} ${CONTRIBDIR}/${.TARGET}
64 SRCS:= ${SRCS:N${_PC}:S|${_PSRC}|${_PC}|}
65 CLEANFILES:= ${CLEANFILES} ${_PC}