1 | ## $Id: yat_lt_link_ifelse.m4 2451 2011-03-28 23:16:14Z peter $ |
---|
2 | # |
---|
3 | # SYNOPSIS |
---|
4 | # |
---|
5 | # YAT_LT_LINK_IFELSE(program, [action-if-true], [action-if-not-true]) |
---|
6 | # |
---|
7 | # DESCRIPTION |
---|
8 | # |
---|
9 | # COPYLEFT |
---|
10 | # |
---|
11 | # Copyright (C) 2010, 2011 Peter Johansson |
---|
12 | # |
---|
13 | # This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
14 | # |
---|
15 | # The yat library is free software; you can redistribute it and/or |
---|
16 | # modify it under the terms of the GNU General Public License as |
---|
17 | # published by the Free Software Foundation; either version 3 of the |
---|
18 | # License, or (at your option) any later version. |
---|
19 | # |
---|
20 | # The yat library is distributed in the hope that it will be useful, |
---|
21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
23 | # General Public License for more details. |
---|
24 | # |
---|
25 | # You should have received a copy of the GNU General Public License |
---|
26 | # along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
27 | # |
---|
28 | |
---|
29 | # Based on _KPSE_USE_LIBTOOL by |
---|
30 | # Peter Breitenlohner <peb@mppmu.mpg.de> shared here |
---|
31 | # http://www.mail-archive.com/autoconf@gnu.org/msg19948.html |
---|
32 | |
---|
33 | # |
---|
34 | # serial 3 |
---|
35 | # |
---|
36 | |
---|
37 | # YAT_LT_LINK_IFELSE(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) |
---|
38 | # ------------------------------------------------------------- |
---|
39 | # Same as AC_LINK_IFELSE but linking via libtool |
---|
40 | AC_DEFUN([YAT_LT_LINK_IFELSE], |
---|
41 | [ |
---|
42 | YAT_USE_LIBTOOL_PUSH |
---|
43 | AC_LINK_IFELSE($@) |
---|
44 | YAT_USE_LIBTOOL_POP |
---|
45 | ]) # YAT_LT_LINK_IFELSE |
---|
46 | |
---|
47 | # YAT_USE_LIBTOOL_PUSH |
---|
48 | # -------------------- |
---|
49 | # Assign `$ac_link' and `$ac_compile' to use libtool. Variables are |
---|
50 | # saved so they can be restored with YAT_USE_LIBTOOL_POP |
---|
51 | AC_DEFUN([YAT_USE_LIBTOOL_PUSH], |
---|
52 | [ |
---|
53 | m4_defn([LT_INIT]) |
---|
54 | m4_ifdef([_YAT_USE_LIBTOOL], [], |
---|
55 | [LT_OUTPUT |
---|
56 | yat_use_libtool_ac_compile=$ac_compile; |
---|
57 | ac_compile="./libtool --mode=compile --tag=_YAT_USE_LIBTOOL_TAG $ac_link"; |
---|
58 | yat_use_libtool_ac_link=$ac_link; |
---|
59 | ac_link="./libtool --mode=link --tag=_YAT_USE_LIBTOOL_TAG $ac_link"; |
---|
60 | ]) dnl |
---|
61 | m4_pushdef([_YAT_USE_LIBTOOL], [yes]) |
---|
62 | ]) # YAT_USE_LIBTOOL_PUSH |
---|
63 | |
---|
64 | # YAT_USE_LIBTOOL_POP |
---|
65 | # -------------------- |
---|
66 | |
---|
67 | # Restore values of `$ac_link' and `$ac_compile' to what they were |
---|
68 | # prior YAT_USE_LIBTOOL_PUSH |
---|
69 | AC_DEFUN([YAT_USE_LIBTOOL_POP], |
---|
70 | [ |
---|
71 | m4_popdef([_YAT_USE_LIBTOOL]) |
---|
72 | m4_ifndef([_YAT_USE_LIBTOOL], dnl |
---|
73 | [ac_compile=$yat_use_libtool_ac_compile; |
---|
74 | ac_link=$yat_use_libtool_ac_link; |
---|
75 | ]) |
---|
76 | ]) # YAT_USE_LIBTOOL_POP |
---|
77 | |
---|
78 | |
---|
79 | # _YAT_USE_LIBTOOL_TAG |
---|
80 | # -------------------- |
---|
81 | # internal macro to select tag depending on active library |
---|
82 | m4_define([_YAT_USE_LIBTOOL_TAG], |
---|
83 | [AC_LANG_CASE([C], [CC], dnl |
---|
84 | [C++], [CXX], dnl |
---|
85 | [Fortran 77], [F77], dnl |
---|
86 | [Fortran], [FC]) dnl |
---|
87 | ]) |
---|