xref: /xnu-8792.81.2/bsd/sys/make_symbol_aliasing.sh (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1*19c3b8c2SApple OSS Distributions#! /bin/bash -
2*19c3b8c2SApple OSS Distributions#
3*19c3b8c2SApple OSS Distributions# Copyright (c) 2010 Apple Inc. All rights reserved.
4*19c3b8c2SApple OSS Distributions#
5*19c3b8c2SApple OSS Distributions# @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6*19c3b8c2SApple OSS Distributions#
7*19c3b8c2SApple OSS Distributions# This file contains Original Code and/or Modifications of Original Code
8*19c3b8c2SApple OSS Distributions# as defined in and that are subject to the Apple Public Source License
9*19c3b8c2SApple OSS Distributions# Version 2.0 (the 'License'). You may not use this file except in
10*19c3b8c2SApple OSS Distributions# compliance with the License. Please obtain a copy of the License at
11*19c3b8c2SApple OSS Distributions# http://www.opensource.apple.com/apsl/ and read it before using this
12*19c3b8c2SApple OSS Distributions# file.
13*19c3b8c2SApple OSS Distributions#
14*19c3b8c2SApple OSS Distributions# The Original Code and all software distributed under the License are
15*19c3b8c2SApple OSS Distributions# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16*19c3b8c2SApple OSS Distributions# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17*19c3b8c2SApple OSS Distributions# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18*19c3b8c2SApple OSS Distributions# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19*19c3b8c2SApple OSS Distributions# Please see the License for the specific language governing rights and
20*19c3b8c2SApple OSS Distributions# limitations under the License.
21*19c3b8c2SApple OSS Distributions#
22*19c3b8c2SApple OSS Distributions# @APPLE_OSREFERENCE_LICENSE_HEADER_END@
23*19c3b8c2SApple OSS Distributions#
24*19c3b8c2SApple OSS Distributions
25*19c3b8c2SApple OSS Distributionsfunction usage() {
26*19c3b8c2SApple OSS Distributions    echo "Usage: $0 <sdk> <output>" 1>&2
27*19c3b8c2SApple OSS Distributions    exit 1
28*19c3b8c2SApple OSS Distributions}
29*19c3b8c2SApple OSS Distributions
30*19c3b8c2SApple OSS Distributionsif [ $# -ne 2 ]; then
31*19c3b8c2SApple OSS Distributions    usage
32*19c3b8c2SApple OSS Distributionsfi
33*19c3b8c2SApple OSS Distributions
34*19c3b8c2SApple OSS DistributionsSDKROOT="$1"
35*19c3b8c2SApple OSS DistributionsOUTPUT="$2"
36*19c3b8c2SApple OSS Distributions
37*19c3b8c2SApple OSS DistributionsAVAILABILITY_PL="${SDKROOT}/${DRIVERKITROOT}/usr/local/libexec/availability.pl"
38*19c3b8c2SApple OSS Distributions
39*19c3b8c2SApple OSS Distributionsif [ ! -x "${AVAILABILITY_PL}" ] ; then
40*19c3b8c2SApple OSS Distributions    echo "Unable to locate ${AVAILABILITY_PL} (or not executable)" >&2
41*19c3b8c2SApple OSS Distributions    exit 1
42*19c3b8c2SApple OSS Distributionsfi
43*19c3b8c2SApple OSS Distributions
44*19c3b8c2SApple OSS Distributions{
45*19c3b8c2SApple OSS Distributionscat <<EOF
46*19c3b8c2SApple OSS Distributions/* Copyright (c) 2010 Apple Inc. All rights reserved.
47*19c3b8c2SApple OSS Distributions * 
48*19c3b8c2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
49*19c3b8c2SApple OSS Distributions * 
50*19c3b8c2SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
51*19c3b8c2SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
52*19c3b8c2SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
53*19c3b8c2SApple OSS Distributions * compliance with the License. The rights granted to you under the License
54*19c3b8c2SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of,
55*19c3b8c2SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to
56*19c3b8c2SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any
57*19c3b8c2SApple OSS Distributions * terms of an Apple operating system software license agreement.
58*19c3b8c2SApple OSS Distributions * 
59*19c3b8c2SApple OSS Distributions * Please obtain a copy of the License at
60*19c3b8c2SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file.
61*19c3b8c2SApple OSS Distributions * 
62*19c3b8c2SApple OSS Distributions * The Original Code and all software distributed under the License are
63*19c3b8c2SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
64*19c3b8c2SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
65*19c3b8c2SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
66*19c3b8c2SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
67*19c3b8c2SApple OSS Distributions * Please see the License for the specific language governing rights and
68*19c3b8c2SApple OSS Distributions * limitations under the License.
69*19c3b8c2SApple OSS Distributions * 
70*19c3b8c2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
71*19c3b8c2SApple OSS Distributions */
72*19c3b8c2SApple OSS Distributions
73*19c3b8c2SApple OSS Distributions#ifndef _CDEFS_H_
74*19c3b8c2SApple OSS Distributions# error "Never use <sys/_symbol_aliasing.h> directly.  Use <sys/cdefs.h> instead."
75*19c3b8c2SApple OSS Distributions#endif
76*19c3b8c2SApple OSS Distributions
77*19c3b8c2SApple OSS DistributionsEOF
78*19c3b8c2SApple OSS Distributions
79*19c3b8c2SApple OSS Distributionsfor ver in $(${AVAILABILITY_PL} --ios) ; do
80*19c3b8c2SApple OSS Distributions    set -- $(echo "$ver" | tr '.' ' ')
81*19c3b8c2SApple OSS Distributions    ver_major=$1
82*19c3b8c2SApple OSS Distributions    ver_minor=$2
83*19c3b8c2SApple OSS Distributions    ver_rel=$3
84*19c3b8c2SApple OSS Distributions    if [ -z "$ver_rel" ]; then
85*19c3b8c2SApple OSS Distributions	    # don't produce these defines for releases with tertiary release numbers
86*19c3b8c2SApple OSS Distributions        value=$(printf "%d%02d00" ${ver_major} ${ver_minor})
87*19c3b8c2SApple OSS Distributions        str=$(printf "__IPHONE_%d_%d" ${ver_major} ${ver_minor})
88*19c3b8c2SApple OSS Distributions        echo "#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= ${value}"
89*19c3b8c2SApple OSS Distributions        echo "#define __DARWIN_ALIAS_STARTING_IPHONE_${str}(x) x"
90*19c3b8c2SApple OSS Distributions        echo "#else"
91*19c3b8c2SApple OSS Distributions        echo "#define __DARWIN_ALIAS_STARTING_IPHONE_${str}(x)"
92*19c3b8c2SApple OSS Distributions        echo "#endif"
93*19c3b8c2SApple OSS Distributions        echo ""
94*19c3b8c2SApple OSS Distributions    fi
95*19c3b8c2SApple OSS Distributionsdone
96*19c3b8c2SApple OSS Distributions
97*19c3b8c2SApple OSS Distributionsfor ver in $(${AVAILABILITY_PL} --macosx) ; do
98*19c3b8c2SApple OSS Distributions    set -- $(echo "$ver" | tr '.' ' ')
99*19c3b8c2SApple OSS Distributions    ver_major=$1
100*19c3b8c2SApple OSS Distributions    ver_minor=$2
101*19c3b8c2SApple OSS Distributions    ver_rel=$3
102*19c3b8c2SApple OSS Distributions    if [ -z "$ver_rel" ]; then
103*19c3b8c2SApple OSS Distributions	ver_rel=0
104*19c3b8c2SApple OSS Distributions    fi
105*19c3b8c2SApple OSS Distributions    if [ "$ver_major" -lt 10 -o \( "$ver_major" -eq 10 -a "$ver_minor" -lt 10 \) ]; then
106*19c3b8c2SApple OSS Distributions	value=$(printf "%d%d0" ${ver_major} ${ver_minor})
107*19c3b8c2SApple OSS Distributions	str=$(printf "__MAC_%d_%d" ${ver_major} ${ver_minor})
108*19c3b8c2SApple OSS Distributions    else
109*19c3b8c2SApple OSS Distributions	value=$(printf "%d%02d%02d" ${ver_major} ${ver_minor} ${ver_rel})
110*19c3b8c2SApple OSS Distributions	if [ "$ver_rel" -gt 0 ]; then
111*19c3b8c2SApple OSS Distributions	    str=$(printf "__MAC_%d_%d_%d" ${ver_major} ${ver_minor} ${ver_rel})
112*19c3b8c2SApple OSS Distributions	else
113*19c3b8c2SApple OSS Distributions	    str=$(printf "__MAC_%d_%d" ${ver_major} ${ver_minor})
114*19c3b8c2SApple OSS Distributions	fi
115*19c3b8c2SApple OSS Distributions    fi
116*19c3b8c2SApple OSS Distributions    echo "#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= ${value}"
117*19c3b8c2SApple OSS Distributions    echo "#define __DARWIN_ALIAS_STARTING_MAC_${str}(x) x"
118*19c3b8c2SApple OSS Distributions    echo "#else"
119*19c3b8c2SApple OSS Distributions    echo "#define __DARWIN_ALIAS_STARTING_MAC_${str}(x)"
120*19c3b8c2SApple OSS Distributions    echo "#endif"
121*19c3b8c2SApple OSS Distributions    echo ""
122*19c3b8c2SApple OSS Distributionsdone
123*19c3b8c2SApple OSS Distributions} > "$OUTPUT"
124*19c3b8c2SApple OSS Distributions
125