compile3.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. # Copyright (C) 2010-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Make sure 'compile' wraps the Microsoft C/C++ compiler (cl) correctly
  17. am_create_testdir=empty
  18. required=xsi-lib-shell
  19. . test-init.sh
  20. get_shell_script compile
  21. # Use a dummy cl, since cl isn't readily available on all systems
  22. cat >cl <<'END'
  23. #! /bin/sh
  24. echo "$@"
  25. END
  26. chmod +x ./cl
  27. # POSIX mandates that the compiler accepts a space between the -I,
  28. # -l and -L options and their respective arguments. Traditionally,
  29. # this should work also without a space. Try both usages.
  30. for sp in '' ' '; do
  31. # Check if compile handles "-o foo", -I, -l, -L, -Xlinker -Wl,
  32. opts=$(LIB= ./compile ./cl foo.c -o foo -l${sp}bar -L${sp}gazonk \
  33. -I${sp}baz -Xlinker foobar -Wl,-foo,bar)
  34. test x"$opts" = \
  35. x"foo.c -Fefoo bar.lib -Ibaz -link -LIBPATH:gazonk foobar -foo bar"
  36. # Check if compile handles "-o foo.obj"
  37. opts=$(./compile ./cl -c foo.c -o foo.obj -I${sp}baz)
  38. test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
  39. # Check if compile handles "-o foo.o"
  40. opts=$(./compile ./cl -c foo.c -o foo.o -I${sp}baz)
  41. test x"$opts" = x"-c foo.c -Fofoo.o -Ibaz"
  42. # Check if compile handles "foo.cc" as C++.
  43. opts=$(./compile ./cl -c foo.cc -o foo.o -I${sp}baz)
  44. test x"$opts" = x"-c -Tpfoo.cc -Fofoo.o -Ibaz"
  45. # Check if compile clears the "eat" variable properly.
  46. opts=$(eat=1 ./compile ./cl -c foo.c -o foo.obj -I${sp}baz)
  47. test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
  48. done
  49. :