xref: /dflybsd-src/contrib/bmake/mk/inc.mk (revision a34d5fb143d34c0e1d2580296c500e2c8a5bc5dc)
1*a34d5fb1SAntonio Huete Jimenez# $Id: inc.mk,v 1.8 2020/08/19 17:51:53 sjg Exp $
25f1e34d9SAlexandre Perrin#
35f1e34d9SAlexandre Perrin#	@(#) Copyright (c) 2008, Simon J. Gerraty
45f1e34d9SAlexandre Perrin#
55f1e34d9SAlexandre Perrin#	This file is provided in the hope that it will
65f1e34d9SAlexandre Perrin#	be of use.  There is absolutely NO WARRANTY.
75f1e34d9SAlexandre Perrin#	Permission to copy, redistribute or otherwise
85f1e34d9SAlexandre Perrin#	use this file is hereby granted provided that
95f1e34d9SAlexandre Perrin#	the above copyright notice and this notice are
105f1e34d9SAlexandre Perrin#	left intact.
115f1e34d9SAlexandre Perrin#
125f1e34d9SAlexandre Perrin#	Please send copies of changes and bug-fixes to:
135f1e34d9SAlexandre Perrin#	sjg@crufty.net
145f1e34d9SAlexandre Perrin#
155f1e34d9SAlexandre Perrin
165f1e34d9SAlexandre Perrin.include <init.mk>
175f1e34d9SAlexandre Perrin
185f1e34d9SAlexandre Perrin.if !empty(LIBOWN)
195f1e34d9SAlexandre PerrinINC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
205f1e34d9SAlexandre Perrin.endif
215f1e34d9SAlexandre PerrinINCMODE ?= 444
225f1e34d9SAlexandre PerrinINC_COPY ?= -C
235f1e34d9SAlexandre PerrinINCSDIR ?= ${INCDIR}
245f1e34d9SAlexandre Perrin
25ca58f742SDaniel FojtSTAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR}
26ca58f742SDaniel Fojt
27ca58f742SDaniel Fojt# accommodate folk used to freebsd
28ca58f742SDaniel FojtINCGROUPS ?= ${INCSGROUPS:UINCS}
29ca58f742SDaniel FojtINCGROUPS := ${INCGROUPS:O:u}
30ca58f742SDaniel Fojt
31ca58f742SDaniel Fojt.if !target(buildincludes)
32ca58f742SDaniel Fojt.for group in ${INCGROUPS}
33ca58f742SDaniel Fojtbuildincludes: ${${group}}
34ca58f742SDaniel Fojt.endfor
35ca58f742SDaniel Fojt.endif
36ca58f742SDaniel Fojtbuildincludes:
37ca58f742SDaniel Fojtincludes: buildincludes
38ca58f742SDaniel Fojt
395f1e34d9SAlexandre Perrin.if !target(incinstall)
40ca58f742SDaniel Fojt.for group in ${INCGROUPS}
41ca58f742SDaniel Fojt.if !empty(${group})
42ca58f742SDaniel Fojt.if ${group} != "INC"
43ca58f742SDaniel Fojt${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN}
44ca58f742SDaniel Fojt${group}DIR ?= ${INCDIR}
455f1e34d9SAlexandre Perrin.endif
46ca58f742SDaniel Fojt# incase we are staging
47ca58f742SDaniel FojtSTAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
48ca58f742SDaniel Fojt
49ca58f742SDaniel Fojt.for header in ${${group}:O:u}
50ca58f742SDaniel Fojt${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN}
51ca58f742SDaniel Fojt${group}DIR.${header:T} ?= ${${group}DIR}
52ca58f742SDaniel Fojtinc_mkdir_list += ${${group}DIR.${header:T}}
53ca58f742SDaniel Fojt
54ca58f742SDaniel Fojt.if defined(${group}NAME.${header:T})
55ca58f742SDaniel FojtSTAGE_AS_SETS += ${group}
56ca58f742SDaniel FojtSTAGE_AS_${header} = ${${group}NAME.${header:T}}
57ca58f742SDaniel Fojtstage_as.${group}: ${header}
58ca58f742SDaniel Fojt
59ca58f742SDaniel Fojtincinstall: incinstall.${group}.${header:T}
60ca58f742SDaniel Fojtincinstall.${group}.${header:T}: ${header} inc_mkdirs
61ca58f742SDaniel Fojt	${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}}
62ca58f742SDaniel Fojt
63ca58f742SDaniel Fojt.else
64ca58f742SDaniel FojtSTAGE_SETS += ${group}
65ca58f742SDaniel Fojtstage_files.${group}: ${header}
66ca58f742SDaniel Fojtincinstall.${group}: ${header}
67ca58f742SDaniel Fojtincinstall: incinstall.${group}
685f1e34d9SAlexandre Perrin.endif
69ca58f742SDaniel Fojt
70ca58f742SDaniel Fojt.endfor				# header
71ca58f742SDaniel Fojt
72ca58f742SDaniel Fojtincinstall.${group}: inc_mkdirs
73ca58f742SDaniel Fojt	${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \
74ca58f742SDaniel Fojt	${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR}
75ca58f742SDaniel Fojt
76ca58f742SDaniel Fojt.endif				# !empty
77ca58f742SDaniel Fojt.endfor				# group
78ca58f742SDaniel Fojt
79ca58f742SDaniel Fojtinc_mkdirs:
80ca58f742SDaniel Fojt	@for d in ${inc_mkdir_list:O:u}; do \
81ca58f742SDaniel Fojt		test -d ${DESTDIR}$$d || \
82ca58f742SDaniel Fojt		${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
83ca58f742SDaniel Fojt	done
84ca58f742SDaniel Fojt
85ca58f742SDaniel Fojt.endif				# !target(incinstall)
86ca58f742SDaniel Fojt
87ca58f742SDaniel Fojtbeforeinstall:
88ca58f742SDaniel Fojtrealinstall:	incinstall
89ca58f742SDaniel Fojt.ORDER: beforeinstall incinstall
90