+++ /dev/null
-dnl Copyright © 2011 Nick Bowler
-dnl
-dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-dnl This is free software: you are free to do what the fuck you want to.
-dnl There is NO WARRANTY, to the extent permitted by law.
-
-m4_define([_DX_COMPUTE_C_STRING_PROG], [AC_LANG_PROGRAM([dnl
-#include <stdio.h>
-#include <stdlib.h>
-$2
-char thestr@<:@@:>@ = $1;
-char padstr@<:@@:>@ = "\n!&?~" $1 "~?&!\n";
-], [dnl
-size_t i;
-FILE *f = fopen("conftest.out", "w");
-if (!f)
- return EXIT_FAILURE;
-for (i = 0; i < sizeof thestr; i++) {
- if (*(thestr+i) == '\n')
- *(thestr+i) = ' ';
-}
-fprintf(f, "%s\n", thestr);
-return 0;
-])])
-
-AC_DEFUN([_DX_COMPUTE_C_STRING_NORUN], [dnl
-AC_REQUIRE([DX_PROG_STRINGS])
-if test x"$STRINGS" = x""; then
- AC_MSG_WARN([strings is recommended for cross compilation])
- dx_c_strings=cat
-else
- dx_c_strings="$STRINGS -n 1"
-fi
-dnl else
-AC_COMPILE_IFELSE([_DX_COMPUTE_C_STRING_PROG([$2], [$3])], [dnl
- $dx_c_strings conftest.$OBJEXT | sed -n '/^!&?~/ {
- t top
- :top
- s/^!&?~\(.*\)~?&!$/\1/p
- t
- N
- s/\n/ /g
- t top
- }' > conftest.out
- if read $1 < conftest.out; then :; else
- AC_MSG_ERROR([failed to extract string due to cross compilation.])
- fi
-], [dnl
- ifelse([$4], [], [:], [$4])])
-dnl fi
-])
-
-dnl DX_COMPUTE_C_STRING(variable, string, [prologue], [action-if-failed])
-dnl
-dnl Assigns the value of a C string literal specified by string to the shell
-dnl variable specified by variable. Any newlines in the string are converted
-dnl to spaces. In a cross compilation environment, it works by scanning a
-dnl compiled object file.
-AC_DEFUN([DX_COMPUTE_C_STRING], [dnl
-AC_LANG_PUSH([C])
-AC_RUN_IFELSE([_DX_COMPUTE_C_STRING_PROG([$2], [$3])],
- [read $1 < conftest.out],
- [ifelse([$4], [], [:], [$4])],
- [_DX_COMPUTE_C_STRING_NORUN([$1], [$2], [$3], [$4])])
-AC_LANG_POP([C])
-])