blob: 1fe8a8e8ee2c9513f3da6fb951d333be3be30806 [file] [log] [blame]
Dmitry V. Levin38a34c92015-12-17 17:56:48 +00001#!/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. Levinf8b49132015-07-23 11:19:47 +000029AC_DEFUN([st_MPERS],[
30
31pushdef([MPERS_NAME], translit([$1], [a-z], [A-Z]))
Elvira Khabirova09294222015-08-04 01:47:02 +030032pushdef([HAVE_MPERS], [HAVE_]MPERS_NAME[_MPERS])
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000033pushdef([HAVE_RUNTIME], [HAVE_]MPERS_NAME[_RUNTIME])
34pushdef([CFLAG], [-$1])
35pushdef([st_cv_cc], [st_cv_$1_cc])
36pushdef([st_cv_runtime], [st_cv_$1_runtime])
Elvira Khabirova09294222015-08-04 01:47:02 +030037pushdef([st_cv_mpers], [st_cv_$1_mpers])
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000038
39case "$arch" in
40 [$2])
Dmitry V. Levine2a33702015-08-27 19:51:05 +000041 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. Levinf8b49132015-07-23 11:19:47 +000052 saved_CFLAGS="$CFLAGS"
Dmitry V. Levine2a33702015-08-27 19:51:05 +000053 CFLAGS="$CFLAGS CFLAG $IFLAG"
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000054 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 Khabirova09294222015-08-04 01:47:02 +030066 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. Levinf8b49132015-07-23 11:19:47 +000077 fi
78 CFLAGS="$saved_CFLAGS"
79 ;;
80
81 *)
82 st_cv_runtime=no
Elvira Khabirova09294222015-08-04 01:47:02 +030083 st_cv_mpers=no
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000084 ;;
85esac
86
87AM_CONDITIONAL(HAVE_RUNTIME, [test "$st_cv_runtime" = yes])
Elvira Khabirova09294222015-08-04 01:47:02 +030088AM_CONDITIONAL(HAVE_MPERS, [test "$st_cv_mpers" = yes])
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000089
Elvira Khabirova09294222015-08-04 01:47:02 +030090popdef([st_cv_mpers])
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000091popdef([st_cv_runtime])
92popdef([st_cv_cc])
93popdef([CFLAG])
94popdef([HAVE_RUNTIME])
Elvira Khabirova09294222015-08-04 01:47:02 +030095popdef([HAVE_MPERS])
Dmitry V. Levinf8b49132015-07-23 11:19:47 +000096popdef([MPERS_NAME])
97
98])