compile7.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 Intel C/C++ compiler (icl) correctly
  17. # with respect to absolute paths.
  18. required='icl'
  19. . test-init.sh
  20. get_shell_script compile
  21. mkdir sub
  22. cat >sub/foo.c <<'EOF'
  23. int foo (void)
  24. {
  25. return 0;
  26. }
  27. EOF
  28. cat >main.c <<'EOF'
  29. extern int foo (void);
  30. int main (void)
  31. {
  32. return foo ();
  33. }
  34. EOF
  35. cwd=$(pwd) || fatal_ "cannot get current directory"
  36. absfoodir=$cwd/sub
  37. absmainc=$cwd/main.c
  38. absmainobj=$cwd/main.obj
  39. cat >> configure.ac << 'END'
  40. AC_PROG_CC
  41. AM_PROG_AR
  42. AC_PROG_RANLIB
  43. AC_CONFIG_FILES([sub/Makefile])
  44. AC_OUTPUT
  45. END
  46. cat > Makefile.am << 'END'
  47. SUBDIRS = sub
  48. END
  49. cat > sub/Makefile.am << 'END'
  50. lib_LIBRARIES = libfoo.a
  51. libfoo_a_SOURCES = foo.c
  52. END
  53. $ACLOCAL
  54. $AUTOCONF
  55. $AUTOMAKE -a
  56. ./configure
  57. $MAKE
  58. ./compile icl $CPPFLAGS $CFLAGS -c -o "$absmainobj" "$absmainc"
  59. # POSIX mandates that the compiler accepts a space between the -I,
  60. # -l and -L options and their respective arguments. Traditionally,
  61. # this should work also without a space. Try both usages.
  62. for sp in '' ' '; do
  63. rm -f main
  64. ./compile icl $CFLAGS $LDFLAGS -L${sp}"$absfoodir" "$absmainobj" \
  65. -o main -l${sp}foo
  66. ./main
  67. done
  68. :