update makefile
[musl-tools.git] / sizeof.sh
blob4ab5edee008e0d183a6f7a21430f413b50c0f00e
1 #!/bin/sh
3 export LC_ALL=C
4 MUSL=${MUSL:-../musl}
6 awk -F'\t' '$3 ~ /^[sut]$/ {
7 print $1
8 }' data/musl.tags >/tmp/m.type
9 echo 'short' >>/tmp/m.type
10 echo 'int' >>/tmp/m.type
11 echo 'long' >>/tmp/m.type
12 echo 'long long' >>/tmp/m.type
13 echo 'float' >>/tmp/m.type
14 echo 'double' >>/tmp/m.type
15 echo 'long double' >>/tmp/m.type
16 echo 'wchar_t' >>/tmp/m.type
17 echo '_Bool' >>/tmp/m.type
18 echo 'void*' >>/tmp/m.type
21 cd $MUSL/include
22 find . -name '*.h' | sed 's,^\./,,' >/tmp/m.header
25 echo '#define _GNU_SOURCE 1' >sizeof.c
26 echo '#define _LARGEFILE64_SOURCE 1' >>sizeof.c
27 echo '#define _FILE_OFFSET_BITS 64' >>sizeof.c
28 echo '#define SYSLOG_NAMES 1' >>sizeof.c
29 echo '#include <stddef.h>' >>sizeof.c
30 echo '#include <sys/types.h>' >>sizeof.c
31 echo '' >>sizeof.c
33 sort /tmp/m.header |uniq |awk '
34 /^(sys\/cachectl|stdalign|stdnoreturn)\.h$/ { printf "//" }
35 { print "#include <" $0 ">" }' >>sizeof.c
36 echo '#define p(x) printf("%s\\t%u\\n", #x, sizeof(x));' >>sizeof.c
37 echo 'int main(){' >>sizeof.c
38 sort /tmp/m.type |uniq |awk '
39 /^(struct|union) __(CODE|ptcb|siginfo|ucontext|sigjmp_buf|double_repr|float_repr)$/ ||
40 /^(DIR|FILE|elf_fpxregset_t|struct user_fpxregs_struct|Sg_io_vec)$/ { printf "//" }
41 { print "p(" $0 ")" }' >>sizeof.c
42 echo 'return 0;}' >>sizeof.c