]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/Makefile
zfs: merge openzfs/zfs@a382e2119
[FreeBSD/FreeBSD.git] / etc / Makefile
1
2 .include <src.opts.mk>
3 .include <src.tools.mk>
4
5 .include <bsd.compat.pre.mk>
6
7 FILESGROUPS=    FILES
8 NLS_ALIASES=    POSIX C \
9                 en_US.US_ASCII C
10
11 # No need as it is empty and just causes rebuilds since this file does so much.
12 UPDATE_DEPENDFILE=      no
13
14 SUBDIR+=termcap
15 .if ${MK_SENDMAIL} != "no"
16 SUBDIR+=sendmail
17 .endif
18
19 # NB: keep these sorted by MK_* knobs
20
21 ETCMAIL=aliases
22 .if ${MK_SENDMAIL} != "no"
23 ETCMAIL+=Makefile README access.sample virtusertable.sample \
24         mailertable.sample
25 .endif
26
27 # Special top level files for FreeBSD
28 FREEBSD=COPYRIGHT
29
30 # Sanitize DESTDIR
31 DESTDIR:=       ${DESTDIR:C://*:/:g}
32
33 afterinstall:
34 .if ${MK_MAN} != "no"
35         ${_+_}cd ${SRCTOP}/share/man; ${MAKE} makedb
36 .endif
37
38 distribute:
39         # Avoid installing tests here; "make distribution" will do this and
40         # correctly place them in the right location.
41         ${_+_}cd ${.CURDIR} ; ${MAKE} MK_TESTS=no install \
42             DESTDIR=${DISTDIR}/${DISTRIBUTION}
43         ${_+_}cd ${.CURDIR} ; ${MAKE} distribution DESTDIR=${DISTDIR}/${DISTRIBUTION}
44
45 .include <bsd.endian.mk>
46
47 .if defined(NO_ROOT)
48 METALOG.add?=   cat -l >> ${METALOG}
49 .endif
50
51 distribution:
52 .if !defined(DESTDIR)
53         @echo "set DESTDIR before running \"make ${.TARGET}\""
54         @false
55 .endif
56         ${_+_}cd ${.CURDIR}/gss; ${MAKE} install
57         ${_+_}cd ${.CURDIR}/mtree; ${MAKE} install
58         ${_+_}cd ${SRCTOP}/share/termcap; ${MAKE} etc-termcap
59         ${_+_}cd ${SRCTOP}/usr.sbin/rmt; ${MAKE} etc-rmt
60         ${INSTALL_SYMLINK} -T "package=runtime" ../var/run/os-release \
61                 ${DESTDIR}/etc/os-release
62 .if ${MK_UNBOUND} != "no"
63         if [ ! -e ${DESTDIR}/etc/unbound ]; then \
64                 ${INSTALL_SYMLINK} -T "package=unbound" \
65                 ../var/unbound ${DESTDIR}/etc/unbound; \
66         fi
67 .endif
68 .if ${MK_SENDMAIL} != "no"
69         ${_+_}cd ${.CURDIR}/sendmail; ${MAKE} distribution
70 .endif
71 .if ${MK_KERBEROS} != "no"
72         cd ${.CURDIR}/root; \
73             ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
74                 -T "package=runtime" \
75                 dot.k5login ${DESTDIR}/root/.k5login;
76 .endif
77
78 .if ${MK_MAIL} != "no"
79         cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
80             -T "package=sendmail" ${ETCMAIL} ${DESTDIR}/etc/mail
81         if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
82               ! -f ${DESTDIR}/etc/aliases ]; then \
83                 ${INSTALL_SYMLINK} -T "package=sendmail" \
84                 mail/aliases ${DESTDIR}/etc/aliases; \
85         fi
86 .endif
87 .if ${MK_LOCATE} != "no"
88         ${INSTALL} -o nobody -g ${BINGRP} -m 644 -T "package=runtime"\
89             /dev/null ${DESTDIR}/var/db/locate.database
90 .endif
91         cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
92                 -T "package=runtime" ${FREEBSD} ${DESTDIR}/
93 .if ${MK_BOOT} != "no"
94 .if exists(${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints)
95         ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
96             -T "package=bootloader,config" \
97             ${SRCTOP}/sys/${MACHINE}/conf/GENERIC.hints \
98             ${DESTDIR}/boot/device.hints
99 .endif
100 .endif
101
102 MTREES=         mtree/BSD.root.dist             /               \
103                 mtree/BSD.var.dist              /var            \
104                 mtree/BSD.usr.dist              /usr            \
105                 mtree/BSD.include.dist          /usr/include    \
106                 mtree/BSD.debug.dist            /usr/lib
107 .for LIBCOMPAT libcompat in ${_ALL_LIBCOMPATS_libcompats}
108 .if ${MK_LIB${LIBCOMPAT}} != "no"
109 MTREES+=        mtree/BSD.lib${libcompat}.dist  /usr
110 MTREES+=        mtree/BSD.lib${libcompat}.dist  /usr/lib/debug/usr
111 .endif
112 .endfor
113 .if ${MK_TESTS} != "no"
114 MTREES+=        mtree/BSD.tests.dist            ${TESTSBASE}
115 MTREES+=        mtree/BSD.tests.dist            /usr/lib/debug/${TESTSBASE}
116 .endif
117 .if ${MK_SENDMAIL} != "no"
118 MTREES+=        mtree/BSD.sendmail.dist         /
119 .endif
120 .for mtree in ${LOCAL_MTREE}
121 MTREES+=        ../${mtree}                     /
122 .endfor
123
124 # Clean up files that have changed into directories, as mtree cannot handle this
125 # scenario.
126 DISTRIB_CLEANUP_FILES+= ${INCLUDEDIR}/c++/v1/__string
127 DISTRIB_CLEANUP_FILES+= ${INCLUDEDIR}/c++/v1/__tuple
128 distrib-cleanup: .PHONY
129         for file in ${DISTRIB_CLEANUP_FILES}; do \
130                 if [ -f ${DESTDIR}/$${file} ]; then \
131                         rm -f ${DESTDIR}/$${file}; \
132                 fi; \
133         done
134
135 distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
136 .for _m _d in ${MTREES}
137         @m=${.CURDIR}/${_m}; \
138         d=${DESTDIR}${_d}; \
139         test -d $$d || mkdir -p $$d; \
140         ${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
141             ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
142         ${MTREE_FILTER} $$m | \
143         ${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
144             -p $$d
145 .endfor
146 .if defined(NO_ROOT)
147 .for _m _d in ${MTREES}
148         @m=${.CURDIR}/${_m}; \
149         d=${_d}; \
150         test "$$d" = "/" && d=""; \
151         d=${DISTBASE}$$d; \
152         ${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
153             "sed s#^\.#.$$d# | ${METALOG.add}" ; \
154         ${MTREE_FILTER} $$m | \
155         ${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
156             ${METALOG.add}
157 .endfor
158 .endif
159 .if ${MK_NLS} != "no"
160 .for alias nls in ${NLS_ALIASES}
161         ${INSTALL_SYMLINK} -T "package=utilities" \
162             "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
163 .endfor
164 .endif
165
166 .include <bsd.prog.mk>
167
168 .if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
169 MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
170         -e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
171         -e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
172         -e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
173         -e 's,\(gid=\)[^ ]*$$,\1${_gid},'
174 .else
175 MTREE_FILTER= cat
176 .if !defined(NO_FSCHG)
177 MTREE_FSCHG=    -i
178 .endif
179 .endif