xref: /openbsd/include/Makefile (revision 264ca280)
1#	$OpenBSD: Makefile,v 1.212 2016/05/07 21:58:24 tedu Exp $
2#	$NetBSD: Makefile,v 1.59 1996/05/15 21:36:43 jtc Exp $
3
4#	@(#)Makefile	5.45.1.1 (Berkeley) 5/6/91
5
6# The ``rm -rf''s used below are safe because rm doesn't follow symbolic
7# links.
8
9
10.include <bsd.own.mk>
11
12FILES=	a.out.h ar.h asr.h assert.h bitstring.h blf.h bsd_auth.h \
13	complex.h cpio.h ctype.h curses.h db.h dirent.h disktab.h \
14	dlfcn.h elf_abi.h err.h errno.h fenv.h float.h fnmatch.h fstab.h fts.h \
15	ftw.h getopt.h glob.h grp.h icdb.h ieeefp.h ifaddrs.h inttypes.h \
16	iso646.h kvm.h langinfo.h libgen.h limits.h link.h link_elf.h \
17	locale.h login_cap.h math.h md5.h memory.h ndbm.h netdb.h netgroup.h \
18	nlist.h nl_types.h paths.h poll.h pwd.h ranlib.h readpassphrase.h \
19	regex.h resolv.h rmd160.h search.h setjmp.h sha1.h sha2.h signal.h \
20	siphash.h sndio.h spawn.h stdbool.h stddef.h stdio.h stdlib.h \
21	string.h strings.h struct.h sysexits.h tar.h tgmath.h tib.h time.h \
22	ttyent.h unistd.h utime.h utmp.h uuid.h vis.h wchar.h wctype.h
23
24MFILES=	frame.h
25LFILES=	endian.h fcntl.h syslog.h termios.h stdarg.h stdint.h varargs.h
26
27DIRS=	arpa protocols rpc rpcsvc
28LDIRS=	crypto ddb dev isofs miscfs msdosfs net netinet netinet6 \
29	netmpls net80211 nfs ntfs scsi sys ufs uvm
30
31# Places that need a prerequisite target met before includes
32PRDIRS=
33
34# Directories with an includes target
35RDIRS=	../lib/libcrypto ../lib/libcurses ../lib/libedit \
36	../lib/libevent ../lib/libexpat ../lib/libform \
37	../lib/libfuse ../lib/libkeynote ../lib/libmenu \
38	../lib/libossaudio ../lib/libpanel \
39	../lib/libpcap ../lib/libradius ../lib/librpcsvc ../lib/librthread \
40	../lib/libskey ../lib/libsqlite3 ../lib/libssl  ../lib/libtls \
41	../lib/libusbhid ../lib/libutil ../lib/libz \
42	../usr.bin/lex ../gnu/lib/libreadline \
43	../sys/arch/${MACHINE}
44
45.if ${COMPILER_VERSION:L} == "gcc3"
46RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
47PRDIRS+= ../gnu/lib/libstdc++
48.else
49RDIRS+= ../gnu/usr.bin/cc/libobjc
50PRDIRS+= ../gnu/lib/libstdc++-v3
51RDIRS+= ../gnu/usr.bin/cc/include
52.endif
53
54# prereq implies includes
55RDIRS += ${PRDIRS}
56
57NOOBJ=	noobj
58
59# Change SYS_INCLUDE in bsd.own.mk to "symlinks" if you don't want copies
60SYS_INCLUDE?=	copies
61
62RUN_MAKE = if test -f Makefile.bsd-wrapper; then ${MAKE} -f Makefile.bsd-wrapper $@; else ${MAKE} $@; fi
63
64prereq:
65	@for i in ${PRDIRS}; do \
66		echo preparing in ${.CURDIR}/$$i; \
67		cd ${.CURDIR}/$$i && ${RUN_MAKE}; \
68	done
69
70includes:
71	@echo installing ${FILES}
72	@for i in ${FILES}; do \
73		cmp -s $$i ${DESTDIR}/usr/include/$$i || \
74		    ${INSTALL} ${INSTALL_COPY} -m 444 $$i ${DESTDIR}/usr/include/$$i; \
75	done
76	@echo installing ${DIRS}
77	@for i in ${DIRS}; do \
78		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
79			${DESTDIR}/usr/include/$$i; \
80		cd ${.CURDIR}/$$i && for j in *.[ih]; do \
81			cmp -s $$j ${DESTDIR}/usr/include/$$i/$$j || \
82			${INSTALL} ${INSTALL_COPY} -m 444 $$j ${DESTDIR}/usr/include/$$i/$$j; \
83		done; \
84	done
85	@ln -sfh openssl ${DESTDIR}/usr/include/ssl
86	@echo installing ${LFILES}
87	@for i in ${LFILES}; do \
88		rm -f ${DESTDIR}/usr/include/$$i && \
89		ln -s sys/$$i ${DESTDIR}/usr/include/$$i; \
90	done
91	@echo installing ${MFILES}
92	@for i in ${MFILES}; do \
93		rm -f ${DESTDIR}/usr/include/$$i && \
94		ln -s machine/$$i ${DESTDIR}/usr/include/$$i; \
95	done
96	chown -R ${BINOWN}:${BINGRP} ${DESTDIR}/usr/include
97	find ${DESTDIR}/usr/include -type f -print0 | \
98		xargs -0r chmod a=r
99	find ${DESTDIR}/usr/include -type d -print0 | \
100		xargs -0r chmod u=rwx,go=rx
101	@for i in ${RDIRS}; do \
102		echo installing in ${.CURDIR}/$$i; \
103		cd ${.CURDIR}/$$i && ${RUN_MAKE}; \
104	done
105
106copies:
107	@echo copies: ${LDIRS}
108	@for i in ${LDIRS}; do \
109		rm -rf ${DESTDIR}/usr/include/$$i && \
110		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
111			${DESTDIR}/usr/include/$$i ; \
112	done
113	cd ../sys; \
114	pax -rw -pa -L \
115	    `find ${LDIRS} -follow -type f -name '*.h' '!' \
116	    '(' -path 'dev/microcode/*' -or -path 'dev/pci/drm/*' ')' \
117	    -print` ${DESTDIR}/usr/include
118	cd ${DESTDIR}/usr/include && rm -rf ${MACHINE} ${MACHINE_CPU} machine
119	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
120		${DESTDIR}/usr/include/${MACHINE}
121	pax -rw -pa -s "|\.\./sys/arch/${MACHINE}/include||" \
122	    ../sys/arch/${MACHINE}/include/*.h \
123	    ${DESTDIR}/usr/include/${MACHINE}
124	if test ${MACHINE} != ${MACHINE_CPU} -a \
125	    -d ../sys/arch/${MACHINE_CPU}/include; then \
126		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
127	    	    ${DESTDIR}/usr/include/${MACHINE_CPU}; \
128		pax -rw -pa -s "|\.\./sys/arch/${MACHINE_CPU}/include||" \
129		    ../sys/arch/${MACHINE_CPU}/include/*.h \
130		    ${DESTDIR}/usr/include/${MACHINE_CPU}; \
131	fi
132	ln -sf ${MACHINE} ${DESTDIR}/usr/include/machine; \
133
134symlinks:
135	@echo symlinks: ${LDIRS}
136	@for i in ${LDIRS}; do \
137		rm -rf ${DESTDIR}/usr/include/$$i && \
138		ln -s /sys/$$i ${DESTDIR}/usr/include/$$i; \
139	done
140	cd ${DESTDIR}/usr/include && rm -rf ${MACHINE} ${MACHINE_CPU} machine
141	ln -s /sys/arch/${MACHINE}/include ${DESTDIR}/usr/include/${MACHINE}
142	if test ${MACHINE} != ${MACHINE_CPU} -a \
143	    -d ../sys/arch/${MACHINE_CPU}/include ; then \
144		ln -s /sys/arch/${MACHINE_CPU}/include \
145		    ${DESTDIR}/usr/include/${MACHINE_CPU} ; \
146	fi
147	ln -sf ${MACHINE} ${DESTDIR}/usr/include/machine
148
149includes: ${SYS_INCLUDE}
150
151.PHONY: prereq includes copies symlink
152.include <bsd.prog.mk>
153