Debian Codegraph @

m4/triplet-transformation.m4

raw
1 dnl
2 dnl _AX_TRIPLET_TRANSFORMATION(SYSTEM-TYPE, SED-SCRIPT [, HEADER])
3 dnl with
4 dnl SYSTEM-TYPE : `build', `host' or `target'
5 dnl SED-SCRIPT : valid sed script transforming the triplet in
6 dnl variable `ac_cv_<SYSTEM-TYPE>'
7 dnl HEADER : message header printed when triplet conversion
8 dnl is applied
9 dnl
10 dnl Read the triplet from the cache variable `ac_cv_<SYSTEM-TYPE>',
11 dnl try to transform it using the sed script SED-SCRIPT. If the
12 dnl transformation results in a change
13 dnl - backup the original triplet in the cache variable
14 dnl `<PROGRAM>_cv_<SYSTEM-TYPE>_orig'
15 dnl - save the transformed one in `ac_cv_<SYSTEM-TYPE>'
16 dnl - update the variables `<SYSTEM-TYPE>-(os|cpu|vendor)' (which is the
17 dnl ultimate goal of this macro).
18 dnl
19 AC_DEFUN([_AX_TRIPLET_TRANSFORMATION],
20 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
21 AC_REQUIRE_AUX_FILE([config.sub])dnl
22 dnl This part should appear in the configure script AFTER the block
23 dnl handling the original sytem-type variables build/host/target.
24 AS_VAR_PUSHDEF([ax_triplet_orig],[]AC_PACKAGE_TARNAME[_cv_$1_orig])
25 dnl The real configure variable `ac_cv_target' might be void.
26 if test x$ac_cv_$1 != x; then
27 dnl here the transformation happens.
28 ax_tt_var=`echo $ac_cv_$1 | sed '$2'`
29 if test x$ax_tt_var = x; then
30 AC_MSG_NOTICE([sed script: $1 triplet conversion `$ac_cv_$1' with sed script `$2'failed.])
31 dnl test if transformed triplet is known to config.sub, hence probably to most of the autotools.
32 elif test x$ax_tt_var != x`$SHELL "$ac_aux_dir/config.sub" $ax_tt_var`; then
33 AC_MSG_NOTICE([`config.sub' test: $1 triplet conversion of `$ac_cv_$1' produced invalid triplet `$ax_tt_var'.])
34 dnl did anything change at all?
35 elif test x$ax_tt_var != x$ac_cv_$1; then
36 dnl print the header just once in one configure script
37 m4_ifnblank([$3],[dnl
38 if test x$ax_tt_header_is_printed != xyes; then
39 ax_tt_header_is_printed=yes
40 AC_MSG_NOTICE([$3])
41 fi])
42 ax_triplet_orig=$ac_cv_$1
43 ac_cv_$1=$ax_tt_var
44 AC_MSG_NOTICE([$1: replacing $ax_triplet_orig -> $ac_cv_$1])
45 dnl Better neutralize ax_tt_var because we call another macro whic might use this
46 dnl variable, too.
47 ax_tt_var=
48 dnl use of autoconf internal: rerun the triplet split cpu/vendor/host
49 _AC_CANONICAL_SPLIT([$1])
50 fi
51 ax_tt_var=
52 fi
53 AS_VAR_POPDEF([ax_triplet_orig])dnl
54 ])dnl _AX_TRIPLET_TRANSFORMATION
55
56 dnl
57 dnl AX_CANONICAL_HOST(PLATFORM-PATTERN, SED-SCRIPT [, TITLE])
58 dnl
59 dnl If UNAME matches PLATFORM-PATTERN convert the build and/or host triplets
60 dnl using SED-SCRIPT. Have configure emit a message if a transformation
61 dnl occurs.
62 dnl
63 dnl This macro works __inside__ configure as if it was called like so on the
64 dnl command line:
65 dnl
66 dnl #! /usr/bin/bash
67 dnl case $(uname) in
68 dnl <PLATFORM-PATTERN>)
69 dnl test -z $mytriplet && mytriplet=$(./config.sub $(./config.guess))
70 dnl ./configure --host=$(echo $mytriplet | sed '<SED-SCRIPT>')
71 dnl ;;
72 dnl *) ./configure
73 dnl esac
74 dnl
75 dnl The macro calls implicitly AC_CANONICAL_HOST.
76 dnl
77 dnl To bypass the macro call such that it should not have any effect
78 dnl on the configure run pass the NON-VOID variable `ax_disable_triplet_transform'
79 dnl to configure. E.g.,
80 dnl
81 dnl ./configure ax_disable_triplet_transform=yes
82 dnl
83 dnl In this case it defaults to calling `AC_CANONICAL_HOST'.
84 dnl
85 AC_DEFUN_ONCE([AX_CANONICAL_HOST],
86 [AC_BEFORE([$0],[AC_CANONICAL_BUILD])dnl
87 AC_BEFORE([$0],[AC_CANONICAL_HOST])dnl
88 ax_tt_header_is_printed=:
89 dnl skip case statement if ax_disable_triplet_transform is set to
90 dnl any non-void string or UNNAME does not match .
91 AS_CASE([x$ax_disable_triplet_transform/`uname`],[x/$1],
92 [_AX_TRIPLET_TRANSFORMATION([build],[$2],[$3])
93 _AX_TRIPLET_TRANSFORMATION([host],[$2],[$3])
94 AC_CANONICAL_HOST
95 ])])dnl AX_CANONICAL_HOST
96
97 dnl
98 dnl GAWK_CANONICAL_HOST
99 dnl
100 dnl This hackery shall fool LIBTOOL and make it believe under MSYS
101 dnl platforms that for build and/or host triplets with vendor `msys'
102 dnl we are on CYGWIN where LIBTOOL(2.4.6/Jan 2020) can handle well
103 dnl shared module libraries.
104 dnl
105 dnl Call `GAWK_CANONICAL_HOST' instead of `AC_CANONICAL_HOST' high up
106 dnl in configure.ac.
107 dnl
108 dnl Bypass the transformation procedure and simply call AC_CANONICAL_HOST instead
109 dnl with
110 dnl
111 dnl ./configure ax_disable_triplet_transform=yes
112 dnl
113 dnl Note that with this macro every setting for CYGWIN will be applied to MSYS.
114 dnl It is tested for the predominant use of generating shared module libraries
115 dnl on MSYS.
116 dnl
117 dnl TODO remove when MSYS is supported by LIBTOOL.
118 dnl
119 AC_DEFUN_ONCE([GAWK_CANONICAL_HOST],
120 [AX_CANONICAL_HOST([MSYS*],[s|-msys$|-cygwin|],[Triplet conversion on MSYS platform:])
121 ])dnl GAWK_CANONICAL_HOST