-
Notifications
You must be signed in to change notification settings - Fork 53
/
acinclude.m4
405 lines (351 loc) · 11.5 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#############################################################
#
# Checking for GNAT
#
#############################################################
conftest_ok="conftest.ok"
AC_DEFUN([AM_PATH_GNAT],
[
AC_PATH_PROG(GNATMAKE, gnatmake, no)
if test x$GNATMAKE = xno ; then
AC_MSG_ERROR(I could not find gnatmake. See the file 'INSTALL' for more details.)
fi
AC_MSG_CHECKING(that your gnat compiler works with a simple example)
rm -f conftest.adb
cat << EOF > conftest.adb
with Ada.Text_IO;
procedure Conftest is
Conftest_Ok : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Create (File => Conftest_Ok,
Name => "$conftest_ok");
Ada.Text_IO.Close (Conftest_Ok);
end Conftest;
EOF
$GNATMAKE conftest > /dev/null 2>&1
if ( test ! -x conftest ) then
AC_MSG_RESULT(no)
AC_MSG_ERROR($GNATMAKE test failed at compile time! Check your configuration.)
fi
./conftest
if ( test ! -f $conftest_ok ) then
AC_MSG_RESULT(no)
AC_MSG_ERROR($GNATMAKE test failed at run time! Check your configuration.)
fi
AC_MSG_RESULT(yes)
])
##########################################################################
## Converts a list of space-separated words into a list suitable for
## inclusion in .gpr files
## $1=the list
## $2=exported name
##########################################################################
AC_DEFUN([AM_TO_GPR],
[
value=[$1]
# Special handling on darwin for gcc 4.5 and 4.7
case "$build_os" in
*darwin*)
value=`echo $value | sed -e "s/-framework \([[^ ]]*\)/-Wl,-framework -Wl,\1/g"`
esac
output=$2
result=""
for v in $value; do
if test "$result" != ""; then
result="$result, "
fi
result="$result\"$v\""
done
$2=$result
AC_SUBST($2)
])
##############################################################
# Usage: AM_HAS_GNAT_PROJECT(project)
# Check whether a given project file is available, and set
# HAVE_GNAT_PROJECT_<project> to "yes" or "no" accordingly.
# (from PolyORB ada.m4)
##############################################################
AC_DEFUN([AM_HAS_GNAT_PROJECT],
[
cat > conftest.gpr <<EOF
with "[$1]";
project Conftest is for Source_Files use (); end Conftest;
EOF
if AC_TRY_COMMAND([gprls -Pconftest.gpr system.ads > /dev/null 2>conftest.out])
then
HAVE_GNAT_PROJECT_$1=yes
else
# Try with "gnatls", in case gprls was not available
if AC_TRY_COMMAND([gnat ls -Pconftest.gpr system.ads > /dev/null 2>conftest.out])
then
HAVE_GNAT_PROJECT_$1=yes
else
HAVE_GNAT_PROJECT_$1=no
fi
fi
AC_MSG_RESULT($HAVE_GNAT_PROJECT_$1)
AC_SUBST(HAVE_GNAT_PROJECT_$1)
])
#############################################################
#
# Configure for gnatcoll build location
#
#############################################################
AC_DEFUN([AM_PATH_GNATCOLL],
[
AC_MSG_CHECKING(for gnatcoll_build)
AC_ARG_WITH(gnatcoll,
[AC_HELP_STRING(
[--with-gnatcoll_build=<path>],
[Specify the directory that contains the gnatcoll install])],
[GNATCOLL_INSTALL=$withval])
AC_MSG_RESULT(${GNATCOLL_INSTALL:-not specified})
AC_SUBST(GNATCOLL_INSTALL)
])
##########################################################################
## Detects GTK and GtkAda
## Input:
## If CONFIGURE_SWITCH_WITH_GTK is set, it specifies the default value
## for gtk. Otherwise, configure will choose the most recent version.
## This exports the following variables
## @PKG_CONFIG@: path to pkg-config, or "no" if not found
## @GTK_GCC_FLAGS@: cflags to pass to the compiler. It isn't call
## GTK_CFLAGS for compatibility reasons with
## GNAT Studio
## @WITH_GTK@: Either "yes" or "no", depending on whether gtk+ was found
## @GTK_VERSION@: one of 2.0, 3.0 or "no"
##########################################################################
AC_DEFUN([AM_PATH_GTK],
[
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "$PKG_CONFIG" = "no" ; then
WITH_GTK=no
GTK_VERSION=no
else
AC_ARG_WITH(gtk,
AC_HELP_STRING(
[--with-gtk=version],
[Specify the version of GTK to support (3.0 or 2.0)])
AC_HELP_STRING(
[--without-gtk],
[Disable support for GTK]),
[WITH_GTK=$withval],
[
AC_MSG_CHECKING(for default gtk+ version)
# Detect the version we should use, from the system
for WITH_GTK in "$CONFIGURE_SWITCH_WITH_GTK" "3.0" "2.0" "no"; do
if test "$WITH_GTK" != ""; then
GTK_PREFIX=`$PKG_CONFIG gtk+-${WITH_GTK} --variable=prefix`
if test "$GTK_PREFIX" != ""; then
break
fi
fi
done
AC_MSG_RESULT($WITH_GTK)
])
if test "$WITH_GTK" != "no"; then
AC_MSG_CHECKING(for gtk+ ${WITH_GTK})
GTK_PREFIX=`$PKG_CONFIG gtk+-${WITH_GTK} --variable=prefix`
AC_MSG_RESULT($GTK_PREFIX)
GTK_GCC_FLAGS=`$PKG_CONFIG gtk+-${WITH_GTK} --cflags`
GTK_GCC_LIBS=`$PKG_CONFIG gtk+-${WITH_GTK} --libs`
if test x"$GTK_GCC_FLAGS" != x ; then
AC_MSG_CHECKING(for gtkada.gpr)
AM_HAS_GNAT_PROJECT(gtkada)
HAVE_GTKADA=$HAVE_GNAT_PROJECT_gtkada
GTK_VERSION=$WITH_GTK
WITH_GTK=${HAVE_GTKADA}
else
GTK_VERSION=no
WITH_GTK=no
fi
fi
fi
AC_SUBST(PKG_CONFIG)
AC_SUBST(GTK_GCC_FLAGS)
AC_SUBST(GTK_GCC_FLAGS_GPR)
AC_SUBST(GTK_GCC_LIBS)
AC_SUBST(WITH_GTK)
AC_SUBST(GTK_VERSION)
])
#############################################################
#
# Configure paths for GtkAda
#
#############################################################
dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
dnl
AC_DEFUN([AM_PATH_GTKADA],
[dnl
dnl Get the cflags and libraries from the gtkada-config script
dnl
AC_MSG_CHECKING(GTK GLIB ATK PANGO prefix)
GTK="gtk+-3.0"
GLIB="glib-2.0"
PANGO="pango"
ATK="atk"
CAIRO="cairo"
if test "$PKG_CONFIG" = "no" ; then
GTK_PREFIX=unknown
AC_MSG_RESULT(not found)
else
GTK_PREFIX=`$PKG_CONFIG $GTK --variable=prefix`
GLIB_PREFIX=`$PKG_CONFIG $GLIB --variable=prefix`
ATK_PREFIX=`$PKG_CONFIG $ATK --variable=prefix`
PANGO_PREFIX=`$PKG_CONFIG $PANGO --variable=prefix`
CAIRO_PREFIX=`$PKG_CONFIG $CAIRO --variable=prefix`
AC_MSG_RESULT($GTK_PREFIX $GLIB_PREFIX $ATK_PREFIX $PANGO_PREFIX $CAIRO_PREFIX)
fi
AC_PATH_PROG(GNATDRV, gnat, no)
min_gtk_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GtkAda - version >= $min_gtk_version)
if test "$GNATDRV" = "no" || ! $GNATDRV ls -Pgtkada > /dev/null ; then
no_gtk=yes
else
# Full version number
#version=`sed -n 's/version := \"\(.*\)\";/\1/p' $GTKADA_PRJ | sed -e 's/[[^0-9.]]*$//'`
#gtk_major_version=`echo $version | cut -d. -f1`
#gtk_minor_version=`echo $version.0 | cut -d. -f2`
gtk_major_version=22
gtk_minor_version=0
dnl
dnl Now check if the installed GtkAda is sufficiently new.
dnl
rm -f conf.gtktest
AC_TRY_RUN([
#include <stdio.h>
int
main ()
{
int major, minor;
char *version = "$min_gtk_version";
system ("touch conf.gtktest");
if (sscanf(version, "%d.%d", &major, &minor) != 2) {
printf("%s, bad version string\n", "$min_gtk_version");
exit(1);
}
if (($gtk_major_version > major) ||
(($gtk_major_version == major) && ($gtk_minor_version > minor)) ||
(($gtk_major_version == major) && ($gtk_minor_version == minor)))
{
return 0;
}
else
{
printf("\n*** An old version of GtkAda (%d.%d) was found.\n",
$gtk_major_version, $gtk_minor_version);
printf("*** You need a version of GtkAda newer or equal to %d.%d. The latest version of\n",
major, minor);
printf("*** GtkAda is always available from http://libre.adacore.com\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the gtkada.gpr project is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GtkAda. You may may have to modify your LD_LIBRARY_PATH enviroment variable, \n");
printf("*** or edit /etc/ld.so.conf so that the correct libraries are found at run-time))\n");
}
return 1;
}
],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
if test "x$no_gtk" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test -f conf.gtktest ; then
:
else
echo "*** Could not run GtkAda test program"
fi
GTK_CFLAGS=""
GTKADA_SRC=""
GTKADA_OBJ=""
GTK_LIBS=""
GTK_STATIC_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GTK_PREFIX)
AC_SUBST(GLIB_PREFIX)
AC_SUBST(ATK_PREFIX)
AC_SUBST(PANGO_PREFIX)
AC_SUBST(CAIRO_PREFIX)
AC_SUBST(GTKADA_SRC)
AC_SUBST(GTKADA_OBJ)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_STATIC_LIBS)
AC_SUBST(GTKADA_PREFIX)
rm -f conf.gtktest
])
###########################################################################
## Checking for pygobject
##
###########################################################################
AC_DEFUN([AM_PATH_PYGOBJECT],
[
AC_ARG_ENABLE(pygobject,
AC_HELP_STRING(
[--disable-pygobject],
[Disable support for PyGobject [[default=enabled]]]),
[WITH_PYGOBJECT=$enableval],
[WITH_PYGOBJECT=$WITH_PYTHON])
AC_MSG_CHECKING(for pygobject)
ac_pygobject_include=`cat<<EOD | $PYTHON -
import distutils.sysconfig
import pkg_resources
import os
r = pkg_resources.Requirement.parse("pygobject")
if r is not None:
e = pkg_resources.resource_filename(r, os.path.join('include', 'pygobject-3.0'))
if e is not None:
if os.path.exists(e):
print (e)
else:
e = os.path.join(os.path.dirname(distutils.sysconfig.get_python_inc ()), "pygobject-3.0")
if os.path.exists(e):
print (e)
else:
e = os.path.join(distutils.sysconfig.get_python_inc (), "pygobject-3.0")
if os.path.exists(e):
print (e)
EOD`
if test "$ac_pygobject_include" != "" ; then
PYGOBJECT_INCLUDE="$PYTHON_CPPFLAGS -I$ac_pygobject_include"
PYGOBJECT_LIB=""
AC_MSG_RESULT(yes (pkg_resources))
WITH_PYGOBJECT=yes
PYGOBJECT_INCLUDE="$PYGOBJECT_INCLUDE -DPYGOBJECT"
elif test "$PKG_CONFIG" = "" -o "$PKG_CONFIG" = "no" ; then
AC_MSG_RESULT(no (pkg-config not found))
WITH_PYGOBJECT=no
elif test "$GTK_VERSION" = "no" ; then
AC_MSG_RESULT(no (gtk+ not found))
WITH_PYGOBJECT=no
else
for version in 3.0 2.0 ; do
module="pygobject-$version"
$PKG_CONFIG $module --exists
if test $? = 0 ; then
break;
fi
module=""
done
if test "$module" = "" ; then
AC_MSG_RESULT(no)
WITH_PYGOBJECT=no
else
PYGOBJECT_INCLUDE=`$PKG_CONFIG $module --cflags`
PYGOBJECT_LIB=`$PKG_CONFIG $module --libs`
AC_MSG_RESULT(yes ($version))
WITH_PYGOBJECT=yes
PYGOBJECT_INCLUDE="$PYGOBJECT_INCLUDE -DPYGOBJECT"
fi
fi
AC_SUBST(WITH_PYGOBJECT)
AC_SUBST(PYGOBJECT_INCLUDE)
AC_SUBST(PYGOBJECT_LIB)
])