bump version for 1.0.49 release
[uclibc-ng.git] / extra / scripts / gen_bits_syscall_h.sh
blobbfd06b832a73b78cf5a80ff5a12201bf1cd250aa
1 #!/bin/sh
3 # Copyright (C) 2001 Manuel Novoa III <mjn3@uclibc.org>
4 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
6 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9 # June 27, 2001 Manuel Novoa III
11 # This script expects CC (as used in the Makefiles) to be set
12 # in the environment, and outputs the appropriate bits/sysnum.h #
13 # corresponding to asm/unistd.h to stdout.
15 # Warning!!! This does _no_ error checking!!!
17 if [ "${KERNEL_HEADERS:-/}" != "/" ] ; then
18 INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
19 else
20 # Let the toolchain use its configure paths.
21 INCLUDE_OPTS=
24 case $CC in
25 *icc*) CC_SYSNUM_ARGS="-dM" ;;
26 *clang*) CC_SYSNUM_ARGS="-dM" ;;
27 *) CC_SYSNUM_ARGS="-dN" ;;
28 esac
30 ( echo "#include <asm/unistd.h>";
31 echo "#include <asm/unistd.h>" |
32 $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
33 sed -n -r \
34 -e 's/^[ ]*#define[ ]*(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/UCLIBC\1\2 \1\2/gp' \
35 -e 's/^[ ]*#undef[ ]*(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/UNDEFUCLIBC\1\2 \1\2/gp' # needed to strip out any kernel-internal defines
36 ) |
37 $CC -E $INCLUDE_OPTS - |
39 cat <<-EOF
40 /* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */
41 /* See $0 for more information. */
43 #ifndef _BITS_SYSNUM_H
44 #define _BITS_SYSNUM_H
46 #ifndef _SYSCALL_H
47 # error "Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead."
48 #endif
50 EOF
51 sed -n -r -e 's/^UCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*) *(.*)/#undef \1\2\
52 #define \1\2 \3\
53 #define SYS_\2 \1\2/gp' \
54 -e 's/^UNDEFUCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/#undef \1\2\
55 #undef SYS_\2/gp'
56 cat <<-EOF
58 #endif
59 EOF