gen-platforms.sh revision 1.1 1 1.1 rillig #! /bin/sh
2 1.1 rillig # $NetBSD: gen-platforms.sh,v 1.1 2021/10/10 18:16:12 rillig Exp $
3 1.1 rillig
4 1.1 rillig #
5 1.1 rillig # Copyright (c) 2021 The NetBSD Foundation, Inc.
6 1.1 rillig # All rights reserved.
7 1.1 rillig #
8 1.1 rillig # Redistribution and use in source and binary forms, with or without
9 1.1 rillig # modification, are permitted provided that the following conditions
10 1.1 rillig # are met:
11 1.1 rillig # 1. Redistributions of source code must retain the above copyright
12 1.1 rillig # notice, this list of conditions and the following disclaimer.
13 1.1 rillig # 2. Redistributions in binary form must reproduce the above copyright
14 1.1 rillig # notice, this list of conditions and the following disclaimer in the
15 1.1 rillig # documentation and/or other materials provided with the distribution.
16 1.1 rillig #
17 1.1 rillig # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.1 rillig # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.1 rillig # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.1 rillig # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.1 rillig # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.1 rillig # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.1 rillig # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.1 rillig # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.1 rillig # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.1 rillig # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.1 rillig # POSSIBILITY OF SUCH DAMAGE.
28 1.1 rillig
29 1.1 rillig # Regenerate the platforms list, to be used in t_integration.sh.
30 1.1 rillig
31 1.1 rillig set -eu
32 1.1 rillig
33 1.1 rillig exec 1>'gen-platforms.out'
34 1.1 rillig
35 1.1 rillig for file in ../../../../usr.bin/xlint/arch/*/targparam.h; do
36 1.1 rillig platform=${file%/*}
37 1.1 rillig platform=${platform##*/}
38 1.1 rillig
39 1.1 rillig char=$(sed -n -E 's,.*"([su]char)\.h".*,\1,p' "$file")
40 1.1 rillig ilp=$(sed -n -E 's,.*"(ilp32|lp64)\.h".*,\1,p' "$file")
41 1.1 rillig size=$(awk '/#.*LONG$/ { l = "long" } /#.*INT$/ { i = "int" } END { print(i "" l) }' "$file")
42 1.1 rillig ldbl=$(sed -n -E 's,^#.*LDOUBLE[^0-9]+([0-9]+)$,ldbl-\1,p' "$file")
43 1.1 rillig
44 1.1 rillig if [ "$size" != "int" ] && [ "$size" != "long" ]; then
45 1.1 rillig size="????" # mips
46 1.1 rillig fi
47 1.1 rillig
48 1.1 rillig case $platform in ????*) indent='\t';; *) indent='\t\t';; esac
49 1.1 rillig
50 1.1 rillig printf '\t\t\t''platform["%s"]'"$indent"'= "%s %-5s %-4s %s"\n' \
51 1.1 rillig "$platform" "$char" "$ilp" "$size" "$ldbl"
52 1.1 rillig done
53