xref: /openbsd/Makefile (revision f10adcc6)
1*f10adcc6Sderaadt#	$OpenBSD: Makefile,v 1.126 2016/10/04 16:54:31 deraadt Exp $
2df930be7Sderaadt
35034ab0fSderaadt#
45034ab0fSderaadt# For more information on building in tricky environments, please see
55034ab0fSderaadt# the list of possible environment variables described in
65034ab0fSderaadt# /usr/share/mk/bsd.README.
75034ab0fSderaadt#
85034ab0fSderaadt# Building recommendations:
95034ab0fSderaadt#
105034ab0fSderaadt# 1) If at all possible, put this source tree in /usr/src.  If /usr/src
1137a1d5d8Sjmc# must be a symbolic link, set BSDSRCDIR in the environment to point to
1237a1d5d8Sjmc# the real location.
135034ab0fSderaadt#
145034ab0fSderaadt# 2) It is also recommended that you compile with objects outside the
155034ab0fSderaadt# source tree. To do this, ensure /usr/obj exists or points to some
165034ab0fSderaadt# area of disk of sufficient size.  Then do "cd /usr/src; make obj".
175034ab0fSderaadt# This will make a symbolic link called "obj" in each directory, as
185034ab0fSderaadt# well as populate the /usr/obj properly with directories for the
195034ab0fSderaadt# objects.
205034ab0fSderaadt#
21b908e61cSart# 3) It is strongly recommended that you build and install a new kernel
22b908e61cSart# before rebuilding your system. Some of the new programs may use new
23b908e61cSart# functionality or depend on API changes that your old kernel doesn't have.
24b908e61cSart#
25b908e61cSart# 4) If you are reasonably sure that things will compile OK, use the
265034ab0fSderaadt# "make build" target supplied here. Good luck.
27d05f021aSmickey#
287797d2abSpirofti# 5) If you want to setup a cross-build environment, there is a "cross-gcc"
297797d2abSpirofti# target available which upon completion of:
3091c7b537Sderaadt#	"make -f Makefile.cross TARGET=<target> cross-gcc"
31d05f021aSmickey# (where <target> is one of the names in the /sys/arch directory) will produce
32d05f021aSmickey# a set of compilation tools along with the includes in the /usr/cross/<target>
333e0db07eSwcobb# directory. The "cross-distrib" target will build cross-tools as well as
343e0db07eSwcobb# binaries for a given <target>.
35d05f021aSmickey#
36094eb183Smickey
375034ab0fSderaadt.include <bsd.own.mk>	# for NOMAN, if it's there.
38df930be7Sderaadt
39df930be7SderaadtSUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share games
40df930be7SderaadtSUBDIR+= gnu
41df930be7Sderaadt
42de206b4fSderaadtSUBDIR+= sys
43df930be7Sderaadt
444f7a1a57Sderaadt.if   make(clean) || make(cleandir) || make(obj)
4584b1e8aeSderaadtSUBDIR+= etc distrib regress
464f7a1a57Sderaadt.endif
474f7a1a57Sderaadt
48df930be7Sderaadtregression-tests:
49df930be7Sderaadt	@echo Running regression tests...
5019806625Sart	@cd ${.CURDIR}/regress && ${MAKE} depend && exec ${MAKE} regress
51df930be7Sderaadt
524ae007f5Sderaadtincludes:
53*f10adcc6Sderaadt	cd ${.CURDIR}/include && ${MAKE} prereq && exec ${MAKE} includes
544ae007f5Sderaadt
550d5e6725Sderaadtbeforeinstall:
56efeb256fSespie	cd ${.CURDIR}/etc && exec ${MAKE} DESTDIR=${DESTDIR} distrib-dirs
57fcf05718Sespie	cd ${.CURDIR}/etc && exec ${MAKE} DESTDIR=${DESTDIR} install-mtree
58efeb256fSespie	cd ${.CURDIR}/include && exec ${MAKE} includes
59df930be7Sderaadt
60df930be7Sderaadtafterinstall:
61df930be7Sderaadt.ifndef NOMAN
62efeb256fSespie	cd ${.CURDIR}/share/man && exec ${MAKE} makedb
6379df76e3Sespie	cd ${.CURDIR}/distrib/sets && exec ${MAKE} makedb
64df930be7Sderaadt.endif
65df930be7Sderaadt
667feaea15Sguenther.ifdef DESTDIR
677feaea15Sguentherbuild:
687feaea15Sguenther	@echo cannot build with DESTDIR set
697feaea15Sguenther	@false
707feaea15Sguenther.else
71df930be7Sderaadtbuild:
7271e87bb9Skstailey.ifdef GLOBAL_AUTOCONF_CACHE
739518c5e7Sangelos	cp /dev/null ${GLOBAL_AUTOCONF_CACHE}
749a76bd19Skstailey.endif
75*f10adcc6Sderaadt	cd ${.CURDIR}/share/mk && exec ${MAKE} install
76*f10adcc6Sderaadt	cd ${.CURDIR}/include && ${MAKE} prereq && exec ${MAKE} includes
77*f10adcc6Sderaadt	${MAKE} cleandir
78efeb256fSespie	cd ${.CURDIR}/lib && ${MAKE} depend && ${MAKE} && \
79*f10adcc6Sderaadt	    NOMAN=1 exec ${MAKE} install
80efeb256fSespie	cd ${.CURDIR}/gnu/lib && ${MAKE} depend && ${MAKE} && \
81*f10adcc6Sderaadt	    NOMAN=1 exec ${MAKE} install
82*f10adcc6Sderaadt	${MAKE} depend && ${MAKE} && exec ${MAKE} install
83*f10adcc6Sderaadt	/bin/sh ${.CURDIR}/distrib/sets/makeetcset ${.CURDIR} ${MAKE}
847feaea15Sguenther.endif
85df930be7Sderaadt
86a222f159SespieCROSS_TARGETS=cross-env cross-dirs cross-obj cross-includes cross-binutils \
87a222f159Sespie	cross-gcc cross-tools cross-lib cross-bin cross-etc-root-var \
88a222f159Sespie	cross-depend cross-clean cross-cleandir
89a222f159Sespie
909c3ce19dSniklas.if !defined(TARGET)
91a222f159Sespie${CROSS_TARGETS}:
92a222f159Sespie	@echo "TARGET must be set for $@"; exit 1
939c3ce19dSniklas.else
94a222f159Sespie. include "Makefile.cross"
953e0db07eSwcobb.endif # defined(TARGET)
969c3ce19dSniklas
97a222f159Sespie.PHONY: ${CROSS_TARGETS} \
98a222f159Sespie	build regression-tests includes beforeinstall afterinstall \
99a222f159Sespie	all depend
100a222f159Sespie
101df930be7Sderaadt.include <bsd.subdir.mk>
102