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