2245 |
21 Apr 10 |
peter |
## $Id$ |
2245 |
21 Apr 10 |
peter |
2 |
# |
2245 |
21 Apr 10 |
peter |
# SYNOPSIS |
2245 |
21 Apr 10 |
peter |
4 |
# |
2245 |
21 Apr 10 |
peter |
# YAT_LT_LINK_IFELSE(program, [action-if-true], [action-if-not-true]) |
2245 |
21 Apr 10 |
peter |
6 |
# |
2245 |
21 Apr 10 |
peter |
# DESCRIPTION |
2245 |
21 Apr 10 |
peter |
8 |
# |
2245 |
21 Apr 10 |
peter |
# COPYLEFT |
2245 |
21 Apr 10 |
peter |
10 |
# |
3114 |
10 Nov 13 |
peter |
# Copyright (C) 2010, 2011, 2013 Peter Johansson |
2245 |
21 Apr 10 |
peter |
12 |
# |
2245 |
21 Apr 10 |
peter |
# This file is part of the yat library, http://dev.thep.lu.se/yat |
2245 |
21 Apr 10 |
peter |
14 |
# |
2245 |
21 Apr 10 |
peter |
# The yat library is free software; you can redistribute it and/or |
2245 |
21 Apr 10 |
peter |
# modify it under the terms of the GNU General Public License as |
2245 |
21 Apr 10 |
peter |
# published by the Free Software Foundation; either version 3 of the |
2245 |
21 Apr 10 |
peter |
# License, or (at your option) any later version. |
2245 |
21 Apr 10 |
peter |
19 |
# |
2245 |
21 Apr 10 |
peter |
# The yat library is distributed in the hope that it will be useful, |
2245 |
21 Apr 10 |
peter |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2245 |
21 Apr 10 |
peter |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2245 |
21 Apr 10 |
peter |
# General Public License for more details. |
2245 |
21 Apr 10 |
peter |
24 |
# |
2245 |
21 Apr 10 |
peter |
# You should have received a copy of the GNU General Public License |
2245 |
21 Apr 10 |
peter |
# along with yat. If not, see <http://www.gnu.org/licenses/>. |
2245 |
21 Apr 10 |
peter |
27 |
# |
2245 |
21 Apr 10 |
peter |
28 |
|
3033 |
28 Apr 13 |
peter |
# Based on _KPSE_USE_LIBTOOL by |
2346 |
21 Oct 10 |
peter |
# Peter Breitenlohner <peb@mppmu.mpg.de> shared here |
2346 |
21 Oct 10 |
peter |
# http://www.mail-archive.com/autoconf@gnu.org/msg19948.html |
2346 |
21 Oct 10 |
peter |
32 |
|
2245 |
21 Apr 10 |
peter |
33 |
# |
3069 |
27 Aug 13 |
peter |
# serial 5 (yat 0.11) |
2245 |
21 Apr 10 |
peter |
35 |
# |
2245 |
21 Apr 10 |
peter |
36 |
|
2376 |
20 Dec 10 |
peter |
# YAT_LT_LINK_IFELSE(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) |
2376 |
20 Dec 10 |
peter |
38 |
# ------------------------------------------------------------- |
2376 |
20 Dec 10 |
peter |
# Same as AC_LINK_IFELSE but linking via libtool |
2245 |
21 Apr 10 |
peter |
40 |
AC_DEFUN([YAT_LT_LINK_IFELSE], |
2245 |
21 Apr 10 |
peter |
41 |
[ |
2346 |
21 Oct 10 |
peter |
42 |
YAT_USE_LIBTOOL_PUSH |
2346 |
21 Oct 10 |
peter |
43 |
AC_LINK_IFELSE($@) |
2346 |
21 Oct 10 |
peter |
44 |
YAT_USE_LIBTOOL_POP |
2245 |
21 Apr 10 |
peter |
45 |
]) # YAT_LT_LINK_IFELSE |
2245 |
21 Apr 10 |
peter |
46 |
|
3033 |
28 Apr 13 |
peter |
47 |
|
2376 |
20 Dec 10 |
peter |
# YAT_USE_LIBTOOL_PUSH |
2376 |
20 Dec 10 |
peter |
49 |
# -------------------- |
3113 |
10 Nov 13 |
peter |
# Assign `$ac_link' to use libtool. Variable is saved so they can be |
3113 |
10 Nov 13 |
peter |
# restored with YAT_USE_LIBTOOL_POP |
2346 |
21 Oct 10 |
peter |
52 |
AC_DEFUN([YAT_USE_LIBTOOL_PUSH], |
2346 |
21 Oct 10 |
peter |
53 |
[ |
2346 |
21 Oct 10 |
peter |
54 |
m4_defn([LT_INIT]) |
2376 |
20 Dec 10 |
peter |
55 |
m4_ifdef([_YAT_USE_LIBTOOL], [], |
2394 |
06 Jan 11 |
peter |
56 |
[LT_OUTPUT |
2346 |
21 Oct 10 |
peter |
57 |
yat_use_libtool_ac_link=$ac_link; |
3069 |
27 Aug 13 |
peter |
58 |
ac_link='./libtool --mode=link --tag=_YAT_USE_LIBTOOL_TAG '"$ac_link"; |
2346 |
21 Oct 10 |
peter |
59 |
]) dnl |
2394 |
06 Jan 11 |
peter |
60 |
m4_pushdef([_YAT_USE_LIBTOOL], [yes]) |
2346 |
21 Oct 10 |
peter |
61 |
]) # YAT_USE_LIBTOOL_PUSH |
2245 |
21 Apr 10 |
peter |
62 |
|
3033 |
28 Apr 13 |
peter |
63 |
|
2376 |
20 Dec 10 |
peter |
# YAT_USE_LIBTOOL_POP |
2376 |
20 Dec 10 |
peter |
65 |
# -------------------- |
2376 |
20 Dec 10 |
peter |
# Restore values of `$ac_link' and `$ac_compile' to what they were |
2376 |
20 Dec 10 |
peter |
# prior YAT_USE_LIBTOOL_PUSH |
2346 |
21 Oct 10 |
peter |
68 |
AC_DEFUN([YAT_USE_LIBTOOL_POP], |
2346 |
21 Oct 10 |
peter |
69 |
[ |
2394 |
06 Jan 11 |
peter |
70 |
m4_popdef([_YAT_USE_LIBTOOL]) |
2394 |
06 Jan 11 |
peter |
71 |
m4_ifndef([_YAT_USE_LIBTOOL], dnl |
3113 |
10 Nov 13 |
peter |
72 |
[ac_link=$yat_use_libtool_ac_link; |
2346 |
21 Oct 10 |
peter |
73 |
]) |
2346 |
21 Oct 10 |
peter |
74 |
]) # YAT_USE_LIBTOOL_POP |
2245 |
21 Apr 10 |
peter |
75 |
|
2376 |
20 Dec 10 |
peter |
76 |
|
3070 |
27 Aug 13 |
peter |
# YAT_LT_LINK_LA_IFELSE(input, [action-if-true], [action-if-false]) |
3070 |
27 Aug 13 |
peter |
78 |
# ----------------------------------------------------------------- |
3070 |
27 Aug 13 |
peter |
# Try to create a libtool archive in two steps. First, run the |
3070 |
27 Aug 13 |
peter |
# compiler on input similar to AC_COMPILE_IFELSE, but input is not |
3070 |
27 Aug 13 |
peter |
# expected to have a main() function. If successful, try to create a |
3070 |
27 Aug 13 |
peter |
# libconftest.la with created object as input and linking with |
3070 |
27 Aug 13 |
peter |
# $LIBS. If both steps are successful, execute shell code |
3070 |
27 Aug 13 |
peter |
# action-if-true, otherwise execute action-if-false. |
3073 |
30 Aug 13 |
peter |
85 |
# |
3073 |
30 Aug 13 |
peter |
# Note, that this macro can be used to check if libraries in $LIBS are |
3073 |
30 Aug 13 |
peter |
# suitable to be linked into a libtool archive, but not that if input |
3073 |
30 Aug 13 |
peter |
# is not using lib the test will test will succeed regardless whether |
3073 |
30 Aug 13 |
peter |
# the lib is suitable or not. |
3069 |
27 Aug 13 |
peter |
90 |
AC_DEFUN([YAT_LT_LINK_LA_IFELSE], |
3069 |
27 Aug 13 |
peter |
91 |
[ |
3069 |
27 Aug 13 |
peter |
92 |
YAT_USE_LIBTOOL_PUSH |
3090 |
26 Sep 13 |
peter |
93 |
AC_LANG_CONFTEST([AC_LANG_SOURCE([$1])]) |
3069 |
27 Aug 13 |
peter |
94 |
|
3070 |
27 Aug 13 |
peter |
95 |
m4_pushdef([ACTION_IF_FALSE], |
3070 |
27 Aug 13 |
peter |
96 |
[_YAT_MSG_LOG_CONFTEST |
3070 |
27 Aug 13 |
peter |
97 |
$3]) |
3069 |
27 Aug 13 |
peter |
98 |
YAT_RUN_LOG([./libtool --mode=compile --tag=_YAT_USE_LIBTOOL_TAG \ |
3070 |
27 Aug 13 |
peter |
99 |
$CXX $CPPFLAGS $CXXFLAGS -c -o conftest.lo conftest.$ac_ext], |
3069 |
27 Aug 13 |
peter |
100 |
[YAT_RUN_LOG([./libtool --mode=link --tag=_YAT_USE_LIBTOOL_TAG \ |
3069 |
27 Aug 13 |
peter |
101 |
$CXX $CXXFLAGS $LDFLAGS -o libconftest.la \ |
3069 |
27 Aug 13 |
peter |
102 |
-rpath `pwd` conftest.lo $LIBS], |
3070 |
27 Aug 13 |
peter |
103 |
[$2], [ACTION_IF_FALSE])], |
3070 |
27 Aug 13 |
peter |
104 |
[ACTION_IF_FALSE]) |
3069 |
27 Aug 13 |
peter |
105 |
|
3073 |
30 Aug 13 |
peter |
106 |
./libtool --mode=clean rm -f conftest.lo libconftest.la >&AS_MESSAGE_LOG_FD |
3070 |
27 Aug 13 |
peter |
107 |
rm -f conftest.$ac_ext |
3070 |
27 Aug 13 |
peter |
108 |
m4_popdef([ACTION_IF_FALSE]) |
3069 |
27 Aug 13 |
peter |
109 |
YAT_USE_LIBTOOL_POP |
3086 |
19 Sep 13 |
peter |
110 |
]) # YAT_LT_LINK_LA_IFELSE |
3069 |
27 Aug 13 |
peter |
111 |
|
3070 |
27 Aug 13 |
peter |
# _YAT_MSG_LOG_CONFTEST |
3070 |
27 Aug 13 |
peter |
113 |
# --------------------- |
3070 |
27 Aug 13 |
peter |
# log source file conftest.$ac_ext |
3070 |
27 Aug 13 |
peter |
115 |
m4_define([_YAT_MSG_LOG_CONFTEST], |
3070 |
27 Aug 13 |
peter |
116 |
[AS_ECHO(["$as_me: failed code was:"]) >&AS_MESSAGE_LOG_FD |
3070 |
27 Aug 13 |
peter |
117 |
sed 's/^/| /' conftest.$ac_ext >&AS_MESSAGE_LOG_FD |
3070 |
27 Aug 13 |
peter |
118 |
]) |
3069 |
27 Aug 13 |
peter |
119 |
|
2376 |
20 Dec 10 |
peter |
# _YAT_USE_LIBTOOL_TAG |
2376 |
20 Dec 10 |
peter |
121 |
# -------------------- |
3069 |
27 Aug 13 |
peter |
# internal macro to select tag depending on active language |
2346 |
21 Oct 10 |
peter |
123 |
m4_define([_YAT_USE_LIBTOOL_TAG], |
3034 |
30 Apr 13 |
peter |
124 |
[AC_LANG_CASE([C],[CC],[C++],[CXX],[Fortran 77], [F77],[Fortran], [FC])]) |