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