Ignore:
Timestamp:
Aug 27, 2013, 5:33:22 AM (8 years ago)
Author:
Peter
Message:

New macro YAT_LT_LINK_LA_IFELSE that tests if we can use code and LIBS
to create a libtool archive.

test/yat_lt_link_la_ifelse_test.sh: Test for new macro

test/yat_lt_compile_ifelse_test.sh: Another test checking that
compiling works with YAT_USE_LIBTOOL_PUSH

refs #759

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/yat_lt_link_la_ifelse_test.sh

    r3036 r3069  
    2323. ./test/init.sh || exit 99
    2424
    25 # create a static and shared libraries
    26 rm -frv yat3rd/*
    27 $mkdir_p yat3rd/static
    28 $mkdir_p yat3rd/shared
    29 $mkdir_p yat3rd/m4
    30 cd yat3rd
    31 
    32 cat > configure.ac <<EOF
    33 AC_INIT([yat3rd], [1.0])
    34 AC_CONFIG_MACRO_DIR([m4])
    35 AM_INIT_AUTOMAKE([foreign])
    36 AC_LANG([C++])
    37 AC_PROG_CXXCPP
    38 AC_PROG_CXX
    39 LT_INIT
    40 AC_CONFIG_FILES([Makefile static/Makefile shared/Makefile])
    41 AC_OUTPUT
    42 EOF
    43 
    44 cat > Makefile.am <<EOF
    45 ACLOCAL_AMFLAGS = -I m4
    46 SUBDIRS = static shared
    47 EOF
    48 
    49 cat > static/Makefile.am <<EOF
    50 lib_LIBRARIES = libyatfoo.a
    51 libyatfoo_a_SOURCES = foo.cc
    52 EOF
    53 
    54 cat > static/foo.cc <<EOF
    55 int foo(void) { return 0; }
    56 EOF
    57 
    58 cat > shared/Makefile.am <<EOF
    59 lib_LTLIBRARIES = libyatbar.la
    60 libyatbar_la_SOURCES = bar.cc
    61 AM_LDFLAGS = -shared
    62 EOF
    63 
    64 cat > shared/bar.cc <<EOF
    65 int bar(void) { return 0; }
    66 EOF
    67 
    68 bootstrap
    69 ./configure --libdir=${abs_top_builddir}/${test_dir}/lib
    70 make install
    71 
    72 cd ..
    73 
    74 ls lib
    75 
    76 test -r lib/libyatfoo.a || exit_fail no static yatfoo
    77 test -r lib/libyatbar.la || exit_fail no shared yatbar
    78 test -r lib/libbar.a && exit_fail
    79 
    8025cat > configure.ac <<EOF
    8126AC_INIT([hello], [1.0])
     
    8934YAT_USE_LIBTOOL_PUSH
    9035
    91 echo =====================================================
    92 sleep 1
    93 LDFLAGS="-L`pwd`/lib"
     36rm -fr .libs
    9437
    95 cat > conftest.cc <<___EOF
    96 int foo(void) { return 0; }
    97 ___EOF
     38LDFLAGS="-L$abs_top_builddir/test/lib"
     39AC_MSG_CHECKING([whether linking against -lmy-shared works])
     40LIBS=-lmy-shared
     41YAT_LT_LINK_LA_IFELSE([
     42    int foo_shared(void);
     43    int my_func(void) { return foo_shared(); }
     44  ],[
     45    AC_MSG_RESULT([yes])
     46  ],[
     47    AC_MSG_RESULT([no])
     48    AC_MSG_FAILURE
     49  ])
    9850
    99 cat conftest.cc
    100 
    101 set -x
    102 
    103 sh libtool --mode=compile \$CXX \$CXXFLAGS \$LDFLAGS -o conftest.o conftest.cc -static || exit 1
    104 
    105 sh libtool --tag=CXX --mode=link \$CXX \$CXXFLAGS \$LDFLAGS -o libconftest.la conftest.o -static || exit 1
    106 
    107 
    108 echo =====================================================
    109 sleep 2
    110 
    111 exit 0
    112 
    113 ok=yes
    114 
    115 LDFLAGS="-L`pwd`/lib"
    116 AC_MSG_CHECKING([linking statically against static library])
    117 LIBS=-lyatfoo
    118 YAT_LT_LINK_LA_IFELSE([-static],
    119                       [AC_MSG_RESULT([OK])],
    120                       [ok=no;
    121                        AC_MSG_RESULT([failed])
    122                        AC_MSG_ERROR([no static -lyatfoo])
    123                       ])
    124 
    125 AC_MSG_CHECKING([that shared linking fails against static libyatfoo])
    126 YAT_LT_LINK_LA_IFELSE([-shared],
    127                       [ok=no;
    128                        AC_MSG_RESULT([no])
    129                        AC_MSG_WARN([succesful shared linking against -lyatfoo])
    130                       ],
    131                       [AC_MSG_RESULT([yes failed])])
    132 
    133 LIBS=-lyatbar
    134 AC_MSG_CHECKING([linking shared against shared library])
    135 YAT_LT_LINK_LA_IFELSE([-shared], [AC_MSG_RESULT([ok])],
    136                       [ok=no;
    137                        AC_MSG_RESULT([no])
    138                        AC_MSG_WARN([no shared -lyatbar])])
    139 
    140 AC_MSG_CHECKING([that static linking fails against shared libyatbar])
    141 YAT_LT_LINK_LA_IFELSE([-static],
    142                       [ok=no;
    143                        AC_MSG_RESULT([no])
    144                        AC_MSG_WARN([succesful static linking against -lyatbar])
    145                       ],
    146                       [AC_MSG_RESULT([yes failed])])
    147 
    148 AS_VAR_IF([ok], [no], [AC_MSG_ERROR([see WARNINGs above])])
     51LIBS=-lmy-static
     52AC_MSG_CHECKING([whether linking against -lmy-static works])
     53YAT_LT_LINK_LA_IFELSE([
     54    int foo_static(void);
     55    int my_func(void) { return foo_static(); }
     56  ],[
     57    AC_MSG_RESULT([yes])
     58    AC_MSG_FAILURE
     59  ],[
     60    AC_MSG_RESULT([no])
     61  ])
    14962
    15063AC_CONFIG_FILES([Makefile])
     
    15366
    15467bootstrap
    155 status=0
    156 ./configure || $status=$?
    157 exit $?
    158 ./configure > stdout 2>stderr || status=$?
    159 cat stdout
    160 if test $status != 0; then
    161     tail -n 1000 config.log
    162     cat stderr >&2
    163     exit_fail configure failed
    164 fi
    165 
    166 cat stderr >&2
     68./configure || exit_fail
    16769exit_success
Note: See TracChangeset for help on using the changeset viewer.