1# $Id: inc.mk,v 1.8 2020/08/19 17:51:53 sjg Exp $ 2# 3# @(#) Copyright (c) 2008, Simon J. Gerraty 4# 5# This file is provided in the hope that it will 6# be of use. There is absolutely NO WARRANTY. 7# Permission to copy, redistribute or otherwise 8# use this file is hereby granted provided that 9# the above copyright notice and this notice are 10# left intact. 11# 12# Please send copies of changes and bug-fixes to: 13# sjg@crufty.net 14# 15 16.include <init.mk> 17 18.if !empty(LIBOWN) 19INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP} 20.endif 21INCMODE ?= 444 22INC_COPY ?= -C 23INCSDIR ?= ${INCDIR} 24 25STAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR} 26 27# accommodate folk used to freebsd 28INCGROUPS ?= ${INCSGROUPS:UINCS} 29INCGROUPS := ${INCGROUPS:O:u} 30 31.if !target(buildincludes) 32.for group in ${INCGROUPS} 33buildincludes: ${${group}} 34.endfor 35.endif 36buildincludes: 37includes: buildincludes 38 39.if !target(incinstall) 40.for group in ${INCGROUPS} 41.if !empty(${group}) 42.if ${group} != "INC" 43${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN} 44${group}DIR ?= ${INCDIR} 45.endif 46# incase we are staging 47STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} 48 49.for header in ${${group}:O:u} 50${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN} 51${group}DIR.${header:T} ?= ${${group}DIR} 52inc_mkdir_list += ${${group}DIR.${header:T}} 53 54.if defined(${group}NAME.${header:T}) 55STAGE_AS_SETS += ${group} 56STAGE_AS_${header} = ${${group}NAME.${header:T}} 57stage_as.${group}: ${header} 58 59incinstall: incinstall.${group}.${header:T} 60incinstall.${group}.${header:T}: ${header} inc_mkdirs 61 ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}} 62 63.else 64STAGE_SETS += ${group} 65stage_files.${group}: ${header} 66incinstall.${group}: ${header} 67incinstall: incinstall.${group} 68.endif 69 70.endfor # header 71 72incinstall.${group}: inc_mkdirs 73 ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \ 74 ${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR} 75 76.endif # !empty 77.endfor # group 78 79inc_mkdirs: 80 @for d in ${inc_mkdir_list:O:u}; do \ 81 test -d ${DESTDIR}$$d || \ 82 ${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ 83 done 84 85.endif # !target(incinstall) 86 87beforeinstall: 88realinstall: incinstall 89.ORDER: beforeinstall incinstall 90