gen_bits_syscall_h.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. *) CC_SYSNUM_ARGS="-dN" ;;
  24. esac
  25. ( echo "#include <asm/unistd.h>";
  26. echo "#include <asm/unistd.h>" |
  27. $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
  28. sed -n -r \
  29. -e '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. (
  34. cat <<-EOF
  35. /* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */
  36. /* See $0 for more information. */
  37. #ifndef _BITS_SYSNUM_H
  38. #define _BITS_SYSNUM_H
  39. #ifndef _SYSCALL_H
  40. # error "Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead."
  41. #endif
  42. EOF
  43. sed -n -r -e 's/^UCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*) *(.*)/#undef \1\2\
  44. #define \1\2 \3\
  45. #define SYS_\2 \1\2/gp' \
  46. -e 's/^UNDEFUCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/#undef \1\2\
  47. #undef SYS_\2/gp'
  48. cat <<-EOF
  49. #endif
  50. EOF
  51. )