winegcc_wrapper.in 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # Wrapper script for winegcc to remove .exe file ending automatically
  3. # appended by winebuild.
  4. # See FindWine.cmake for usage
  5. set -e
  6. args="$@"
  7. # Find output name, link mode and architecture
  8. while [ $# -gt 0 ]; do
  9. key="$1"
  10. case $key in
  11. -o)
  12. output=$2
  13. shift
  14. ;;
  15. -c)
  16. no_link=true
  17. ;;
  18. -m32)
  19. win32=true
  20. ;;
  21. -m64)
  22. win64=true
  23. ;;
  24. *)
  25. ;;
  26. esac
  27. shift
  28. done
  29. if [ -z "$output" ]; then
  30. # If -c is used without specifying an output name, GCC defaults to "a.out".
  31. if [ "$no_link" != true ]; then
  32. output="a.out"
  33. no_move=true
  34. fi
  35. fi
  36. # Some Wine distributions can't find their own headers. WINE_INCLUDE_DIR provided
  37. # by FindWine.cmake
  38. extra_args="-I@WINE_INCLUDE_DIR@ -I@WINE_INCLUDE_DIR@/wine/windows"
  39. # Apply manually specified flags
  40. extra_args="$extra_args @WINE_CXX_FLAGS@"
  41. # Apply -m32 library fix if necessary
  42. if [ "$win32" = true ] && [ "$no_link" != true ]; then
  43. extra_args="$extra_args @WINE_32_FLAGS@"
  44. fi
  45. # Apply -m64 library fix if necessary
  46. if [ "$win64" = true ] && [ "$no_link" != true ]; then
  47. extra_args="$extra_args @WINE_64_FLAGS@"
  48. fi
  49. # Work around https://bugs.winehq.org/show_bug.cgi?id=47710
  50. extra_args="$extra_args -D__WIDL_objidl_generated_name_0000000C="
  51. # Run winegcc
  52. export WINEBUILD=@WINE_BUILD@
  53. @WINE_CXX@ $extra_args $args
  54. if [ "$no_move" = true ] || [ "$no_link" = true ]; then
  55. exit 0
  56. fi
  57. if [ ! -e "$output.exe" ]; then
  58. echo "Fatal error in winegcc wrapper: No output file \"$output.exe\" found."
  59. exit 1
  60. fi
  61. mv $output.exe $output