xref: /titanic_50/usr/src/lib/Makefile.asthdr (revision 2a9459bdd821c1cf59590a7a9069ac9c591e8a6b)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27
28# Note: libast headers are generated by the AST build system outside OS/Net
29# (and then copied here) and depend on the architecture (e.g. "i386", "amd64",
30# "sparc", "sparcv9" etc. ...), we later merge them into one unified file
31# (see below)
32
33ROOTHDRDIR=	$(ROOT)/usr/include/ast
34
35# Define the symbol used to distinguish between 32bit and 64bit parts of the
36# include file. We cannot use |_LP64| here because not every compiler (like
37# Studio 10/11/12) sets it by default (this doesn't harm because the AST
38# includes are OS- and platform-specific anyway) and we can't rely on the
39# system includes like <sys/isa_defs.h> because "/usr/bin/diff -D<symbol>"
40# adds the "#ifdef <symbol>" before any other content and "injecting" an
41# "#include <sys/isa_defs.h>" will alter the behaviour of the AST code
42# in unpredictable ways (e.g. the resulting code will not longer work).
43# Sun-Bug #6524070 ("RFE: Please set |_LP64| for 64bit platforms by default
44# (like gcc does)") has been filed against the Sun Studio compiler as RFE
45# to set |_LP64| for 64bit targets.
46# (INTEL_BLD is '#' for a Sparc build and SPARC_BLD is '#' for an Intel build)
47$(SPARC_BLD)AST64BITCPPSYMBOL = __sparcv9
48$(INTEL_BLD)AST64BITCPPSYMBOL = __amd64
49
50# We use a custom install sequence here to unify 32bit and 64bit AST includes
51# since we can only ship one set of includes. Therefore we use
52# "/usr/bin/diff -D <64bit>" (and for some exceptions a manual path) to
53# generate an unified version of the include files (and add a boilerplate text
54# which explains the interface stability status).
55# ToDo: Rewrite this in ksh93 to simplify the boilerplate generation
56$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/%
57	@mkdir -p tmpastinclude ; \
58	boilerplate="" \
59	boilerplate="$${boilerplate}/*\n" \
60	boilerplate="$${boilerplate} * BEGIN OpenSolaris section\n" \
61	boilerplate="$${boilerplate} *   This is an unstable interface; changes may be made\n" \
62	boilerplate="$${boilerplate} *   without notice.\n" \
63	boilerplate="$${boilerplate} * END OpenSolaris section\n" \
64	boilerplate="$${boilerplate} */\n" ; \
65        if [[ "$(@F)" = "ast_limits.h" || \
66	      "$(@F)" = "ast_dirent.h" ]] ; then \
67	    print "# Building (concatenation) $(@F)" ; \
68	    ( \
69                print -n "$${boilerplate}" ; \
70	        print '#ifndef $(AST64BITCPPSYMBOL)'      ; \
71	        cat   "$(HDRDIR32)/$(@F)"                 ; \
72	        print '#else /* $(AST64BITCPPSYMBOL) */'  ; \
73	        cat   "$(HDRDIR64)/$(@F)"                 ; \
74	        print '#endif /* $(AST64BITCPPSYMBOL) */' ; \
75	    ) >"tmpastinclude/$(@F)" ; \
76	else \
77	    print "# Building (diff) $(@F)" ; \
78	    ( \
79	        set +o errexit ; \
80	        print -n "$${boilerplate}" ; \
81	        /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\
82	    ) >"tmpastinclude/$(@F)" ; \
83	fi
84	$(INS) -s -m $(FILEMODE) -f $(@D) "tmpastinclude/$(@F)"
85
86# Add temporary include files to the list of files to "clobber"
87CLOBBERFILES += tmpastinclude/*
88