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