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# 23# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26 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). 54$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/% 55 @mkdir -p tmpastinclude ; \ 56 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 { \ 67 print -n "$${boilerplate}" ; \ 68 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)" ; \ 74 else \ 75 printf "# Building (diff) %s\n" "$(@F)"; \ 76 { \ 77 set +o errexit ; \ 78 print -n "$${boilerplate}" ; \ 79 /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\ 80 } >"tmpastinclude/$(@F)" ; \ 81 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/* 86