b43-asm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. #
  3. # b43-asm preprocessing frontend
  4. #
  5. # Copyright (c) 2010 Michael Buesch <m@bues.ch>
  6. # Licensed under the GNU/GPL version 2.
  7. #
  8. # The b43-asm backend binary
  9. B43_ASM="b43-asm.bin"
  10. # The C preprocessor binary
  11. CPP="gcc -E"
  12. # This variable is changed by the installer scripts.
  13. installed=0
  14. if [ $installed -eq 0 ] && [ -x "./$B43_ASM" ]; then
  15. B43_ASM="./$B43_ASM"
  16. fi
  17. # Probe the CPP binary
  18. $CPP --help >/dev/null 2>&1
  19. if [ $? -ne 0 ]; then
  20. echo "ERROR: Failed to execute the C preprocessor \"$CPP\""
  21. exit 1
  22. fi
  23. # Probe the b43-asm binary
  24. $B43_ASM a b --help >/dev/null 2>&1
  25. if [ $? -ne 0 ]; then
  26. echo "ERROR: Failed to execute the b43-asm binary \"$B43_ASM\""
  27. exit 2
  28. fi
  29. if [ $# -lt 2 ]; then
  30. $B43_ASM --help
  31. exit 3
  32. fi
  33. infile="$1"
  34. shift
  35. outfile="$1"
  36. shift
  37. cpp_args=
  38. if [ "$1" = "--cpp-args" ]; then
  39. shift
  40. while [ "$1" != "--" ]; do
  41. if [ $# -eq 0 ]; then
  42. echo "ERROR: --cpp-args must be terminated by --"
  43. exit 4
  44. fi
  45. cpp_args="$cpp_args $1"
  46. shift
  47. done
  48. shift
  49. fi
  50. if [ "$infile" != "-" ]; then
  51. if ! [ -r "$infile" ]; then
  52. echo "ERROR: Can not read input file \"$infile\""
  53. exit 5
  54. fi
  55. fi
  56. $CPP -x c++ -traditional-cpp $cpp_args "$infile" | $B43_ASM "-" "$outfile" --__real_infile "$infile" $@