1# $OpenBSD: Makefile,v 1.136 2020/04/05 20:14:14 deraadt Exp $ 2 3# 4# For more information on building in tricky environments, please see 5# the list of possible environment variables described in 6# /usr/share/mk/bsd.README. 7# 8# Building recommendations: 9# 10# 1) If at all possible, put this source tree in /usr/src. If /usr/src 11# must be a symbolic link, set BSDSRCDIR in the environment to point to 12# the real location. 13# 14# 2) It is also recommended that you compile with objects outside the 15# source tree. To do this, ensure /usr/obj exists or points to some 16# area of disk of sufficient size. Then do "cd /usr/src; make obj". 17# This will make a symbolic link called "obj" in each directory, as 18# well as populate the /usr/obj properly with directories for the 19# objects. 20# 21# 3) It is strongly recommended that you build and install a new kernel 22# before rebuilding your system. Some of the new programs may use new 23# functionality or depend on API changes that your old kernel doesn't have. 24# 25# 4) If you are reasonably sure that things will compile OK, use the 26# "make build" target supplied here. Good luck. 27# 28# 5) If you want to setup a cross-build environment, there is a "cross-gcc" 29# target available which upon completion of: 30# "make -f Makefile.cross TARGET=<target> cross-gcc" 31# (where <target> is one of the names in the /sys/arch directory) will produce 32# a set of compilation tools along with the includes in the /usr/cross/<target> 33# directory. The "cross-distrib" target will build cross-tools as well as 34# binaries for a given <target>. 35# 36 37.include <bsd.own.mk> # for NOMAN, if it's there. 38 39SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share games 40SUBDIR+= gnu 41 42SUBDIR+= sys 43 44.if make(clean) || make(cleandir) || make(obj) 45SUBDIR+= etc distrib regress 46.endif 47 48regression-tests: 49 @echo Running regression tests... 50 @cd ${.CURDIR}/regress && ${MAKE} depend && exec ${MAKE} regress 51 52includes: 53 cd ${.CURDIR}/include && \ 54 su ${BUILDUSER} -c 'exec ${MAKE} prereq' && \ 55 exec ${MAKE} includes 56 57beforeinstall: 58 cd ${.CURDIR}/etc && exec ${MAKE} DESTDIR=${DESTDIR} distrib-dirs 59 cd ${.CURDIR}/etc && exec ${MAKE} DESTDIR=${DESTDIR} install-mtree 60 cd ${.CURDIR}/include && exec ${MAKE} includes 61 62afterinstall: 63.ifndef NOMAN 64 cd ${.CURDIR}/share/man && exec ${MAKE} makedb 65 cd ${.CURDIR}/distrib/sets && exec ${MAKE} makedb 66.endif 67 68.ifdef DESTDIR 69build: 70 @echo cannot build with DESTDIR set 71 @false 72.else 73build: 74 umask ${WOBJUMASK}; exec ${MAKE} do-build 75 76do-build: 77.ifdef GLOBAL_AUTOCONF_CACHE 78 ${INSTALL} -c -o ${BUILDUSER} -g ${WOBJGROUP} -m 664 /dev/null \ 79 ${GLOBAL_AUTOCONF_CACHE} 80.endif 81 @if [[ `id -u` -ne 0 ]]; then \ 82 echo $@ must be called by root >&2; \ 83 false; \ 84 fi 85 cd ${.CURDIR}/share/mk && exec ${MAKE} install 86 exec ${MAKE} cleandir 87 exec ${MAKE} includes 88 cd ${.CURDIR}/lib && \ 89 su ${BUILDUSER} -c 'exec ${MAKE}' && \ 90 NOMAN=1 exec ${MAKE} install 91 /sbin/ldconfig -R 92 cd ${.CURDIR}/gnu/lib && \ 93 su ${BUILDUSER} -c 'exec ${MAKE}' && \ 94 NOMAN=1 exec ${MAKE} install 95 /sbin/ldconfig -R 96 su ${BUILDUSER} -c 'exec ${MAKE}' && \ 97 exec ${MAKE} install 98 /bin/sh ${.CURDIR}/distrib/sets/makeetcset ${.CURDIR} ${MAKE} 99.endif 100 101CROSS_TARGETS=cross-env cross-dirs cross-obj cross-includes cross-binutils \ 102 cross-gcc cross-tools cross-lib cross-bin cross-etc-root-var \ 103 cross-depend cross-clean cross-cleandir 104 105.if !defined(TARGET) 106${CROSS_TARGETS}: 107 @echo "TARGET must be set for $@"; exit 1 108.else 109. include "Makefile.cross" 110.endif # defined(TARGET) 111 112.PHONY: ${CROSS_TARGETS} \ 113 build regression-tests includes beforeinstall afterinstall \ 114 all do-build 115 116.include <bsd.subdir.mk> 117