gen_bits_syscall_h.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
  17. case $CC in
  18. *icc*) CC_SYSNUM_ARGS="-dM" ;;
  19. *) CC_SYSNUM_ARGS="-dN" ;;
  20. esac
  21. ( echo "#include <asm/unistd.h>";
  22. echo "#include <asm/unistd.h>" |
  23. $CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
  24. sed -ne 's/^[ ]*#define[ ]*\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/UCLIBC\1\2 \1\2/gp' \
  25. -e 's/^[ ]*#undef[ ]*\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/UNDEFUCLIBC\1\2 \1\2/gp' # needed to strip out any kernel-internal defines
  26. ) |
  27. $CC -E $INCLUDE_OPTS - |
  28. ( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ;
  29. echo ;
  30. echo "#ifndef _BITS_SYSNUM_H" ;
  31. echo "#define _BITS_SYSNUM_H" ;
  32. echo ;
  33. echo "#ifndef _SYSCALL_H" ;
  34. echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
  35. echo "#endif" ; echo ;
  36. sed -ne 's/^UCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\) *\(.*\)/#undef \1\2\
  37. #define \1\2 \3\
  38. #define SYS_\2 \1\2/gp' \
  39. -e 's/^UNDEFUCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/#undef \1\2/gp'
  40. echo ;
  41. echo "#endif" ;
  42. )