xref: /illumos-gate/usr/src/head/Makefile (revision aeac2d873b68a43f6650e0d0f021c02f5a653a21)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21#
22# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
23#
24# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# Copyright 2013 Garrett D'Amore <garrett@damore.org>
28# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
29#
30# head/Makefile
31#
32# include global definitions
33include ../Makefile.master
34
35sparc_HDRS=
36i386_HDRS=	stack_unwind.h
37
38# Headers are listed one per line so that TeamWare can auto-merge most changes
39
40KRB5HDRS= mit_copyright.h mit-sipb-copyright.h
41
42ATTRDB_HDRS=	secdb.h auth_attr.h exec_attr.h prof_attr.h user_attr.h \
43	auth_list.h
44
45HDRS=   $($(MACH)_HDRS)  $(ATTRDB_HDRS) \
46	aio.h		\
47	alloca.h	\
48	apptrace.h	\
49	apptrace_impl.h	\
50	ar.h		\
51	archives.h	\
52	assert.h	\
53	atomic.h	\
54	attr.h		\
55	complex.h	\
56	config_admin.h	\
57	cpio.h		\
58	crypt.h		\
59	ctype.h		\
60	deflt.h		\
61	devid.h		\
62	devmgmt.h	\
63	devpoll.h	\
64	dial.h		\
65	dirent.h	\
66	dlfcn.h		\
67	door.h		\
68	elf.h		\
69	err.h		\
70	errno.h		\
71	euc.h		\
72	exacct.h	\
73	exacct_impl.h	\
74	execinfo.h	\
75	fatal.h		\
76	fcntl.h		\
77	fenv.h		\
78	float.h		\
79	floatingpoint.h	\
80	fmtmsg.h	\
81	fnmatch.h	\
82	ftw.h		\
83	gelf.h		\
84	getopt.h	\
85	getwidth.h	\
86	glob.h		\
87	grp.h		\
88	iconv.h		\
89	ieeefp.h	\
90	ifaddrs.h	\
91	inttypes.h	\
92	iso646.h	\
93	klpd.h		\
94	langinfo.h	\
95	lastlog.h	\
96	lber.h		\
97	ldap.h		\
98	libelf.h	\
99	libgen.h	\
100	libintl.h	\
101	libw.h		\
102	libzonecfg.h	\
103	limits.h	\
104	linenum.h	\
105	link.h		\
106	listen.h	\
107	locale.h	\
108	macros.h	\
109	malloc.h	\
110	math.h		\
111	mdmn_changelog.h	\
112	memory.h	\
113	meta.h		\
114	meta_runtime.h	\
115	metadyn.h	\
116	mon.h		\
117	monetary.h	\
118	mp.h		\
119	mqueue.h	\
120	nan.h		\
121	ndbm.h		\
122	ndpd.h		\
123	netconfig.h	\
124	netdb.h		\
125	netdir.h	\
126	nl_types.h	\
127	nlist.h		\
128	note.h		\
129	nsctl.h		\
130	nsswitch.h	\
131	nss_common.h	\
132	nss_dbdefs.h	\
133	nss_netdir.h	\
134	paths.h		\
135	pcsample.h	\
136	pfmt.h		\
137	pkgdev.h	\
138	pkginfo.h	\
139	pkglocs.h	\
140	pkgstrct.h	\
141	pkgtrans.h	\
142	poll.h		\
143	port.h		\
144	priv.h		\
145	priv_utils.h	\
146	proc_service.h	\
147	procfs.h	\
148	prof.h		\
149	project.h	\
150	pthread.h	\
151	pw.h		\
152	pwd.h		\
153	rctl.h		\
154	re_comp.h	\
155	regex.h		\
156	regexp.h	\
157	resolv.h	\
158	rje.h		\
159	rtld_db.h	\
160	sac.h		\
161	sched.h		\
162	schedctl.h	\
163	sdssc.h		\
164	search.h	\
165	semaphore.h	\
166	setjmp.h	\
167	sgtty.h		\
168	shadow.h	\
169	siginfo.h	\
170	signal.h	\
171	spawn.h		\
172	stdarg.h	\
173	stdbool.h	\
174	stddef.h	\
175	stdint.h	\
176	stdio.h		\
177	stdio_ext.h	\
178	stdio_tag.h	\
179	stdio_impl.h	\
180	stdlib.h	\
181	storclass.h	\
182	string.h	\
183	strings.h	\
184	stropts.h	\
185	synch.h		\
186	sysexits.h	\
187	syslog.h	\
188	syms.h		\
189	tar.h		\
190	termio.h	\
191	termios.h	\
192	tgmath.h	\
193	thread.h	\
194	thread_db.h	\
195	time.h		\
196	tiuser.h	\
197	tzfile.h	\
198	ucontext.h	\
199	ucred.h		\
200	ulimit.h	\
201	unistd.h	\
202	userdefs.h	\
203	ustat.h		\
204	utime.h		\
205	utmp.h		\
206	utmpx.h		\
207	valtools.h	\
208	values.h	\
209	varargs.h	\
210	wait.h		\
211	wchar.h		\
212	wchar_impl.h	\
213	wctype.h	\
214	widec.h		\
215	wordexp.h	\
216	xlocale.h	\
217	xti.h		\
218	xti_inet.h	\
219	zone.h
220
221ISOHDRS = \
222	ctype_iso.h	\
223	limits_iso.h	\
224	locale_iso.h	\
225	math_c99.h	\
226	math_iso.h	\
227	setjmp_iso.h  	\
228	signal_iso.h	\
229	stdarg_c99.h	\
230	stdarg_iso.h	\
231	stddef_iso.h	\
232	stdio_c99.h	\
233	stdio_iso.h	\
234	stdlib_c99.h	\
235	stdlib_iso.h	\
236	string_iso.h	\
237	time_iso.h	\
238	wchar_c99.h	\
239	wchar_iso.h	\
240	wctype_iso.h
241
242ARPAHDRS = 		\
243	ftp.h		\
244	inet.h		\
245	nameser.h	\
246	telnet.h	\
247	tftp.h		\
248	nameser_compat.h
249
250AUDIOHDRS =		\
251	au.h
252
253UUIDHDRS =		\
254	uuid.h
255
256# rpcsvc headers which are just headers (not derived from a .x file)
257RPCSVC_SRC_HDRS =	\
258	bootparam.h	\
259	daemon_utils.h	\
260	dbm.h		\
261	nis_db.h	\
262	nislib.h	\
263	svc_dg_priv.h	\
264	yp_prot.h	\
265	ypclnt.h	\
266	yppasswd.h	\
267	ypupd.h		\
268	rpc_sztypes.h
269
270# rpcsvc headers which are generated from .x files
271RPCSVC_GEN_HDRS = \
272	bootparam_prot.h \
273	mount.h		\
274	nfs_prot.h	\
275	nfs4_prot.h	\
276	nis.h		\
277	rex.h		\
278	rquota.h	\
279	rstat.h		\
280	rusers.h	\
281	rwall.h		\
282	spray.h		\
283	ufs_prot.h	\
284	nfs_acl.h
285
286LVMRPCHDRS = \
287mhdx.h mdiox.h meta_basic.h metad.h metamed.h metamhd.h metacl.h
288
289SYMHDRASSERT = $(ROOT)/usr/include/iso/assert_iso.h
290SYMHDRERRNO = $(ROOT)/usr/include/iso/errno_iso.h
291SYMHDRFLOAT = $(ROOT)/usr/include/iso/float_iso.h
292SYMHDRISO646 = $(ROOT)/usr/include/iso/iso646_iso.h
293
294RPCGENFLAGS = -C -h
295rpcsvc/rwall.h :=	RPCGENFLAGS += -M
296meta_basic.h :=	RPCGENFLAGS += -M
297metad.h := RPCGENFLAGS += -M
298metamed.h := RPCGENFLAGS += -M
299mhdx.h := RPCGENFLAGS += -M
300mdiox.h := RPCGENFLAGS += -M
301metamhd.h := RPCGENFLAGS += -M
302metacl.h := RPCGENFLAGS += -M
303
304# rpcsvc rpcgen source (.x files)
305#
306# yp.x is an attempt at codifying what was hand coded in RPCL.
307# Unfortunately it doesn't quite work. (The handcoded stuff isn't
308# expressable in RPCL) this is due to the fact that YP was written
309# before rpcgen existed.  Hence, yp_prot.h cannot be derived from yp.x
310#
311# There is no `.h' for nis_object.x because it is included by nis.x and
312# the resulting .h is nis.h.
313
314RPCSVCPROTS = \
315$(RPCSVC_GEN_HDRS:%.h=%.x)        nis_object.x       yp.x
316
317LVMSVCPROTS = \
318$(LVMRPCHDRS:%.h=%.x)
319
320RPCSVCHDRS= $(RPCSVC_SRC_HDRS) $(RPCSVC_GEN_HDRS)
321
322PROTOHDRS=   dumprestore.h routed.h ripngd.h rwhod.h timed.h
323
324ROOTHDRS= $(HDRS:%=$(ROOT)/usr/include/%)  \
325	$(KRB5HDRS:%=$(ROOT)/usr/include/kerberosv5/%)  \
326	$(ISOHDRS:%=$(ROOT)/usr/include/iso/%)  \
327	$(ARPAHDRS:%=$(ROOT)/usr/include/arpa/%)  \
328	$(AUDIOHDRS:%=$(ROOT)/usr/include/audio/%)  \
329	$(UUIDHDRS:%=$(ROOT)/usr/include/uuid/%)  \
330	$(RPCSVCHDRS:%=$(ROOT)/usr/include/rpcsvc/%)  \
331	$(RPCSVCPROTS:%=$(ROOT)/usr/include/rpcsvc/%)  \
332	$(LVMRPCHDRS:%=$(ROOT)/usr/include/%) \
333	$(PROTOHDRS:%=$(ROOT)/usr/include/protocols/%)
334
335DIRS= iso arpa audio rpcsvc protocols security uuid kerberosv5
336ROOTDIRS= $(DIRS:%=$(ROOT)/usr/include/%)
337
338# check files really don't exist
339#
340# should do something with the rpcsvc headers
341
342iso/%.check:		iso/%.h
343	$(DOT_H_CHECK)
344
345arpa/%.check:		arpa/%.h
346	$(DOT_H_CHECK)
347
348audio/%.check:		audio/%.h
349	$(DOT_H_CHECK)
350
351rpcsvc/%.check:		rpcsvc/%.h
352	$(DOT_H_CHECK)
353
354rpcsvc/%.check:		rpcsvc/%.x
355	$(DOT_X_CHECK)
356
357protocols/%.check:	protocols/%.h
358	$(DOT_H_CHECK)
359
360kerberosv5/%.check:             kerberosv5/%.h
361	$(DOT_H_CHECK)
362
363uuid/%.check:		uuid/%.h
364	$(DOT_H_CHECK)
365
366# Note that the derived headers (rpcgen) are not checked at this time.  These
367# need work at the source level and rpcgen itself has a bug which causes a
368# cstyle violation.  Furthermore, there seems to be good reasons for the
369# generated headers to not pass all of the hdrchk rules.
370#
371# Add the following to the CHECKHDRS list to activate the .x checks:
372#	$(RPCSVCPROTS:%.x=rpcsvc/%.check) \
373#
374CHECKHDRS= $(HDRS:%.h=%.check)  \
375	$(KRB5HDRS:%.h=kerberosv5/%.check)  \
376	$(ISOHDRS:%.h=iso/%.check)  \
377	$(ARPAHDRS:%.h=arpa/%.check)  \
378	$(AUDIOHDRS:%.h=audio/%.check)  \
379	$(UUIDHDRS:%.h=uuid/%.check)  \
380	$(RPCSVC_SRC_HDRS:%.h=rpcsvc/%.check) \
381	$(PROTOHDRS:%.h=protocols/%.check)
382
383# headers which won't quite meet the standards...
384#
385# assert.h is required by ansi-c to *not* be idempotent (section 4.1.2).
386# Hence the trailing guard is not the last thing in the file nor can it
387# be without playing silly games.
388
389assert.check	:= HDRCHK_TAIL = | grep -v "end guard wrong" | true
390
391# install rules
392
393$(ROOT)/usr/include/security/%: security/%
394	$(INS.file)
395
396$(ROOT)/usr/include/protocols/%: protocols/%
397	$(INS.file)
398
399$(ROOT)/usr/include/rpcsvc/%: rpcsvc/%
400	$(INS.file)
401
402$(ROOT)/usr/include/kerberosv5/%: kerberosv5/%
403	$(INS.file)
404
405$(ROOT)/usr/include/arpa/%: arpa/%
406	$(INS.file)
407
408$(ROOT)/usr/include/audio/%: audio/%
409	$(INS.file)
410
411$(ROOT)/usr/include/iso/%: iso/%
412	$(INS.file)
413
414$(ROOT)/usr/include/uuid/%: uuid/%
415	$(INS.file)
416
417$(ROOT)/usr/include/%: %
418	$(INS.file)
419
420.KEEP_STATE:
421
422.PARALLEL:	$(ROOTHDRS) $(CHECKHDRS)
423
424install_h: 	$(ROOTDIRS) .WAIT $(ROOTHDRS) $(SYMHDRASSERT) $(SYMHDRERRNO) \
425		$(SYMHDRFLOAT) $(SYMHDRISO646)
426
427check:	$(CHECKHDRS)
428
429clean clobber:
430	$(RM) $(LVMRPCHDRS);
431	cd rpcsvc ; $(RM) $(RPCSVC_GEN_HDRS)
432
433$(ROOTDIRS):
434	$(INS.dir)
435
436$(SYMHDRASSERT):
437	-$(RM) $@; $(SYMLINK) ../assert.h $@
438
439$(SYMHDRERRNO):
440	-$(RM) $@; $(SYMLINK) ../errno.h $@
441
442$(SYMHDRFLOAT):
443	-$(RM) $@; $(SYMLINK) ../float.h $@
444
445$(SYMHDRISO646):
446	-$(RM) $@; $(SYMLINK) ../iso646.h $@
447
448rpcsvc/%.h:	rpcsvc/%.x
449	$(RPCGEN) $(RPCGENFLAGS) $< -o $@
450
451rpcsvc/nis.h:	rpcsvc/nis.x
452	$(RPCGEN) $(RPCGENFLAGS) rpcsvc/nis.x |\
453	$(SED) -e '/EDIT_START/,$$ d' > $@
454
455meta_basic.h:	../uts/common/sys/lvm/meta_basic.x
456	$(RPCGEN) $(RPCGENFLAGS)  ../uts/common/sys/lvm/meta_basic.x | \
457	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
458	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
459	{ print $0 } \
460	' > $@
461
462metad.h:	metad.x
463	$(RPCGEN) $(RPCGENFLAGS)  metad.x | \
464	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
465	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
466	{ print $0 } \
467	' > $@
468
469mhdx.h:	../uts/common/sys/lvm/mhdx.x
470	$(RPCGEN) $(RPCGENFLAGS) ../uts/common/sys/lvm/mhdx.x | \
471	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
472	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
473	{ print $0 } \
474	' > $@
475
476mdiox.h:	../uts/common/sys/lvm/mdiox.x
477	$(RPCGEN) $(RPCGENFLAGS) ../uts/common/sys/lvm/mdiox.x | \
478	$(AWK) '{sub(/sys\/lvm\/md_mhdx/, "mhdx"); print $$0}' | \
479	$(AWK) '{sub(/sys\/lvm\/md_basic/, "meta_basic"); print $$0}' | \
480	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
481	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
482	{ print $0 } \
483	' > $@
484
485metamed.h:	../uts/common/sys/lvm/metamed.x
486	$(RPCGEN) $(RPCGENFLAGS) ../uts/common/sys/lvm/metamed.x | \
487	$(AWK) '{sub(/sys\/lvm\/md_basic/, "meta_basic"); print $$0}' | \
488	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
489	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
490	{ print $0 } \
491	' > $@
492
493metamhd.h:	metamhd.x
494	$(RPCGEN) $(RPCGENFLAGS) metamhd.x | \
495	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
496	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
497	{ print $0 } \
498	' > $@
499
500metacl.h:	metacl.x
501	$(RPCGEN) $(RPCGENFLAGS) metacl.x | \
502	$(AWK) '/<synch.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
503	/<thread.h>/ { print "#ifdef _REENTRANT"; print $$0; print "#endif\t/* _REENTRANT */"; next } \
504	{ print $0 } \
505	' > $@
506