xref: /titanic_44/usr/src/lib/Makefile.asthdr (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)
1da2e3ebdSchin#
2da2e3ebdSchin# CDDL HEADER START
3da2e3ebdSchin#
4da2e3ebdSchin# The contents of this file are subject to the terms of the
5da2e3ebdSchin# Common Development and Distribution License (the "License").
6da2e3ebdSchin# You may not use this file except in compliance with the License.
7da2e3ebdSchin#
8da2e3ebdSchin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da2e3ebdSchin# or http://www.opensolaris.org/os/licensing.
10da2e3ebdSchin# See the License for the specific language governing permissions
11da2e3ebdSchin# and limitations under the License.
12da2e3ebdSchin#
13da2e3ebdSchin# When distributing Covered Code, include this CDDL HEADER in each
14da2e3ebdSchin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da2e3ebdSchin# If applicable, add the following below this CDDL HEADER, with the
16da2e3ebdSchin# fields enclosed by brackets "[]" replaced with your own identifying
17da2e3ebdSchin# information: Portions Copyright [yyyy] [name of copyright owner]
18da2e3ebdSchin#
19da2e3ebdSchin# CDDL HEADER END
20da2e3ebdSchin#
21*7c2fbfb3SApril Chin
22da2e3ebdSchin#
23*7c2fbfb3SApril Chin# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24da2e3ebdSchin# Use is subject to license terms.
25da2e3ebdSchin#
26da2e3ebdSchin
27da2e3ebdSchin# Note: libast headers are generated by the AST build system outside OS/Net
28da2e3ebdSchin# (and then copied here) and depend on the architecture (e.g. "i386", "amd64",
29da2e3ebdSchin# "sparc", "sparcv9" etc. ...), we later merge them into one unified file
30da2e3ebdSchin# (see below)
31da2e3ebdSchin
32da2e3ebdSchinROOTHDRDIR=	$(ROOT)/usr/include/ast
33da2e3ebdSchin
34da2e3ebdSchin# Define the symbol used to distinguish between 32bit and 64bit parts of the
35da2e3ebdSchin# include file. We cannot use |_LP64| here because not every compiler (like
36da2e3ebdSchin# Studio 10/11/12) sets it by default (this doesn't harm because the AST
37da2e3ebdSchin# includes are OS- and platform-specific anyway) and we can't rely on the
38da2e3ebdSchin# system includes like <sys/isa_defs.h> because "/usr/bin/diff -D<symbol>"
39da2e3ebdSchin# adds the "#ifdef <symbol>" before any other content and "injecting" an
40da2e3ebdSchin# "#include <sys/isa_defs.h>" will alter the behaviour of the AST code
41da2e3ebdSchin# in unpredictable ways (e.g. the resulting code will not longer work).
42da2e3ebdSchin# Sun-Bug #6524070 ("RFE: Please set |_LP64| for 64bit platforms by default
43da2e3ebdSchin# (like gcc does)") has been filed against the Sun Studio compiler as RFE
44da2e3ebdSchin# to set |_LP64| for 64bit targets.
45da2e3ebdSchin# (INTEL_BLD is '#' for a Sparc build and SPARC_BLD is '#' for an Intel build)
46da2e3ebdSchin$(SPARC_BLD)AST64BITCPPSYMBOL = __sparcv9
47da2e3ebdSchin$(INTEL_BLD)AST64BITCPPSYMBOL = __amd64
48da2e3ebdSchin
49da2e3ebdSchin# We use a custom install sequence here to unify 32bit and 64bit AST includes
50da2e3ebdSchin# since we can only ship one set of includes. Therefore we use
51da2e3ebdSchin# "/usr/bin/diff -D <64bit>" (and for some exceptions a manual path) to
52da2e3ebdSchin# generate an unified version of the include files (and add a boilerplate text
53da2e3ebdSchin# which explains the interface stability status).
54da2e3ebdSchin$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/%
55da2e3ebdSchin	@mkdir -p tmpastinclude ; \
56*7c2fbfb3SApril Chin	typeset boilerplate="" ; \
57*7c2fbfb3SApril Chin	boilerplate+="/*\n" \
58*7c2fbfb3SApril Chin	boilerplate+=" * BEGIN OpenSolaris section\n" \
59*7c2fbfb3SApril Chin	boilerplate+=" *   This is an unstable interface; changes may be made\n" \
60*7c2fbfb3SApril Chin	boilerplate+=" *   without notice.\n" \
61*7c2fbfb3SApril Chin	boilerplate+=" * END OpenSolaris section\n" \
62*7c2fbfb3SApril Chin	boilerplate+=" */\n" ; \
63*7c2fbfb3SApril Chin        if [[ "$(@F)" == "ast_limits.h" || \
64*7c2fbfb3SApril Chin	      "$(@F)" == "ast_dirent.h" ]] ; then \
65*7c2fbfb3SApril Chin	    printf "# Building (concatenation) %s\n" "$(@F)" ; \
66*7c2fbfb3SApril Chin	    { \
67da2e3ebdSchin                print -n "$${boilerplate}" ; \
68*7c2fbfb3SApril Chin	        printf '#ifndef %s\n' "$(AST64BITCPPSYMBOL)"      ; \
69da2e3ebdSchin	        cat    "$(HDRDIR32)/$(@F)"                 ; \
70*7c2fbfb3SApril Chin	        printf '#else /* %s */\n' "$(AST64BITCPPSYMBOL)" ; \
71da2e3ebdSchin	        cat    "$(HDRDIR64)/$(@F)"                 ; \
72*7c2fbfb3SApril Chin	        printf '#endif /* %s */\n' "$(AST64BITCPPSYMBOL)" ; \
73*7c2fbfb3SApril Chin	    } >"tmpastinclude/$(@F)" ; \
74da2e3ebdSchin	else \
75*7c2fbfb3SApril Chin	    printf "# Building (diff) %s\n" "$(@F)"; \
76*7c2fbfb3SApril Chin	    { \
77da2e3ebdSchin	        set +o errexit ; \
78da2e3ebdSchin	        print -n "$${boilerplate}" ; \
79da2e3ebdSchin	        /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\
80*7c2fbfb3SApril Chin	    } >"tmpastinclude/$(@F)" ; \
81da2e3ebdSchin	fi
82da2e3ebdSchin	$(INS) -s -m $(FILEMODE) -f $(@D) "tmpastinclude/$(@F)"
83da2e3ebdSchin
84da2e3ebdSchin# Add temporary include files to the list of files to "clobber"
85da2e3ebdSchinCLOBBERFILES += tmpastinclude/*
86