~ubuntu-branches/ubuntu/trusty/libgii/trusty

« back to all changes in this revision

Viewing changes to m4/common.m4

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2006-10-17 19:36:15 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061017193615-6civk5a1i4n1kyb0
Tags: 1:1.0.1-3
Fixed "ggtick is missing". Closes: #388682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl ------ compiler.m4 ------
 
2
dnl Check CC specific characteristics
 
3
 
 
4
dnl $1 is the $CC option to check for.
 
5
dnl $2 is a boolean value (1 for true or 0 for false),
 
6
dnl    whether the option should be activated in
 
7
dnl    CFLAGS if available
 
8
dnl    Defaults to true, if not specified
 
9
 
 
10
AC_DEFUN([GGI_CC_CHECK4_OPTION],
 
11
[
 
12
 
 
13
AC_MSG_CHECKING([if $CC has -$1 option])
 
14
save_CFLAGS="$CFLAGS"
 
15
 
 
16
CFLAGS="$CFLAGS -$1"
 
17
AC_COMPILE_IFELSE([
 
18
        AC_LANG_PROGRAM([[#include <stdio.h>]],
 
19
                        [[printf("Hello World\n");]])
 
20
        ], [cc_tmp=yes],
 
21
        [cc_tmp=no])
 
22
 
 
23
activate=1
 
24
if test -n "$2"; then
 
25
        activate=$2
 
26
fi
 
27
 
 
28
if test $activate -eq 0 -o "$cc_tmp" != "yes"; then
 
29
        CFLAGS="$save_CFLAGS"
 
30
fi
 
31
 
 
32
 
 
33
AC_MSG_RESULT([$cc_tmp])
 
34
 
 
35
AS_VAR_SET(AS_TR_SH(m4_tolower([cc_has_$1])), $cc_tmp)
 
36
 
 
37
])
 
38
 
 
39
 
 
40
 
 
41
dnl Check if -Werror-implicit-function-declaration kills the build.
 
42
 
 
43
dnl AIX 4.2 is missing a prototype for (at least) snprintf.
 
44
dnl Cygwin 1.5.11 is missing a prototype for (at least) siginterrupt.
 
45
dnl HP/UX 11.11 is missing a prototype for (at least) strtoull.
 
46
dnl True64 (version?) is missing a prototype for (at least) strtoull.
 
47
 
 
48
AC_DEFUN([GGI_CHECK_IMPLICIT_DECLARATIONS],
 
49
[
 
50
 
 
51
dnl First check, if we _have_ -Werror-implicit-function-declaration
 
52
GGI_CC_CHECK4_OPTION([Werror-implicit-function-declaration], 0)
 
53
 
 
54
if test "$cc_has_werror_implicit_function_declaration" = "yes"; then
 
55
        ggi_test_funcs="strncasecmp snprintf siginterrupt strtoull"
 
56
 
 
57
        dnl Now check for some headers ...
 
58
        AC_CHECK_HEADERS([string.h strings.h signal.h])
 
59
 
 
60
        dnl ... for the declarations
 
61
        for func in $ggi_test_funcs; do
 
62
                AC_CHECK_DECLS($func,[],[],
 
63
                        [$ac_includes_default
 
64
                         #ifdef HAVE_SIGNAL_H
 
65
                         #include <signal.h>
 
66
                         #endif])
 
67
        done
 
68
 
 
69
        dnl ... and for the symbols.
 
70
        AC_CHECK_FUNCS($ggi_test_funcs)
 
71
 
 
72
        AC_MSG_CHECKING([if the system is missing declarations])
 
73
 
 
74
        for func in $ggi_test_funcs; do
 
75
                decl_var=AS_TR_SH([ac_cv_have_decl_$func])
 
76
                func_var=AS_TR_SH([ac_cv_func_$func])
 
77
 
 
78
                if eval "test \"x\${$decl_var}\" = \"xno\" -a \
 
79
                              \"x\${$func_var}\" = \"xyes\""; then
 
80
                  cc_has_werror_implicit_function_declaration="no"
 
81
                fi
 
82
        done
 
83
 
 
84
        dnl When we can use -Werror-implicit-function-declaration, then
 
85
        dnl there are no declarations missing. Thus the result output
 
86
        dnl must be inverted!
 
87
        if test $cc_has_werror_implicit_function_declaration = "yes"; then
 
88
                AC_MSG_RESULT([no])
 
89
        else
 
90
                AC_MSG_RESULT([yes])
 
91
        fi
 
92
fi
 
93
 
 
94
])
 
95
 
 
96
 
 
97
 
 
98
 
 
99
dnl ----- dllext.m4 -----
 
100
dnl Suffix detection for runtime loadable libraries.
 
101
 
 
102
AC_DEFUN([GGI_DLLEXT],
 
103
[
 
104
 
 
105
AC_MSG_CHECKING([for shared library extension])
 
106
case "${host}" in
 
107
  *-*-mingw* | *-*-cygwin*)
 
108
        DLLEXT="dll"
 
109
        ;;
 
110
  *)
 
111
        DLLEXT="so"
 
112
        ;;
 
113
esac
 
114
AC_MSG_RESULT([$DLLEXT])
 
115
 
 
116
AC_SUBST(DLLEXT)
 
117
 
 
118
])
 
119
 
 
120
 
 
121
 
 
122
 
 
123
dnl ------ extrapaths.m4 ------
 
124
dnl Let user add extra includes and libs
 
125
 
 
126
AC_DEFUN([GGI_EXTRA_PATHS],
 
127
[
 
128
 
 
129
AC_ARG_WITH([extra-includes],
 
130
[  --with-extra-includes=DIR
 
131
                          add extra include paths (separator ':')],
 
132
  use_extra_includes="$withval",
 
133
  use_extra_includes=NO
 
134
)
 
135
 
 
136
if test -n "$use_extra_includes" && \
 
137
        test "$use_extra_includes" != "NO"; then
 
138
  ac_save_ifs=$IFS
 
139
  IFS=':'
 
140
  for dir in ${use_extra_includes} ; do
 
141
    if test -d "$dir" ; then
 
142
      extra_includes="$extra_includes -I$dir"
 
143
    else
 
144
      test -f "$dir" && \
 
145
        extra_includes="$extra_includes -include $dir"
 
146
    fi
 
147
  done
 
148
  IFS=$ac_save_ifs
 
149
  CPPFLAGS="$CPPFLAGS $extra_includes"
 
150
fi
 
151
 
 
152
AC_ARG_WITH([extra-libs],
 
153
[  --with-extra-libs=DIR   add extra library paths (separator ':')],
 
154
  use_extra_libs="$withval",
 
155
  use_extra_libs=NO
 
156
)
 
157
if test -n "$use_extra_libs" && \
 
158
        test "$use_extra_libs" != "NO"; then
 
159
   ac_save_ifs=$IFS
 
160
   IFS=':'
 
161
   for dir in $use_extra_libs; do
 
162
     if test -d "$dir" ; then
 
163
       extra_libraries="$extra_libraries -L$dir"
 
164
     else
 
165
       extra_libraries="$extra_libraries -l$dir"
 
166
     fi
 
167
   done
 
168
   IFS=$ac_save_ifs
 
169
   LDFLAGS="$LDFLAGS $extra_libraries"
 
170
fi
 
171
 
 
172
AC_SUBST(extra_includes)
 
173
AC_SUBST(extra_libraries)
 
174
 
 
175
])
 
176
 
 
177
 
 
178
 
 
179
dnl ------ os.m4 ------
 
180
dnl Add your OS here, if not listed
 
181
 
 
182
AC_DEFUN([GGI_CHECKOS],
 
183
[
 
184
 
 
185
case "${host_os}" in
 
186
  cygwin*)
 
187
        os="os_win32_cygwin"
 
188
        ;;
 
189
  mingw*)
 
190
        os="os_win32_mingw"
 
191
        ;;
 
192
  pw32*)
 
193
        os="os_win32_pw32"
 
194
        ;;
 
195
  darwin* | rhapsody*)
 
