xref: /freebsd/contrib/bmake/mk/inc.mk (revision c59c3bf34db360695f07735bebc76a768cac5afc)
1*c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause
2*c59c3bf3SSimon J. Gerraty#
3*c59c3bf3SSimon J. Gerraty# $Id: inc.mk,v 1.9 2024/02/17 17:26:57 sjg Exp $
43cbdda60SSimon J. Gerraty#
53cbdda60SSimon J. Gerraty#	@(#) Copyright (c) 2008, Simon J. Gerraty
63cbdda60SSimon J. Gerraty#
73cbdda60SSimon J. Gerraty#	This file is provided in the hope that it will
83cbdda60SSimon J. Gerraty#	be of use.  There is absolutely NO WARRANTY.
93cbdda60SSimon J. Gerraty#	Permission to copy, redistribute or otherwise
103cbdda60SSimon J. Gerraty#	use this file is hereby granted provided that
113cbdda60SSimon J. Gerraty#	the above copyright notice and this notice are
123cbdda60SSimon J. Gerraty#	left intact.
133cbdda60SSimon J. Gerraty#
143cbdda60SSimon J. Gerraty#	Please send copies of changes and bug-fixes to:
153cbdda60SSimon J. Gerraty#	sjg@crufty.net
163cbdda60SSimon J. Gerraty#
173cbdda60SSimon J. Gerraty
183cbdda60SSimon J. Gerraty.include <init.mk>
193cbdda60SSimon J. Gerraty
203cbdda60SSimon J. Gerraty.if !empty(LIBOWN)
213cbdda60SSimon J. GerratyINC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
223cbdda60SSimon J. Gerraty.endif
233cbdda60SSimon J. GerratyINCMODE ?= 444
243cbdda60SSimon J. GerratyINC_COPY ?= -C
253cbdda60SSimon J. GerratyINCSDIR ?= ${INCDIR}
263cbdda60SSimon J. Gerraty
27cac6fd11SSimon J. GerratySTAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR}
28cac6fd11SSimon J. Gerraty
29cac6fd11SSimon J. Gerraty# accommodate folk used to freebsd
30cac6fd11SSimon J. GerratyINCGROUPS ?= ${INCSGROUPS:UINCS}
31cac6fd11SSimon J. GerratyINCGROUPS := ${INCGROUPS:O:u}
32cac6fd11SSimon J. Gerraty
33cac6fd11SSimon J. Gerraty.if !target(buildincludes)
34cac6fd11SSimon J. Gerraty.for group in ${INCGROUPS}
35cac6fd11SSimon J. Gerratybuildincludes: ${${group}}
36cac6fd11SSimon J. Gerraty.endfor
37cac6fd11SSimon J. Gerraty.endif
38cac6fd11SSimon J. Gerratybuildincludes:
39cac6fd11SSimon J. Gerratyincludes: buildincludes
40cac6fd11SSimon J. Gerraty
413cbdda60SSimon J. Gerraty.if !target(incinstall)
42cac6fd11SSimon J. Gerraty.for group in ${INCGROUPS}
43cac6fd11SSimon J. Gerraty.if !empty(${group})
44cac6fd11SSimon J. Gerraty.if ${group} != "INC"
45cac6fd11SSimon J. Gerraty${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN}
46cac6fd11SSimon J. Gerraty${group}DIR ?= ${INCDIR}
473cbdda60SSimon J. Gerraty.endif
48cac6fd11SSimon J. Gerraty# incase we are staging
49cac6fd11SSimon J. GerratySTAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
50cac6fd11SSimon J. Gerraty
51cac6fd11SSimon J. Gerraty.for header in ${${group}:O:u}
52cac6fd11SSimon J. Gerraty${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN}
53cac6fd11SSimon J. Gerraty${group}DIR.${header:T} ?= ${${group}DIR}
54cac6fd11SSimon J. Gerratyinc_mkdir_list += ${${group}DIR.${header:T}}
55cac6fd11SSimon J. Gerraty
56cac6fd11SSimon J. Gerraty.if defined(${group}NAME.${header:T})
57cac6fd11SSimon J. GerratySTAGE_AS_SETS += ${group}
58cac6fd11SSimon J. GerratySTAGE_AS_${header} = ${${group}NAME.${header:T}}
59cac6fd11SSimon J. Gerratystage_as.${group}: ${header}
60cac6fd11SSimon J. Gerraty
61cac6fd11SSimon J. Gerratyincinstall: incinstall.${group}.${header:T}
62cac6fd11SSimon J. Gerratyincinstall.${group}.${header:T}: ${header} inc_mkdirs
63cac6fd11SSimon J. Gerraty	${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}}
64cac6fd11SSimon J. Gerraty
65cac6fd11SSimon J. Gerraty.else
66cac6fd11SSimon J. GerratySTAGE_SETS += ${group}
67cac6fd11SSimon J. Gerratystage_files.${group}: ${header}
68cac6fd11SSimon J. Gerratyincinstall.${group}: ${header}
69cac6fd11SSimon J. Gerratyincinstall: incinstall.${group}
703cbdda60SSimon J. Gerraty.endif
71cac6fd11SSimon J. Gerraty
72cac6fd11SSimon J. Gerraty.endfor				# header
73cac6fd11SSimon J. Gerraty
74cac6fd11SSimon J. Gerratyincinstall.${group}: inc_mkdirs
75cac6fd11SSimon J. Gerraty	${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \
76cac6fd11SSimon J. Gerraty	${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR}
77cac6fd11SSimon J. Gerraty
78cac6fd11SSimon J. Gerraty.endif				# !empty
79cac6fd11SSimon J. Gerraty.endfor				# group
80cac6fd11SSimon J. Gerraty
81cac6fd11SSimon J. Gerratyinc_mkdirs:
82cac6fd11SSimon J. Gerraty	@for d in ${inc_mkdir_list:O:u}; do \
83cac6fd11SSimon J. Gerraty		test -d ${DESTDIR}$$d || \
84cac6fd11SSimon J. Gerraty		${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
85cac6fd11SSimon J. Gerraty	done
86cac6fd11SSimon J. Gerraty
87cac6fd11SSimon J. Gerraty.endif				# !target(incinstall)
88cac6fd11SSimon J. Gerraty
89cac6fd11SSimon J. Gerratybeforeinstall:
90cac6fd11SSimon J. Gerratyrealinstall:	incinstall
91cac6fd11SSimon J. Gerraty.ORDER: beforeinstall incinstall
92