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