]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/Makefile
Rework META_TARGETS so that it automatically adds META_DEPS to the targets.
[FreeBSD/FreeBSD.git] / include / Makefile
1 #       @(#)Makefile    8.2 (Berkeley) 1/4/94
2 # $FreeBSD$
3 #
4 # Doing a "make install" builds /usr/include.
5
6 .include <src.opts.mk>
7
8 CLEANFILES= osreldate.h version
9 SUBDIR= arpa protocols rpcsvc rpc xlocale
10 SUBDIR_PARALLEL=
11 INCS=   a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
12         db.h \
13         dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
14         fts.h ftw.h getopt.h glob.h grp.h \
15         ieeefp.h ifaddrs.h \
16         inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
17         locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
18         ndbm.h netconfig.h \
19         netdb.h nl_types.h nlist.h nss.h nsswitch.h paths.h \
20         printf.h proc_service.h pthread.h \
21         pthread_np.h pwd.h ranlib.h readpassphrase.h regex.h \
22         res_update.h resolv.h runetype.h search.h semaphore.h setjmp.h \
23         signal.h spawn.h stab.h stdalign.h stdbool.h stddef.h \
24         stdnoreturn.h stdio.h stdlib.h string.h stringlist.h \
25         strings.h sysexits.h tar.h termios.h tgmath.h \
26         time.h timeconv.h timers.h ttyent.h \
27         uchar.h ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h \
28         wchar.h wctype.h wordexp.h xlocale.h
29
30 .PATH: ${.CURDIR}/../contrib/libc-vis
31 INCS+=  vis.h
32
33 MHDRS=  float.h floatingpoint.h stdarg.h
34
35 PHDRS=  sched.h _semaphore.h
36
37 LHDRS=  aio.h errno.h fcntl.h linker_set.h poll.h stdatomic.h stdint.h \
38         syslog.h ucontext.h
39
40 LDIRS=  bsm cam geom net net80211 netgraph netinet netinet6 \
41         netipsec netnatm netsmb nfs nfsclient nfsserver sys vm
42
43 LSUBDIRS=       cam/ata cam/scsi \
44         dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \
45         dev/hwpmc \
46         dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/nvme \
47         dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
48         dev/speaker dev/utopia dev/vkbd dev/wi \
49         fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
50         fs/procfs fs/smbfs fs/udf fs/unionfs \
51         geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
52         geom/mirror geom/mountver geom/multipath geom/nop \
53         geom/raid geom/raid3 geom/shsec geom/stripe geom/virstor \
54         net/altq \
55         netgraph/atm netgraph/netflow \
56         netinet/cc \
57         security/audit \
58         security/mac_biba security/mac_bsdextended security/mac_lomac \
59         security/mac_mls security/mac_partition \
60         ufs/ffs ufs/ufs
61
62 LSUBSUBDIRS=    dev/mpt/mpilib
63
64 .if ${MK_BLUETOOTH} != "no"
65 LSUBSUBDIRS+=   netgraph/bluetooth/include
66 .endif
67
68 .if ${MK_CUSE} != "no"
69 LSUBDIRS+=      fs/cuse
70 .endif
71
72 .if ${MK_GSSAPI} != "no"
73 SUBDIR+=        gssapi
74 INCS+=          gssapi.h
75 .endif
76
77 .if ${MK_HESIOD} != "no"
78 INCS+=  hesiod.h
79 .endif
80
81 # Handle the #define aliases for libiconv
82 .if ${MK_ICONV} == "yes"
83 INCS+=          iconv.h
84 .endif
85
86 .if ${MK_USB} != "no"
87 LSUBDIRS+=      dev/usb
88 .endif
89
90 .if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
91 _dev_powermac_nvram=    dev/powermac_nvram
92 .endif
93
94 # Define SHARED to indicate whether you want symbolic links to the system
95 # source (``symlinks''), or a separate copy (``copies'').  ``symlinks'' is
96 # probably only useful for developers and should be avoided if you do not
97 # wish to tie your /usr/include and /usr/src together.
98 #SHARED=        symlinks
99 SHARED?=        copies
100
101 INCS+=  osreldate.h
102
103 SYSDIR=                 ${.CURDIR}/../sys
104 NEWVERS_SH=             ${SYSDIR}/conf/newvers.sh
105 PARAM_H=                ${SYSDIR}/sys/param.h
106 MK_OSRELDATE_SH=        ${.CURDIR}/mk-osreldate.sh
107
108 SYMLINKS+= ${INCLUDEDIR} ${LIBDIR}/include
109
110 osreldate.h: ${NEWVERS_SH} ${PARAM_H} ${MK_OSRELDATE_SH}
111         env NEWVERS_SH=${NEWVERS_SH} PARAMFILE=${PARAM_H} SYSDIR=${SYSDIR} \
112             sh ${MK_OSRELDATE_SH}
113
114 .for i in ${LHDRS}
115 INCSLINKS+=     sys/$i ${INCLUDEDIR}/$i
116 .endfor
117 .for i in ${MHDRS}
118 INCSLINKS+=     machine/$i ${INCLUDEDIR}/$i
119 .endfor
120 .for i in ${PHDRS}
121 INCSLINKS+=     sys/$i ${INCLUDEDIR}/$i
122 .endfor
123
124 .if ${MACHINE} != ${MACHINE_CPUARCH}
125 _MARCHS=        ${MACHINE_CPUARCH}
126 .endif
127 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
128 _MARCHS+=       x86
129 .endif
130
131 META_TARGETS+=  compat copies symlinks
132 stage_includes: ${SHARED}
133
134 # Take care of stale directory-level symlinks.
135 compat:
136 .for i in ${LDIRS} ${LSUBDIRS} machine ${_MARCHS} crypto
137         if [ -L ${DESTDIR}${INCLUDEDIR}/$i ]; then \
138                 rm -f ${DESTDIR}${INCLUDEDIR}/$i; \
139         fi
140 .endfor
141         mtree -deU ${MTREE_FOLLOWS_SYMLINKS} \
142             -f ${.CURDIR}/../etc/mtree/BSD.include.dist \
143             -p ${DESTDIR}${INCLUDEDIR} > /dev/null
144
145 copies:
146 .for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} crypto machine machine/pc \
147         ${_MARCHS}
148         if [ -d ${DESTDIR}${INCLUDEDIR}/$i ]; then \
149                 cd ${DESTDIR}${INCLUDEDIR}/$i; \
150                 for h in *.h; do \
151                         if [ -L $$h ]; then rm -f $$h; fi; \
152                 done; \
153         fi
154 .endfor
155 .for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS}
156         cd ${.CURDIR}/../sys; \
157         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
158             ${DESTDIR}${INCLUDEDIR}/$i
159 .endfor
160         cd ${.CURDIR}/../sys/dev/acpica; \
161         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
162             ${DESTDIR}${INCLUDEDIR}/dev/acpica; \
163         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpi_hpet.h \
164             ${DESTDIR}${INCLUDEDIR}/dev/acpica
165         cd ${.CURDIR}/../sys/dev/agp; \
166         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \
167             ${DESTDIR}${INCLUDEDIR}/dev/agp
168         cd ${.CURDIR}/../sys/dev/bktr; \
169         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
170             ${DESTDIR}${INCLUDEDIR}/dev/bktr
171 .if ${MK_NAND} != "no"
172         cd ${.CURDIR}/../sys/dev/nand; \
173         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \
174             ${DESTDIR}${INCLUDEDIR}/dev/nand; \
175         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \
176             ${DESTDIR}${INCLUDEDIR}/dev/nand
177 .endif
178         cd ${.CURDIR}/../sys/dev/pci; \
179         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \
180             ${DESTDIR}${INCLUDEDIR}/dev/pci
181         cd ${.CURDIR}/../sys/fs/cd9660/; \
182         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
183             ${DESTDIR}${INCLUDEDIR}/isofs/cd9660
184 .if ${MK_IPFILTER} != "no"
185         cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
186         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
187             ${DESTDIR}${INCLUDEDIR}/netinet
188 .endif
189 .if ${MK_PF} != "no"
190         cd ${.CURDIR}/../sys/netpfil/pf; \
191         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
192             ${DESTDIR}${INCLUDEDIR}/netpfil/pf
193 .endif
194         cd ${.CURDIR}/../sys/crypto; \
195         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
196             ${DESTDIR}${INCLUDEDIR}/crypto
197         cd ${.CURDIR}/../sys/opencrypto; \
198         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
199             ${DESTDIR}${INCLUDEDIR}/crypto
200         cd ${.CURDIR}/../sys/${MACHINE}/include; \
201         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
202             ${DESTDIR}${INCLUDEDIR}/machine
203 .if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
204         cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
205         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
206             ${DESTDIR}${INCLUDEDIR}/machine/pc
207 .endif
208 .for _MARCH in ${_MARCHS}
209 .if exists(${.CURDIR}/../sys/${_MARCH}/include)
210         ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
211             ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
212         cd ${.CURDIR}/../sys/${_MARCH}/include; \
213         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
214             ${DESTDIR}${INCLUDEDIR}/${_MARCH}
215 .if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
216         ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
217             ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
218         cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
219         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
220             ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc
221 .endif
222 .endif
223 .endfor
224         cd ${.CURDIR}/../sys/rpc; \
225         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
226             ${DESTDIR}${INCLUDEDIR}/rpc
227         cd ${.CURDIR}/../sys/teken; \
228         ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \
229             ${DESTDIR}${INCLUDEDIR}/teken
230
231 symlinks:
232         @${ECHO} "Setting up symlinks to kernel source tree..."
233 .for i in ${LDIRS}
234         cd ${.CURDIR}/../sys/$i; \
235         for h in *.h; do \
236                 ${INSTALL_SYMLINK} ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
237         done
238 .endfor
239 .for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci}
240         cd ${.CURDIR}/../sys/$i; \
241         for h in *.h; do \
242                 ${INSTALL_SYMLINK} ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
243         done
244 .endfor
245         cd ${.CURDIR}/../sys/dev/acpica; \
246         for h in acpiio.h acpi_hpet.h; do \
247                 ${INSTALL_SYMLINK} ../../../../sys/dev/acpica/$$h \
248                     ${DESTDIR}${INCLUDEDIR}/dev/acpica; \
249         done
250         cd ${.CURDIR}/../sys/dev/agp; \
251         for h in agpreg.h; do \
252                 ${INSTALL_SYMLINK} ../../../../sys/dev/agp/$$h \
253                     ${DESTDIR}${INCLUDEDIR}/dev/agp; \
254         done
255         cd ${.CURDIR}/../sys/dev/bktr; \
256         for h in ioctl_*.h; do \
257                 ${INSTALL_SYMLINK} ../../../../sys/dev/bktr/$$h \
258                     ${DESTDIR}${INCLUDEDIR}/dev/bktr; \
259         done
260 .if ${MK_NAND} != "no"
261         cd ${.CURDIR}/../sys/dev/nand; \
262         for h in nandsim.h nand_dev.h; do \
263                 ${INSTALL_SYMLINK} ../../../../sys/dev/nand/$$h \
264                     ${DESTDIR}${INCLUDEDIR}/dev/nand; \
265         done
266 .endif
267         cd ${.CURDIR}/../sys/dev/pci; \
268         for h in pcireg.h; do \
269                 ${INSTALL_SYMLINK} ../../../../sys/dev/pci/$$h \
270                     ${DESTDIR}${INCLUDEDIR}/dev/pci; \
271         done
272 .for i in ${LSUBSUBDIRS}
273         cd ${.CURDIR}/../sys/$i; \
274         for h in *.h; do \
275                 ${INSTALL_SYMLINK} ../../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
276         done
277 .endfor
278 .if ${MK_IPFILTER} != "no"
279         cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
280         for h in *.h; do \
281                 ${INSTALL_SYMLINK} ../../../sys/contrib/ipfilter/netinet/$$h \
282                     ${DESTDIR}${INCLUDEDIR}/netinet; \
283         done
284 .endif
285 .if ${MK_PF} != "no"
286         cd ${.CURDIR}/../sys/netpfil/pf; \
287         for h in *.h; do \
288                 ${INSTALL_SYMLINK} ../../../../sys/netpfil/pf/$$h \
289                     ${DESTDIR}${INCLUDEDIR}/netpfil/pf; \
290         done
291 .endif
292         cd ${.CURDIR}/../sys/crypto; \
293         for h in rijndael/rijndael.h; do \
294                 ${INSTALL_SYMLINK} ../../../sys/crypto/$$h \
295                     ${DESTDIR}${INCLUDEDIR}/crypto; \
296         done
297         cd ${.CURDIR}/../sys/opencrypto; \
298         for h in *.h; do \
299                 ${INSTALL_SYMLINK} ../../../sys/opencrypto/$$h \
300                     ${DESTDIR}${INCLUDEDIR}/crypto; \
301         done
302         cd ${.CURDIR}/../sys/${MACHINE}/include; \
303         for h in *.h; do \
304                 ${INSTALL_SYMLINK} ../../../sys/${MACHINE}/include/$$h \
305                     ${DESTDIR}${INCLUDEDIR}/machine; \
306         done
307 .if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
308         cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
309         for h in *.h; do \
310                 ${INSTALL_SYMLINK} ../../../../sys/${MACHINE}/include/pc/$$h \
311                     ${DESTDIR}${INCLUDEDIR}/machine/pc; \
312         done
313 .endif
314 .for _MARCH in ${_MARCHS}
315 .if exists(${.CURDIR}/../sys/${_MARCH}/include)
316         ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
317             ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
318         cd ${.CURDIR}/../sys/${_MARCH}/include; \
319         for h in *.h; do \
320                 ${INSTALL_SYMLINK} ../../../sys/${_MARCH}/include/$$h \
321                     ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
322         done
323 .if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
324         ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
325             ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
326         cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
327         for h in *.h; do \
328                 ${INSTALL_SYMLINK} ../../../../sys/${_MARCH}/include/pc/$$h \
329                     ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
330         done
331 .endif
332 .endif
333 .endfor
334         cd ${.CURDIR}/../sys/fs/cd9660; \
335         for h in *.h; do \
336                 ${INSTALL_SYMLINK} ../../../../sys/fs/cd9660/$$h \
337                     ${DESTDIR}${INCLUDEDIR}/isofs/cd9660; \
338         done
339         cd ${.CURDIR}/../sys/rpc; \
340         for h in types.h; do \
341                 ${INSTALL_SYMLINK} ../../../sys/rpc/$$h \
342                     ${DESTDIR}${INCLUDEDIR}/rpc; \
343         done
344
345 .include <bsd.prog.mk>
346
347 installincludes: ${SHARED}
348 ${SHARED}: compat
349
350 .if ${MACHINE} == "host" && !defined(_SKIP_BUILD)
351 # we're here because we are building a sysroot...
352 # we need MACHINE et al set correctly
353 HOST_MACHINE!= uname -m
354 HOST_MACHINE_ARCH!= uname -p
355 MACHINE:= ${HOST_MACHINE}
356 MACHINE_ARCH:= ${HOST_MACHINE_ARCH}
357 .endif