winegcc_wrapper.in 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. # Additionally, apply "-z notext" to fix an inconsistency in ld.lld vs ld.bfd and ld.gold
  43. if [ "$win32" = true ] && [ "$no_link" != true ]; then
  44. extra_args="$extra_args @WINE_32_FLAGS@ -z notext"
  45. fi
  46. # Apply -m64 library fix if necessary
  47. if [ "$win64" = true ] && [ "$no_link" != true ]; then
  48. extra_args="$extra_args @WINE_64_FLAGS@"
  49. fi
  50. # Work around https://bugs.winehq.org/show_bug.cgi?id=47710
  51. extra_args="$extra_args -D__WIDL_objidl_generated_name_0000000C="
  52. # Run winegcc
  53. export WINEBUILD=@WINE_BUILD@
  54. @WINE_CXX@ $extra_args $args
  55. if [ "$no_move" = true ] || [ "$no_link" = true ]; then
  56. exit 0
  57. fi
  58. if [ ! -e "$output.exe" ]; then
  59. echo "Fatal error in winegcc wrapper: No output file \"$output.exe\" found."
  60. exit 1
  61. fi
  62. mv $output.exe $output