Hi, I came across the need of building FILES components in several occasions, for instance the pkgconfig files in X.Org. In the end I did the installation part myself, only re-using the filesinstall macro from bsd.files.mk. I have another use for it now, and I'd rather not do that again, but rather provide a way of building files installed by bsd.files.mk, and I came up with the following patch. The bsd.prog.mk part fixes a bug with the way it handles CLEANFILES; if the original Makefile didn't set CLEANFILES, the target is created empty, and any further addition to CLEANFILES won't do what you expect. There might be better ways to fix that one, adding a if in the shell code for instance. Opinions? The reason I need it is to do substitutions in the rc.d scripts for xdm and xfs, which include the path to the X11 distribution. Index: bsd.files.mk =================================================================== RCS file: /cvsroot/src/share/mk/bsd.files.mk,v retrieving revision 1.39 diff -u -r1.39 bsd.files.mk --- bsd.files.mk 25 Aug 2008 08:11:04 -0000 1.39 +++ bsd.files.mk 18 Oct 2008 21:28:29 -0000 @@ -8,6 +8,7 @@ .if !target(__fileinstall) ##### Basic targets realinstall: filesinstall +realall: filesbuild ##### Default values FILESDIR?= ${BINDIR} @@ -15,6 +16,10 @@ FILESGRP?= ${BINGRP} FILESMODE?= ${NONBINMODE} +##### Build rules +filesbuild: +.PHONY: filelsbuild + ##### Install rules filesinstall:: # ensure existence .PHONY: filesinstall @@ -36,19 +41,25 @@ _FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override _FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override _F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path +_FDOBUILD:= ${FILESBUILD_${F}:Uno} .if ${MKUPDATE} == "no" ${_F}! ${F} __fileinstall # install rule -.if !defined(BUILD) && !make(all) && !make(${F}) +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") ${_F}! .MADE # no build at install .endif .else ${_F}: ${F} __fileinstall # install rule -.if !defined(BUILD) && !make(all) && !make(${F}) +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") ${_F}: .MADE # no build at install .endif .endif +.if ${_FDOBUILD} != "no" +filesbuild: ${F} +CLEANFILES+= ${F} +.endif + filesinstall:: ${_F} .PRECIOUS: ${_F} # keep if install fails .endfor @@ -63,19 +74,25 @@ _FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override _FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override _F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path +_FDOBUILD:= ${FILESBUILD_${F}:Uno} .if ${MKUPDATE} == "no" ${_F}! ${F} __fileinstall # install rule -.if !defined(BUILD) && !make(all) && !make(${F}) +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") ${_F}! .MADE # no build at install .endif .else ${_F}: ${F} __fileinstall # install rule -.if !defined(BUILD) && !make(all) && !make(${F}) +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") ${_F}: .MADE # no build at install .endif .endif +.if ${_FDOBUILD} != "no" +filesbuild: ${F} +CLEANFILES+= ${F} +.endif + configfilesinstall:: ${_F} .PRECIOUS: ${_F} # keep if install fails .endfor Index: bsd.prog.mk =================================================================== RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v retrieving revision 1.236 diff -u -r1.236 bsd.prog.mk --- bsd.prog.mk 2 Oct 2008 17:54:53 -0000 1.236 +++ bsd.prog.mk 18 Oct 2008 21:28:29 -0000 @@ -27,11 +27,6 @@ echo "source ${__gdbinit}" >> .gdbinit .endfor -cleanextra: .PHONY -.if defined(CLEANFILES) && !empty(CLEANFILES) - rm -f ${CLEANFILES} -.endif - cleanobjs: .PHONY cleanprog: .PHONY cleanobjs cleanextra @@ -449,6 +444,11 @@ .include <bsd.sys.mk> .include <bsd.dep.mk> +cleanextra: .PHONY +.if defined(CLEANFILES) && !empty(CLEANFILES) + rm -f ${CLEANFILES} +.endif + ${TARGETS}: # ensure existence .endif # HOSTPROG -- Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost "See the look on my face from staying too long in one place [...] every time the morning breaks I know I'm closer to falling" KT Tunstall, Saving My Face, Drastic Fantastic, 2007.
Attachment:
pgpR6KoTodM1j.pgp
Description: PGP signature