Changeset 3069


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

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/m4/yat_lt_link_ifelse.m4

    r3034 r3069  
    3232
    3333#
    34 # serial 4 (yat 0.11)
     34# serial 5 (yat 0.11)
    3535#
    3636
     
    5656  [LT_OUTPUT
    5757   yat_use_libtool_ac_compile=$ac_compile;
    58    ac_compile="./libtool --mode=compile --tag=_YAT_USE_LIBTOOL_TAG $ac_link";
     58   ac_compile='./libtool --mode=compile --tag=_YAT_USE_LIBTOOL_TAG '"$ac_compile";
    5959   yat_use_libtool_ac_link=$ac_link;
    60    ac_link="./libtool --mode=link --tag=_YAT_USE_LIBTOOL_TAG $ac_link";
     60   ac_link='./libtool --mode=link --tag=_YAT_USE_LIBTOOL_TAG '"$ac_link";
    6161  ]) dnl
    6262m4_pushdef([_YAT_USE_LIBTOOL], [yes])
     
    7878
    7979
     80#
     81AC_DEFUN([YAT_LT_LINK_LA_IFELSE],
     82[
     83YAT_USE_LIBTOOL_PUSH
     84#ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
     85cat > conftest.cpp << EOF
     86$1
     87EOF
     88
     89# FIXME we should log program etc when failed similar to AC_LINK_IFELSE
     90YAT_RUN_LOG([./libtool --mode=compile --tag=_YAT_USE_LIBTOOL_TAG \
     91       $CXX $CPPFLAGS $CXXFLAGS -c -o conftest.lo conftest.cpp],
     92  [YAT_RUN_LOG([./libtool --mode=link --tag=_YAT_USE_LIBTOOL_TAG \
     93                $CXX $CXXFLAGS $LDFLAGS -o libconftest.la \
     94                -rpath `pwd` conftest.lo $LIBS],
     95               [$2], [$3])],
     96  [$3])
     97
     98YAT_USE_LIBTOOL_POP
     99]) # YAT_LT_LINK_STATIC_IFELSE
     100
     101
    80102# _YAT_USE_LIBTOOL_TAG
    81103# --------------------
    82 # internal macro to select tag depending on active library
     104# internal macro to select tag depending on active language
    83105m4_define([_YAT_USE_LIBTOOL_TAG],
    84106[AC_LANG_CASE([C],[CC],[C++],[CXX],[Fortran 77], [F77],[Fortran], [FC])])
  • trunk/test/Makefile.am

    r3063 r3069  
    9393test/yat_ld_add_flag_test.sh \
    9494test/yat_have_svn_wc_test.sh \
     95test/yat_lt_compile_ifelse_test.sh \
    9596test/yat_lt_link_ifelse_test.sh \
     97test/yat_lt_link_la_ifelse_test.sh \
    9698test/yat_msg_error_test.sh \
    9799test/yat_msg_error_test2.sh \
     
    144146  $(top_srcdir)/m4/ax_check_link_flag.m4 \
    145147  $(shell_test_deps)
     148test/yat_lt_compile_ifelse_test.log: $(shell_test_deps) \
     149  $(top_srcdir)/m4/yat_lt_link_ifelse.m4
    146150test/yat_lt_link_ifelse_test.log: $(top_srcdir)/m4/yat_lt_link_ifelse.m4 \
    147151  $(top_srcdir)/m4/yat.m4 $(shell_test_deps) \
    148152  $(top_builddir)/build_support/yat-config
     153test/yat_lt_link_la_ifelse_test.log: $(shell_test_deps) \
     154  $(top_srcdir)/m4/yat_lt_link_ifelse.m4
    149155test/yat_m4_test.log:$(top_srcdir)/m4/yat.m4 $(shell_test_deps) \
    150156  $(top_builddir)/build_support/yat-config
  • 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.