Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 1 | #!/usr/bin/m4 |
| 2 | # |
| 3 | # Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org> |
| 4 | # Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com> |
| 5 | # All rights reserved. |
| 6 | # |
| 7 | # Redistribution and use in source and binary forms, with or without |
| 8 | # modification, are permitted provided that the following conditions |
| 9 | # are met: |
| 10 | # 1. Redistributions of source code must retain the above copyright |
| 11 | # notice, this list of conditions and the following disclaimer. |
| 12 | # 2. Redistributions in binary form must reproduce the above copyright |
| 13 | # notice, this list of conditions and the following disclaimer in the |
| 14 | # documentation and/or other materials provided with the distribution. |
| 15 | # 3. The name of the author may not be used to endorse or promote products |
| 16 | # derived from this software without specific prior written permission. |
| 17 | # |
| 18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 29 | AC_DEFUN([st_MPERS],[ |
| 30 | |
| 31 | pushdef([MPERS_NAME], translit([$1], [a-z], [A-Z])) |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 32 | pushdef([HAVE_MPERS], [HAVE_]MPERS_NAME[_MPERS]) |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 33 | pushdef([HAVE_RUNTIME], [HAVE_]MPERS_NAME[_RUNTIME]) |
| 34 | pushdef([CFLAG], [-$1]) |
| 35 | pushdef([st_cv_cc], [st_cv_$1_cc]) |
| 36 | pushdef([st_cv_runtime], [st_cv_$1_runtime]) |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 37 | pushdef([st_cv_mpers], [st_cv_$1_mpers]) |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 38 | |
| 39 | case "$arch" in |
| 40 | [$2]) |
Dmitry V. Levin | e2a3370 | 2015-08-27 19:51:05 +0000 | [diff] [blame] | 41 | AH_TEMPLATE([HAVE_GNU_STUBS_32_H], |
| 42 | [Define to 1 if you have the <gnu/stubs-32.h> header file.]) |
| 43 | AH_TEMPLATE([HAVE_GNU_STUBS_X32_H], |
| 44 | [Define to 1 if you have the <gnu/stubs-x32.h> header file.]) |
| 45 | pushdef([gnu_stubs], [gnu/stubs-][m4_substr([$1], 1)][.h]) |
| 46 | AC_CHECK_HEADERS([gnu_stubs], [IFLAG=], |
| 47 | [mkdir -p gnu |
| 48 | : > gnu_stubs |
| 49 | AC_MSG_NOTICE([Created empty gnu_stubs]) |
| 50 | IFLAG=-I.]) |
| 51 | popdef([gnu_stubs]) |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 52 | saved_CFLAGS="$CFLAGS" |
Dmitry V. Levin | e2a3370 | 2015-08-27 19:51:05 +0000 | [diff] [blame] | 53 | CFLAGS="$CFLAGS CFLAG $IFLAG" |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 54 | AC_CACHE_CHECK([for CFLAG compile support], [st_cv_cc], |
| 55 | [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdint.h> |
| 56 | int main(){return 0;}]])], |
| 57 | [st_cv_cc=yes], |
| 58 | [st_cv_cc=no])]) |
| 59 | if test $st_cv_cc = yes; then |
| 60 | AC_CACHE_CHECK([for CFLAG runtime support], [st_cv_runtime], |
| 61 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdint.h> |
| 62 | int main(){return 0;}]])], |
| 63 | [st_cv_runtime=yes], |
| 64 | [st_cv_runtime=no], |
| 65 | [st_cv_runtime=no])]) |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 66 | AC_CACHE_CHECK([whether mpers.sh CFLAG works], [st_cv_mpers], |
| 67 | [if CC="$CC" CPP="$CPP" CPPFLAGS="$CPPFLAGS" \ |
| 68 | $srcdir/mpers_test.sh [$1]; then |
| 69 | st_cv_mpers=yes |
| 70 | else |
| 71 | st_cv_mpers=no |
| 72 | fi]) |
| 73 | if test $st_cv_mpers = yes; then |
| 74 | AC_DEFINE(HAVE_MPERS, [1], |
| 75 | [Define to 1 if you have CFLAG mpers support]) |
| 76 | fi |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 77 | fi |
| 78 | CFLAGS="$saved_CFLAGS" |
| 79 | ;; |
| 80 | |
| 81 | *) |
| 82 | st_cv_runtime=no |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 83 | st_cv_mpers=no |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 84 | ;; |
| 85 | esac |
| 86 | |
| 87 | AM_CONDITIONAL(HAVE_RUNTIME, [test "$st_cv_runtime" = yes]) |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 88 | AM_CONDITIONAL(HAVE_MPERS, [test "$st_cv_mpers" = yes]) |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 89 | |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 90 | popdef([st_cv_mpers]) |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 91 | popdef([st_cv_runtime]) |
| 92 | popdef([st_cv_cc]) |
| 93 | popdef([CFLAG]) |
| 94 | popdef([HAVE_RUNTIME]) |
Elvira Khabirova | 0929422 | 2015-08-04 01:47:02 +0300 | [diff] [blame] | 95 | popdef([HAVE_MPERS]) |
Dmitry V. Levin | f8b4913 | 2015-07-23 11:19:47 +0000 | [diff] [blame] | 96 | popdef([MPERS_NAME]) |
| 97 | |
| 98 | ]) |