xref: /illumos-gate/usr/src/cmd/ast/Makefile.asthdr (revision 28ab0ca48b3e331cbbb231b1c8325f9f24f9af95)
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# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
27#
28
29ROOTHDRDIR=	$(ROOT)/usr/include/ast
30
31# Define the symbol used to distinguish between 32bit and 64bit parts of the
32# include file. We cannot use |_LP64| here because not every compiler (like
33# Studio 10/11/12) sets it by default (this doesn't harm because the AST
34# includes are OS- and platform-specific anyway) and we can't rely on the
35# system includes like <sys/isa_defs.h> because "/usr/bin/diff -D<symbol>"
36# adds the "#ifdef <symbol>" before any other content and "injecting" an
37# "#include <sys/isa_defs.h>" will alter the behaviour of the AST code
38# in unpredictable ways (e.g. the resulting code will not longer work).
39# Sun-Bug #6524070 ("RFE: Please set |_LP64| for 64bit platforms by default
40# (like gcc does)") has been filed against the Sun Studio compiler as RFE
41# to set |_LP64| for 64bit targets.
42# (INTEL_BLD is '#' for a Sparc build and SPARC_BLD is '#' for an Intel build)
43$(SPARC_BLD)AST64BITCPPSYMBOL = __sparcv9
44$(INTEL_BLD)AST64BITCPPSYMBOL = __amd64
45
46# We use a custom install sequence here to unify 32bit and 64bit AST includes
47# since we can only ship one set of includes. Therefore we use
48# "/usr/bin/diff -D <64bit>" (and for some exceptions a manual path) to
49# generate an unified version of the include files (and add a boilerplate text
50# which explains the interface stability status).
51$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/%
52	@mkdir -p tmpastinclude ; \
53	typeset boilerplate="" ; \
54	boilerplate+="/*\n" \
55	boilerplate+=" * BEGIN illumos section\n" \
56	boilerplate+=" *   This is an unstable interface; changes may be made\n" \
57	boilerplate+=" *   without notice.\n" \
58	boilerplate+=" * END illumos section\n" \
59	boilerplate+=" */\n" ; \
60        if [[ "$(@F)" == "ast_limits.h" || \
61	      "$(@F)" == "ast_dirent.h" ]] ; then \
62	    printf "# Building (concatenation) %s\n" "$(@F)" ; \
63	    { \
64                print -n "$${boilerplate}" ; \
65	        printf '#ifndef %s\n' "$(AST64BITCPPSYMBOL)"      ; \
66	        cat    "$(HDRDIR32)/$(@F)"                 ; \
67	        printf '#else /* %s */\n' "$(AST64BITCPPSYMBOL)" ; \
68	        cat    "$(HDRDIR64)/$(@F)"                 ; \
69	        printf '#endif /* %s */\n' "$(AST64BITCPPSYMBOL)" ; \
70	    } >"tmpastinclude/$(@F)" ; \
71	else \
72	    printf "# Building (diff) %s\n" "$(@F)"; \
73	    { \
74	        set +o errexit ; \
75	        print -n "$${boilerplate}" ; \
76	        /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\
77	    } >"tmpastinclude/$(@F)" ; \
78	fi
79	$(INS) -s -m $(FILEMODE) -f $(@D) "tmpastinclude/$(@F)"
80
81# Add temporary include files to the list of files to "clobber"
82CLOBBERFILES += tmpastinclude/*
83