forked from bitrig/bitrig
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
164 lines (142 loc) · 5.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# $OpenBSD: Makefile,v 1.124 2015/06/02 06:10:14 deraadt Exp $
#
# For more information on building in tricky environments, please see
# the list of possible environment variables described in
# /usr/share/mk/bsd.README.
#
# Building recommendations:
#
# 1) If at all possible, put this source tree in /usr/src. If /usr/src
# must be a symbolic link, set BSDSRCDIR in the environment to point to
# the real location.
#
# 2) It is also recommended that you compile with objects outside the
# source tree. To do this, ensure /usr/obj exists or points to some
# area of disk of sufficient size. Then do "cd /usr/src; make obj".
# This will make a symbolic link called "obj" in each directory, as
# well as populate the /usr/obj properly with directories for the
# objects.
#
# 3) It is strongly recommended that you build and install a new kernel
# before rebuilding your system. Some of the new programs may use new
# functionality or depend on API changes that your old kernel doesn't have.
#
# 4) If you are reasonably sure that things will compile OK, use the
# "make build" target supplied here. Good luck.
#
# 5) If you want to setup a cross-build environment, there is a "cross-gcc"
# target available which upon completion of:
# "make -f Makefile.cross TARGET=<target> cross-gcc"
# (where <target> is one of the names in the /sys/arch directory) will produce
# a set of compilation tools along with the includes in the /usr/cross/<target>
# directory. The "cross-distrib" target will build cross-tools as well as
# binaries for a given <target>.
#
.include <bsd.own.mk> # for NOMAN, if it's there.
SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share games
SUBDIR+= gnu
SUBDIR+= sys
.if make(clean) || make(cleandir) || make(obj)
SUBDIR+= distrib regress
.endif
regression-tests:
@echo Running regression tests...
@cd ${.CURDIR}/regress && ${MAKE} depend && exec ${MAKE} regress
includes:
cd ${.CURDIR}/include && ${MAKE} prereq && exec ${SUDO} ${MAKE} includes
beforeinstall:
cd ${.CURDIR}/etc && exec ${MAKE} DESTDIR=${DESTDIR} distrib-dirs
cd ${.CURDIR}/etc && exec ${MAKE} DESTDIR=${DESTDIR} install-mtree
cd ${.CURDIR}/include && exec ${MAKE} includes
afterinstall:
.ifndef NOMAN
cd ${.CURDIR}/share/man && exec ${MAKE} makedb
cd ${.CURDIR}/distrib/sets && exec ${MAKE} makedb
.endif
.ifdef DESTDIR
build buildworld:
@echo cannot build with DESTDIR set
@false
.else
mk_files:
cd ${.CURDIR}/share/mk && exec ${SUDO} ${MAKE} install
build: mk_files
.ifdef GLOBAL_AUTOCONF_CACHE
cp /dev/null ${GLOBAL_AUTOCONF_CACHE}
.endif
cd ${.CURDIR}/usr.bin/clang && ${SUDO} NOMAN=1 ${MAKE} snapstrap && \
exec ${SUDO} ${MAKE} snapclean
cd ${.CURDIR}/include && ${MAKE} prereq && exec ${SUDO} ${MAKE} includes
${SUDO} ${MAKE} cleandir
cd ${.CURDIR}/libexec/ld.so && \
SKIPDIR="ldd ldconfig" ${MAKE} depend && \
SKIPDIR="ldd ldconfig" ${MAKE} && \
${SUDO} SKIPDIR="ldd ldconfig" NOMAN=1 ${MAKE} install
cd ${.CURDIR}/lib/csu && ${MAKE} depend && ${MAKE} && \
NOMAN=1 exec ${SUDO} ${MAKE} install
cd ${.CURDIR}/lib/libc && ${MAKE} depend && ${MAKE} && \
NOMAN=1 exec ${SUDO} ${MAKE} install
cd ${.CURDIR}/lib && ${MAKE} depend && ${MAKE} && \
NOMAN=1 exec ${SUDO} ${MAKE} install
${MAKE} depend && ${MAKE} && exec ${SUDO} ${MAKE} install
${SUDO} /bin/sh ${.CURDIR}/distrib/sets/makeetcset ${.CURDIR} ${MAKE}
.ORDER: mk_files pre_world build
buildworld: mk_files pre_world build
pre_world:
${SUDO} rm -rf /usr/obj/*
${MAKE} obj >/dev/null
cd ${.CURDIR}/etc && ${SUDO} DESTDIR=/ ${MAKE} distrib-dirs
.endif
CROSS_TARGETS=cross-env cross-dirs cross-obj cross-includes cross-binutils \
cross-gcc cross-tools cross-lib cross-bin cross-etc-root-var \
cross-distrib cross-depend cross-clean cross-cleandir
.if !defined(TARGET)
${CROSS_TARGETS}:
@echo "TARGET must be set for $@"; exit 1
.else
. include "Makefile.cross"
.endif # defined(TARGET)
.PHONY: ${CROSS_TARGETS} \
build regression-tests includes beforeinstall afterinstall \
all depend
.if exists(/usr/snap)
SNAPDIR?=/usr/snap
.endif
.if !defined(SNAPDIR)
snapinfo snap do_snap do_snap_rel:
@echo "SNAPDIR must be defined or create the directory /usr/snap"
@exit 1
.else
.NOTPARALLEL:
ARCH!= uname -m
SNAPARCHDIR=${SNAPDIR}/${ARCH}
.if defined(SNAPDIRSUFFIX)
SNAPROOTDIR=${SNAPARCHDIR}/root.${SNAPDIRSUFFIX}
SNAPRELDIR=${SNAPARCHDIR}/release.${SNAPDIRSUFFIX}
SNAPLOGFILE= echo ${SNAPARCHDIR}/buildlog.${SNAPDIRSUFFIX}
.else
SNAPROOTDIR=${SNAPARCHDIR}/root
.if defined(SNAPDATE)
SNAPRELDIR!= echo ${SNAPARCHDIR}/release.$$(date "+%y%m%d%H%M")
.else
SNAPRELDIR!= echo ${SNAPARCHDIR}/release
.endif
SNAPLOGFILE != echo ${SNAPARCHDIR}/buildlog.$$(date "+%y%m%d%H%M")
.endif
snapinfo:
@echo rootdir = ${SNAPROOTDIR}
@echo reldir = ${SNAPRELDIR}
@echo logfile = ${SNAPLOGFILE}
snap:
mkdir -p ${SNAPARCHDIR}
${MAKE} do_snap 2>&1 | tee ${SNAPLOGFILE}
do_snap: buildworld do_snap_rel
do_snap_rel:
date
rm -rf ${SNAPROOTDIR}
mkdir -p ${SNAPROOTDIR}
mkdir -p ${SNAPRELDIR}
cd ${.CURDIR}/etc && DESTDIR=${SNAPROOTDIR} RELEASEDIR=${SNAPRELDIR} ${MAKE} release
cd ${.CURDIR}/distrib/sets && DESTDIR=${SNAPROOTDIR} sh checkflist
.endif
.include <bsd.subdir.mk>