196
        os="os_darwin"
 
197
        ;;
 
198
  freebsd*)
 
199
        os="os_freebsd"
 
200
        ;;
 
201
  linux*)
 
202
        os="os_linux"
 
203
        ;;
 
204
  netbsd*)
 
205
        os="os_netbsd"
 
206
        ;;
 
207
  openbsd*)
 
208
        os="os_openbsd"
 
209
        ;;
 
210
  solaris*)
 
211
        os="os_solaris"
 
212
        ;;
 
213
  aix*)
 
214
        os="os_aix"
 
215
        ;;
 
216
  *)
 
217
        os="os_default"
 
218
        ;;
 
219
esac
 
220
 
 
221
AM_CONDITIONAL(OS_WIN32, [test $os = "os_win32_cygwin" -o $os = "os_win32_mingw" -o $os = "os_win32_pw32"])
 
222
AM_CONDITIONAL(OS_WIN32_CYGWIN, test $os = "os_win32_cygwin")
 
223
AM_CONDITIONAL(OS_WIN32_MINGW, test $os = "os_win32_mingw")
 
224
AM_CONDITIONAL(OS_WIN32_PW32, test $os = "os_win32_pw32")
 
225
 
 
226
AM_CONDITIONAL(OS_DARWIN, test $os = "os_darwin")
 
227
AM_CONDITIONAL(OS_FREEBSD, test $os = "os_freebsd")
 
228
AM_CONDITIONAL(OS_LINUX, test $os = "os_linux")
 
229
AM_CONDITIONAL(OS_NETBSD, test $os = "os_netbsd")
 
