summaryrefslogtreecommitdiff
path: root/usr/src/lib/Makefile.asthdr
blob: defc22d4cc693b755b3af9b58d5770fa37717ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"%Z%%M%	%I%	%E% SMI"
#

# Note: libast headers are generated by the AST build system outside OS/Net
# (and then copied here) and depend on the architecture (e.g. "i386", "amd64",
# "sparc", "sparcv9" etc. ...), we later merge them into one unified file
# (see below)

ROOTHDRDIR=	$(ROOT)/usr/include/ast

# Define the symbol used to distinguish between 32bit and 64bit parts of the
# include file. We cannot use |_LP64| here because not every compiler (like
# Studio 10/11/12) sets it by default (this doesn't harm because the AST
# includes are OS- and platform-specific anyway) and we can't rely on the
# system includes like <sys/isa_defs.h> because "/usr/bin/diff -D<symbol>"
# adds the "#ifdef <symbol>" before any other content and "injecting" an
# "#include <sys/isa_defs.h>" will alter the behaviour of the AST code
# in unpredictable ways (e.g. the resulting code will not longer work).
# Sun-Bug #6524070 ("RFE: Please set |_LP64| for 64bit platforms by default
# (like gcc does)") has been filed against the Sun Studio compiler as RFE
# to set |_LP64| for 64bit targets.
# (INTEL_BLD is '#' for a Sparc build and SPARC_BLD is '#' for an Intel build)
$(SPARC_BLD)AST64BITCPPSYMBOL = __sparcv9
$(INTEL_BLD)AST64BITCPPSYMBOL = __amd64

# We use a custom install sequence here to unify 32bit and 64bit AST includes
# since we can only ship one set of includes. Therefore we use
# "/usr/bin/diff -D <64bit>" (and for some exceptions a manual path) to
# generate an unified version of the include files (and add a boilerplate text
# which explains the interface stability status).
# ToDo: Rewrite this in ksh93 to simplify the boilerplate generation
$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/%
	@mkdir -p tmpastinclude ; \
	boilerplate="" \
	boilerplate="$${boilerplate}/*\n" \
	boilerplate="$${boilerplate} * BEGIN OpenSolaris section\n" \
	boilerplate="$${boilerplate} *   This is an unstable interface; changes may be made\n" \
	boilerplate="$${boilerplate} *   without notice.\n" \
	boilerplate="$${boilerplate} * END OpenSolaris section\n" \
	boilerplate="$${boilerplate} */\n" ; \
        if [[ "$(@F)" = "ast_limits.h" || \
	      "$(@F)" = "ast_dirent.h" ]] ; then \
	    print "# Building (concatenation) $(@F)" ; \
	    ( \
                print -n "$${boilerplate}" ; \
	        print '#ifndef $(AST64BITCPPSYMBOL)'      ; \
	        cat   "$(HDRDIR32)/$(@F)"                 ; \
	        print '#else /* $(AST64BITCPPSYMBOL) */'  ; \
	        cat   "$(HDRDIR64)/$(@F)"                 ; \
	        print '#endif /* $(AST64BITCPPSYMBOL) */' ; \
	    ) >"tmpastinclude/$(@F)" ; \
	else \
	    print "# Building (diff) $(@F)" ; \
	    ( \
	        set +o errexit ; \
	        print -n "$${boilerplate}" ; \
	        /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\
	    ) >"tmpastinclude/$(@F)" ; \
	fi
	$(INS) -s -m $(FILEMODE) -f $(@D) "tmpastinclude/$(@F)"

# Add temporary include files to the list of files to "clobber"
CLOBBERFILES += tmpastinclude/*