1a7f2f51fSSepherosa Ziehau# Create forwarding headers for ${SYSDIR}/cpu/${MACHINE_ARCH}/*.h in 2a7f2f51fSSepherosa Ziehau# ${_MACHINE_FWD}/include/machine and share the directory among module build 3a7f2f51fSSepherosa Ziehau# directories. 4a7f2f51fSSepherosa Ziehau# Define _MACHINE_FWD before inclusion of this file. 5a7f2f51fSSepherosa Ziehau.if !defined(_MACHINE_FWD) 6a7f2f51fSSepherosa Ziehau.error you must define _MACHINE_FWD in which to generate forwarding headers. 7a7f2f51fSSepherosa Ziehau.endif 8a7f2f51fSSepherosa Ziehau 9456acd3aSMatthew Dillon# _FWDHDRS fills in missing <machine/BLAH.h> headers from <cpu/BLAH.h>, 10456acd3aSMatthew Dillon# allowing us to omit forwarding-only header files in each platform 11456acd3aSMatthew Dillon# architecture's machine/ directory. 12456acd3aSMatthew Dillon# 13a7f2f51fSSepherosa Ziehau_cpu_hdrs!= echo ${SYSDIR}/cpu/${MACHINE_ARCH}/include/*.h 14a7f2f51fSSepherosa Ziehau_FWDHDRS= 15a7f2f51fSSepherosa Ziehau.for _h in ${_cpu_hdrs} 16a7f2f51fSSepherosa Ziehau_fwd:= ${_MACHINE_FWD}/include/machine/${_h:T} 17a7f2f51fSSepherosa Ziehau_FWDHDRS:= ${_FWDHDRS} ${_fwd} 18a7f2f51fSSepherosa Ziehau${_fwd}: ${_h} 19a7f2f51fSSepherosa Ziehau.endfor 208f4576aaSSepherosa Ziehau 21456acd3aSMatthew Dillon# _LHDRS mimics _LHDRS from /usr/src/include/Makefile, directly linking 22456acd3aSMatthew Dillon# sys/BLAH.h as <BLAH.h> for certain header files. These are used to 23456acd3aSMatthew Dillon# mimic a standard user include topology. Only the virtual kernel 24456acd3aSMatthew Dillon# build uses these. e.g. in order for #include <fcntl.h> to work. 25456acd3aSMatthew Dillon# 26*5c08cc45SSascha Wildner_lhdrs= aio.h errno.h fcntl.h linker_set.h poll.h syslog.h ucontext.h 27456acd3aSMatthew Dillon_LHDRS= 28456acd3aSMatthew Dillon.for _h in ${_lhdrs} 29456acd3aSMatthew Dillon_fwd:= ${_MACHINE_FWD}/include/${_h} 30456acd3aSMatthew Dillon_LHDRS:= ${_LHDRS} ${_fwd} 31456acd3aSMatthew Dillon${_fwd}: ${SYSDIR}/sys/${_h} 32456acd3aSMatthew Dillon.endfor 33456acd3aSMatthew Dillon 34d0aac0ecSYONETANI Tomokazu.ORDER: ${_MACHINE_FWD}/include/machine ${_FWDHDRS} ${_LHDRS} 358f4576aaSSepherosa Ziehau 36a7f2f51fSSepherosa Ziehau${_MACHINE_FWD} ${_MACHINE_FWD}/include/machine: 37a7f2f51fSSepherosa Ziehau @mkdir -p ${.TARGET} 38a7f2f51fSSepherosa Ziehau 39703521daSSimon SchubertFORWARD_HEADERS_COOKIE= ${_MACHINE_FWD}/.done 40703521daSSimon Schubert${FORWARD_HEADERS_COOKIE}: ${_MACHINE_FWD}/include/machine ${_FWDHDRS} ${_LHDRS} 41703521daSSimon Schubert @touch ${.TARGET} 42a7f2f51fSSepherosa Ziehau 43a7f2f51fSSepherosa Ziehau${_FWDHDRS}: 449c9078b1SJohn Marino @(echo "creating machine/ forwarding header ${.TARGET}" 1>&2; \ 459c9078b1SJohn Marino echo "/*" ; \ 469c9078b1SJohn Marino echo " * CONFIG-GENERATED FILE, DO NOT EDIT" ; \ 479c9078b1SJohn Marino echo " */" ; \ 489c9078b1SJohn Marino echo ; \ 499c9078b1SJohn Marino echo "#ifndef _MACHINE_${.TARGET:T:S/./_/g:tu}_" ; \ 509c9078b1SJohn Marino echo "#define _MACHINE_${.TARGET:T:S/./_/g:tu}_" ; \ 519c9078b1SJohn Marino echo "#include <cpu/${.TARGET:T}>" ; \ 529c9078b1SJohn Marino echo "#endif" ; \ 53a265e6ddSMatthew Dillon echo) > ${.TARGET}.${.MAKE.PID} 54a265e6ddSMatthew Dillon @mv -f ${.TARGET}.${.MAKE.PID} ${.TARGET} 55456acd3aSMatthew Dillon 56456acd3aSMatthew Dillon${_LHDRS}: 579c9078b1SJohn Marino @(echo "creating sys/ forwarding header ${.TARGET}" 1>&2; \ 589c9078b1SJohn Marino echo "/*" ; \ 599c9078b1SJohn Marino echo " * CONFIG-GENERATED FILE, DO NOT EDIT" ; \ 609c9078b1SJohn Marino echo " */" ; \ 619c9078b1SJohn Marino echo ; \ 629c9078b1SJohn Marino echo "#ifndef _${.TARGET:T:S/./_/g:tu}_" ; \ 639c9078b1SJohn Marino echo "#define _${.TARGET:T:S/./_/g:tu}_" ; \ 649c9078b1SJohn Marino echo "#include <sys/${.TARGET:T}>" ; \ 659c9078b1SJohn Marino echo "#endif" ; \ 66a265e6ddSMatthew Dillon echo) > ${.TARGET}.${.MAKE.PID} 67a265e6ddSMatthew Dillon @mv -f ${.TARGET}.${.MAKE.PID} ${.TARGET} 68