gen_bits_syscall_h.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # June 27, 2001 Manuel Novoa III
  9. #
  10. # This script expects top_builddir and CC (as used in the Makefiles) to be set
  11. # in the environment, and outputs the appropriate
  12. # $top_builddir/include/bits/sysnum.h # corresponding to
  13. # $top_builddir/include/asm/unistd.h to stdout.
  14. #
  15. # Warning!!! This does _no_ error checking!!!
  16. if [ "${KERNEL_HEADERS:-/}" != "/" ] ; then
  17. INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
  18. else
  19. # Let the toolchain use its configure paths.
  20. INCLUDE_OPTS=
  21. fi
  22. case $CC in
  23. *icc*) CC_SYSNUM_ARGS="-dM" ;;
  24. *) CC_SYSNUM_ARGS="-dN" ;;
  25. esac
  26. ( echo "#include <asm/unistd.h>";
  27. echo "#include <asm/unistd.h>" |
  28. $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
  29. sed -ne 's/^[ ]*#define[ ]*\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/UCLIBC\1\2 \1\2/gp' \
  30. -e 's/^[ ]*#undef[ ]*\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/UNDEFUCLIBC\1\2 \1\2/gp' # needed to strip out any kernel-internal defines
  31. ) |
  32. $CC -E $INCLUDE_OPTS - |
  33. ( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ;
  34. echo ;
  35. echo "#ifndef _BITS_SYSNUM_H" ;
  36. echo "#define _BITS_SYSNUM_H" ;
  37. echo ;
  38. echo "#ifndef _SYSCALL_H" ;
  39. echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
  40. echo "#endif" ; echo ;
  41. sed -ne 's/^UCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\) *\(.*\)/#undef \1\2\
  42. #define \1\2 \3\
  43. #define SYS_\2 \1\2/gp' \
  44. -e 's/^UNDEFUCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/#undef \1\2/gp'
  45. echo ;
  46. echo "#endif" ;
  47. )