230
AM_CONDITIONAL(OS_OPENBSD, test $os = "os_openbsd")
 
231
AM_CONDITIONAL(OS_SOLARIS, test $os = "os_solaris")
 
232
AM_CONDITIONAL(OS_AIX, test $os = "os_aix")
 
233
AM_CONDITIONAL(OS_DEFAULT, test $os = "os_default")
 
234
 
 
235
])
 
236
 
 
237
 
 
238
 
 
239
 
 
240
dnl ------ rellibdir.m4 -----
 
241
dnl Find a relative path that takes us from static_sysconfdir/ggi_subdir
 
242
dnl to static_libdir/ggi_subdir.
 
243
 
 
244
dnl This macro is easily fooled with //, /./ and /../ combinations.
 
245
dnl Also, I'm very far from a script guru. This macro can probably
 
246
dnl be written in a couple of lines if you know the right script
 
247
dnl knobs.
 
248
 
 
249
AC_DEFUN([GGI_SYSCONF_TO_LIB],
 
250
[
 
251
rel_ggisysconfdir="$static_sysconfdir/$ggi_subdir"
 
252
rel_ggilibdir="$static_libdir/$ggi_subdir"
 
253
again="yes"
 
254
until test "$again" = "no"; do
 
255
        again=""
 
256
        newcdir=""
 
257
        newldir=""
 
258
        as_save_IFS=$IFS
 
259
        IFS='/'
 
260
        for cdir in $rel_ggisysconfdir; do
 
261
                IFS=$as_save_IFS
 
262
                if test -n "$again"; then
 
263
                        if test -n "$newcdir"; then
 
264
                                newcdir="$newcdir/$cdir"
 
265
                        else
 
266
                                newcdir="$cdir"
 
267
                        fi
 
268
                        continue
 
269
                fi
 
270
                as_save_IFS=$IFS
 
271
                IFS='/'
 
272
                for ldir in $rel_ggilibdir; do
 
273
                        IFS=$as_save_IFS
 
274
                        if test -z "$again"; then
 
275
                                if test "$ldir" = "$cdir"; then
 
276
                                        again="yes"
 
277
                                        newldir=""
 
278
                                        newcdir=""
 
279
                                else
 
280
                                        again="no"
 
281
                                        newldir="$ldir"
 
282
                                        newcdir="$cdir"
 
283
                                fi
 
284
                                continue
 
285
                        fi
 
286
                        if test -n "$newldir"; then
 
287
                                newldir="$newldir/$ldir"
 
288
                        else
 
289
                                newldir="$ldir"
 
290
                        fi
 
291
                done
 
292
        done
 
293
        rel_ggisysconfdir="$newcdir"
 
294
        rel_ggilibdir="$newldir"
 
295
done
 
296
as_save_IFS=$IFS
 
297
IFS='/'
 
298
for cdir in $rel_ggisysconfdir; do
 
299
        rel_ggilibdir="../$rel_ggilibdir"
 
300
done
 
301
IFS=$as_save_IFS
 
302
 
 
303
ggi_sysconfdir_to_libdir="$rel_ggilibdir"
 
304
])
 
305
 
 
306
 
 
307
dnl ----- strings.m4 -----
 
308
dnl Check for safe and secure string functions
 
309
 
 
310
AC_DEFUN([GGI_CHECK_STRING_FUNCS],
 
311
[
 
312
 
 
313
dnl strings.h exists on SYSV systems
 
314
dnl and contains strcasecmp() and strncasecmp()
 
315
AC_CHECK_HEADERS(string.h strings.h)
 
316
 
 
317
AC_CHECK_FUNCS([strcasecmp strncasecmp \
 
318
        strncat strncpy snprintf vsnprintf \
 
319
        strlcpy strlcat asprintf \
 
320
        strtol strtoul strtoll strtoull])
 
321
 
 
322
])
 
323
 
 
324
 
 
325
 
 
326
dnl ----- checklib.m4 -----
 
327
dnl Check for libs using libtool
 
328
 
 
329
AC_DEFUN([GGI_CHECK_LIB],
 
330
[
 
331
   save_CC="$CC"
 
332
   CC="$SHELL ./libtool --mode=link $CC"
 
333
   AC_CHECK_LIB($1, $2, [
 
334
     CC="$save_CC"
 
335
     $3], [
 
336
     CC="$save_CC"
 
337
     $4])
 
338
])
 
339
 
 
340
dnl ----- checkint.m4 -----
 
341
dnl Add fallback if C99 inttypes are not there...
 
342
AC_DEFUN([GGI_NEED_INTTYPES],
 
343
[
 
344
if test "$ac_cv_header_inttypes_h" != "yes"; then
 
345
  AC_DEFINE(GG_NEED_INTTYPES, 1,
 
346
            [Tell libgg to define integer types when building])
 
347
fi
 
348
])