1#!/bin/sh
2#
3# Copyright (C) 2001 Manuel Novoa III <mjn3@uclibc.org>
4# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5#
6# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7#
8
9# June 27, 2001         Manuel Novoa III
10#
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.
14#
15# Warning!!! This does _no_ error checking!!!
16
17if [ "${KERNEL_HEADERS:-/}" != "/" ] ; then
18  INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
19else
20  # Let the toolchain use its configure paths.
21  INCLUDE_OPTS=
22fi
23
24case $CC in
25*icc*) CC_SYSNUM_ARGS="-dM" ;;
26*clang*) CC_SYSNUM_ARGS="-dM" ;;
27*)     CC_SYSNUM_ARGS="-dN" ;;
28esac
29
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 - |
38(
39  cat <<-EOF
40/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */
41/* See $0 for more information. */
42
43#ifndef _BITS_SYSNUM_H
44#define _BITS_SYSNUM_H
45
46#ifndef _SYSCALL_H
47# error "Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead."
48#endif
49
50EOF
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
57
58#endif
59EOF
60)
61