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