]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/build/Makefile
Include eventhandler.h in more compilation units
[FreeBSD/FreeBSD.git] / tools / build / Makefile
1 # $FreeBSD$
2
3 .PATH: ${.CURDIR}/../../include
4
5 LIB=            egacy
6 SRC=
7 INCSGROUPS=     INCS SYSINCS CASPERINC
8 INCS=
9
10 SYSINCSDIR=     ${INCLUDEDIR}/sys
11 CASPERINCDIR=   ${INCLUDEDIR}/casper
12
13 BOOTSTRAPPING?= 0
14
15 _WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true
16 .if ${_WITH_PWCACHEDB} == 0
17 .PATH: ${.CURDIR}/../../contrib/libc-pwcache
18 CFLAGS+=        -I${.CURDIR}/../../contrib/libc-pwcache \
19                 -I${.CURDIR}/../../lib/libc/include
20 SRCS+=          pwcache.c
21 .endif
22
23 _WITH_STRSVIS!= grep -c strsvis /usr/include/vis.h || true
24 .if ${_WITH_STRSVIS} == 0
25 .PATH: ${.CURDIR}/../../contrib/libc-vis
26 SRCS+=          vis.c
27 CFLAGS+=        -I${.CURDIR}/../../contrib/libc-vis \
28                 -I${.CURDIR}/../../lib/libc/include
29 .endif
30
31 _WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true
32 .if ${_WITH_REALLOCARRAY} == 0
33 .PATH: ${.CURDIR}/../../lib/libc/stdlib
34 INCS+=          stdlib.h
35 SRCS+=          reallocarray.c
36 CFLAGS+=        -I${.CURDIR}/../../lib/libc/include
37 .endif
38
39 _WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true
40 .if ${_WITH_UTIMENS} == 0
41 SYSINCS+=       stat.h
42 SRCS+=          futimens.c utimensat.c
43 .endif
44
45 _WITH_EXPLICIT_BZERO!= grep -c explicit_bzero /usr/include/strings.h || true
46 .if ${_WITH_EXPLICIT_BZERO} == 0
47 .PATH: ${SRCTOP}/sys/libkern
48 INCS+=          strings.h
49 SRCS+=          explicit_bzero.c
50 .endif
51
52 .if exists(/usr/include/capsicum_helpers.h)
53 _WITH_CAPH_ENTER!= grep -c caph_enter /usr/include/capsicum_helpers.h || true
54 .endif
55 .if !defined(_WITH_CAPH_ENTER) || ${_WITH_CAPH_ENTER} == 0
56 .PATH: ${SRCTOP}/lib/libcapsicum
57 INCS+=          capsicum_helpers.h
58 .PATH: ${SRCTOP}/lib/libcasper/libcasper
59 INCS+=          libcasper.h
60 .endif
61
62 CASPERINC+=     ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h
63
64 .if empty(SRCS)
65 SRCS=           dummy.c
66 .endif
67
68 .if defined(CROSS_BUILD_TESTING)
69 SUBDIR=         cross-build
70 .endif
71
72 # Needed to build config (since it uses libnv)
73 SYSINCS+=       ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h
74
75 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
76 # accidentally run tools that are incompatible but happen to be in $PATH.
77 # This is especially important when building on Linux/MacOS where many of the
78 # programs used during the build accept different flags or generate different
79 # output. On those platforms we only symlink the tools known to be compatible
80 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
81 # from the FreeBSD sources during the bootstrap-tools stage.
82
83 # basic commands: It is fine to use the host version for all of these even on
84 # Linux/MacOS since we only use flags that are supported by all of them.
85 _host_tools_to_symlink= basename bzip2 bunzip2 chmod chown cmp comm cp date \
86         dirname echo env false find fmt gzip gunzip head hostname id ln ls \
87         mkdir mv nice patch rm realpath sh sleep stat tee touch tr true uname \
88         uniq wc which
89
90 # We also need a symlink to the absolute path to the make binary used for
91 # the toplevel makefile. This is not necessarily the same as `which make`
92 # since e.g. on Linux and MacOS that will be GNU make.
93 _make_abs!=     which "${MAKE}"
94 _host_abs_tools_to_symlink=     ${_make_abs}:make ${_make_abs}:bmake
95
96 host-symlinks:
97         @echo "Linking host tools into ${DESTDIR}/bin"
98 .for _tool in ${_host_tools_to_symlink}
99         @if [ ! -e "${DESTDIR}/bin/${_tool}" ]; then \
100                 source_path=`which ${_tool}`; \
101                 if [ ! -e "$${source_path}" ] ; then \
102                         echo "Cannot find host tool '${_tool}'"; false; \
103                 fi; \
104                 ln -sfnv "$${source_path}" "${DESTDIR}/bin/${_tool}"; \
105         fi
106 .endfor
107 .for _tool in ${_host_abs_tools_to_symlink}
108         @source_path="${_tool:S/:/ /:[1]}"; \
109         target_path="${DESTDIR}/bin/${_tool:S/:/ /:[2]}"; \
110         if [ ! -e "$${target_path}" ] ; then \
111                 if [ ! -e "$${source_path}" ] ; then \
112                         echo "Host tool '${src_path}' is missing"; false; \
113                 fi; \
114                 ln -sfnv "$${source_path}" "$${target_path}"; \
115         fi
116 .endfor
117
118 # Create all the directories that are needed during the legacy, bootstrap-tools
119 # and cross-tools stages. We do this here using mkdir since mtree may not exist
120 # yet (this happens if we are crossbuilding from Linux/Mac).
121 installdirs:
122 .for _dir in bin usr/lib usr/include usr/include/casper lib/geom lib/casper
123         mkdir -p "${DESTDIR}/${_dir}"
124 .endfor
125 # Link usr/bin, sbin, and usr/sbin to bin so that it doesn't matter whether a
126 # bootstrap tool was added to WORLTMP with a symlink or by building it in the
127 # bootstrap-tools phase. We could also overrride BINDIR when building bootstrap
128 # tools but adding the symlinks is easier and means all tools are also
129 # in the directory that they are installed to normally.
130
131 .for _dir in sbin usr/sbin usr/bin
132 # delete existing directories from before r340157
133         @if [ ! -L ${DESTDIR}/${_dir} ]; then \
134             echo "removing old non-symlink ${DESTDIR}/${_dir}"; \
135             rm -rf "${DESTDIR}/${_dir}"; \
136         fi
137 .endfor
138         ln -sfn bin ${DESTDIR}/sbin
139         ln -sfn ../bin ${DESTDIR}/usr/bin
140         ln -sfn ../bin ${DESTDIR}/usr/sbin
141 .for _group in ${INCSGROUPS:NINCS}
142         mkdir -p "${DESTDIR}/${${_group}DIR}"
143 .endfor
144
145 .include <bsd.lib.mk>