comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/aclocal/build-to-host.m4 @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 68:5028fdace37b
1 # build-to-host.m4 serial 3
2 dnl Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl Written by Bruno Haible.
8
9 dnl When the build environment ($build_os) is different from the target runtime
10 dnl environment ($host_os), file names may need to be converted from the build
11 dnl environment syntax to the target runtime environment syntax. This is
12 dnl because the Makefiles are executed (mostly) by build environment tools and
13 dnl therefore expect file names in build environment syntax, whereas the runtime
14 dnl expects file names in target runtime environment syntax.
15 dnl
16 dnl For example, if $build_os = cygwin and $host_os = mingw32, filenames need
17 dnl be converted from Cygwin syntax to native Windows syntax:
18 dnl /cygdrive/c/foo/bar -> C:\foo\bar
19 dnl /usr/local/share -> C:\cygwin64\usr\local\share
20 dnl
21 dnl gl_BUILD_TO_HOST([somedir])
22 dnl This macro takes as input an AC_SUBSTed variable 'somedir', which must
23 dnl already have its final value assigned, and produces two additional
24 dnl AC_SUBSTed variables 'somedir_c' and 'somedir_c_make', that designate the
25 dnl same file name value, just in different syntax:
26 dnl - somedir_c is the file name in target runtime environment syntax,
27 dnl as a C string (starting and ending with a double-quote,
28 dnl and with escaped backslashes and double-quotes in
29 dnl between).
30 dnl - somedir_c_make is the same thing, escaped for use in a Makefile.
31
32 AC_DEFUN([gl_BUILD_TO_HOST],
33 [
34 AC_REQUIRE([AC_CANONICAL_BUILD])
35 AC_REQUIRE([AC_CANONICAL_HOST])
36 AC_REQUIRE([gl_BUILD_TO_HOST_INIT])
37
38 dnl Define somedir_c.
39 gl_final_[$1]="$[$1]"
40 dnl Translate it from build syntax to host syntax.
41 case "$build_os" in
42 cygwin*)
43 case "$host_os" in
44 mingw* | windows*)
45 gl_final_[$1]=`cygpath -w "$gl_final_[$1]"` ;;
46 esac
47 ;;
48 esac
49 dnl Convert it to C string syntax.
50 [$1]_c=`printf '%s\n' "$gl_final_[$1]" | sed -e "$gl_sed_double_backslashes" -e "$gl_sed_escape_doublequotes" | tr -d "$gl_tr_cr"`
51 [$1]_c='"'"$[$1]_c"'"'
52 AC_SUBST([$1_c])
53
54 dnl Define somedir_c_make.
55 [$1]_c_make=`printf '%s\n' "$[$1]_c" | sed -e "$gl_sed_escape_for_make_1" -e "$gl_sed_escape_for_make_2" | tr -d "$gl_tr_cr"`
56 dnl Use the substituted somedir variable, when possible, so that the user
57 dnl may adjust somedir a posteriori when there are no special characters.
58 if test "$[$1]_c_make" = '\"'"${gl_final_[$1]}"'\"'; then
59 [$1]_c_make='\"$([$1])\"'
60 fi
61 AC_SUBST([$1_c_make])
62 ])
63
64 dnl Some initializations for gl_BUILD_TO_HOST.
65 AC_DEFUN([gl_BUILD_TO_HOST_INIT],
66 [
67 gl_sed_double_backslashes='s/\\/\\\\/g'
68 gl_sed_escape_doublequotes='s/"/\\"/g'
69 changequote(,)dnl
70 gl_sed_escape_for_make_1="s,\\([ \"&'();<>\\\\\`|]\\),\\\\\\1,g"
71 changequote([,])dnl
72 gl_sed_escape_for_make_2='s,\$,\\$$,g'
73 dnl Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
74 dnl does not understand '\r'.
75 case `echo r | tr -d '\r'` in
76 '') gl_tr_cr='\015' ;;
77 *) gl_tr_cr='\r' ;;
78 esac
79 ])