gen_bits_syscall_h.sh 1.6 KB

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