da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Common Development and Distribution License (the "License").
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# or http://www.opensolaris.org/os/licensing.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Note: libast headers are generated by the AST build system outside OS/Net
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# (and then copied here) and depend on the architecture (e.g. "i386", "amd64",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# "sparc", "sparcv9" etc. ...), we later merge them into one unified file
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# (see below)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinROOTHDRDIR= $(ROOT)/usr/include/ast
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Define the symbol used to distinguish between 32bit and 64bit parts of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# include file. We cannot use |_LP64| here because not every compiler (like
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Studio 10/11/12) sets it by default (this doesn't harm because the AST
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# includes are OS- and platform-specific anyway) and we can't rely on the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# system includes like <sys/isa_defs.h> because "/usr/bin/diff -D<symbol>"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# adds the "#ifdef <symbol>" before any other content and "injecting" an
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# "#include <sys/isa_defs.h>" will alter the behaviour of the AST code
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# in unpredictable ways (e.g. the resulting code will not longer work).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Sun-Bug #6524070 ("RFE: Please set |_LP64| for 64bit platforms by default
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# (like gcc does)") has been filed against the Sun Studio compiler as RFE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# to set |_LP64| for 64bit targets.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# (INTEL_BLD is '#' for a Sparc build and SPARC_BLD is '#' for an Intel build)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin$(SPARC_BLD)AST64BITCPPSYMBOL = __sparcv9
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin$(INTEL_BLD)AST64BITCPPSYMBOL = __amd64
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# We use a custom install sequence here to unify 32bit and 64bit AST includes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# since we can only ship one set of includes. Therefore we use
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# "/usr/bin/diff -D <64bit>" (and for some exceptions a manual path) to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# generate an unified version of the include files (and add a boilerplate text
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# which explains the interface stability status).
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/%
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin @mkdir -p tmpastinclude ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin typeset boilerplate="" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin boilerplate+="/*\n" \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin boilerplate+=" * BEGIN OpenSolaris section\n" \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin boilerplate+=" * This is an unstable interface; changes may be made\n" \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin boilerplate+=" * without notice.\n" \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin boilerplate+=" * END OpenSolaris section\n" \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin boilerplate+=" */\n" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if [[ "$(@F)" == "ast_limits.h" || \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin "$(@F)" == "ast_dirent.h" ]] ; then \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf "# Building (concatenation) %s\n" "$(@F)" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin print -n "$${boilerplate}" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf '#ifndef %s\n' "$(AST64BITCPPSYMBOL)" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin cat "$(HDRDIR32)/$(@F)" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf '#else /* %s */\n' "$(AST64BITCPPSYMBOL)" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin cat "$(HDRDIR64)/$(@F)" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf '#endif /* %s */\n' "$(AST64BITCPPSYMBOL)" ; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin } >"tmpastinclude/$(@F)" ; \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin else \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf "# Building (diff) %s\n" "$(@F)"; \
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin { \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin set +o errexit ; \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin print -n "$${boilerplate}" ; \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin } >"tmpastinclude/$(@F)" ; \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin fi
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin $(INS) -s -m $(FILEMODE) -f $(@D) "tmpastinclude/$(@F)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Add temporary include files to the list of files to "clobber"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinCLOBBERFILES += tmpastinclude/*