[go: up one dir, main page]

File: common.m4

package info (click to toggle)
libggigcp 1.0.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,580 kB
  • ctags: 497
  • sloc: sh: 9,172; ansic: 2,396; makefile: 176
file content (348 lines) | stat: -rw-r--r-- 7,377 bytes parent folder | download | duplicates (19)
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
dnl ------ compiler.m4 ------
dnl Check CC specific characteristics

dnl $1 is the $CC option to check for.
dnl $2 is a boolean value (1 for true or 0 for false),
dnl    whether the option should be activated in
dnl    CFLAGS if available
dnl    Defaults to true, if not specified

AC_DEFUN([GGI_CC_CHECK4_OPTION],
[

AC_MSG_CHECKING([if $CC has -$1 option])
save_CFLAGS="$CFLAGS"

CFLAGS="$CFLAGS -$1"
AC_COMPILE_IFELSE([
	AC_LANG_PROGRAM([[#include <stdio.h>]],
			[[printf("Hello World\n");]])
	], [cc_tmp=yes],
	[cc_tmp=no])

activate=1
if test -n "$2"; then
	activate=$2
fi

if test $activate -eq 0 -o "$cc_tmp" != "yes"; then
	CFLAGS="$save_CFLAGS"
fi


AC_MSG_RESULT([$cc_tmp])

AS_VAR_SET(AS_TR_SH(m4_tolower([cc_has_$1])), $cc_tmp)

])



dnl Check if -Werror-implicit-function-declaration kills the build.

dnl AIX 4.2 is missing a prototype for (at least) snprintf.
dnl Cygwin 1.5.11 is missing a prototype for (at least) siginterrupt.
dnl HP/UX 11.11 is missing a prototype for (at least) strtoull.
dnl True64 (version?) is missing a prototype for (at least) strtoull.

AC_DEFUN([GGI_CHECK_IMPLICIT_DECLARATIONS],
[

dnl First check, if we _have_ -Werror-implicit-function-declaration
GGI_CC_CHECK4_OPTION([Werror-implicit-function-declaration], 0)

if test "$cc_has_werror_implicit_function_declaration" = "yes"; then
	ggi_test_funcs="strncasecmp snprintf siginterrupt strtoull"

	dnl Now check for some headers ...
	AC_CHECK_HEADERS([string.h strings.h signal.h])

	dnl ... for the declarations
	for func in $ggi_test_funcs; do
		AC_CHECK_DECLS($func,[],[],
			[$ac_includes_default
			 #ifdef HAVE_SIGNAL_H
			 #include <signal.h>
			 #endif])
	done

	dnl ... and for the symbols.
	AC_CHECK_FUNCS($ggi_test_funcs)

	AC_MSG_CHECKING([if the system is missing declarations])

	for func in $ggi_test_funcs; do
		decl_var=AS_TR_SH([ac_cv_have_decl_$func])
		func_var=AS_TR_SH([ac_cv_func_$func])

		if eval "test \"x\${$decl_var}\" = \"xno\" -a \
			      \"x\${$func_var}\" = \"xyes\""; then
		  cc_has_werror_implicit_function_declaration="no"
		fi
	done

	dnl When we can use -Werror-implicit-function-declaration, then
	dnl there are no declarations missing. Thus the result output
	dnl must be inverted!
	if test $cc_has_werror_implicit_function_declaration = "yes"; then
		AC_MSG_RESULT([no])
	else
		AC_MSG_RESULT([yes])
	fi
fi

])




dnl ----- dllext.m4 -----
dnl Suffix detection for runtime loadable libraries.

AC_DEFUN([GGI_DLLEXT],
[

AC_MSG_CHECKING([for shared library extension])
case "${host}" in
  *-*-mingw* | *-*-cygwin*)
	DLLEXT="dll"
        ;;
  *)
	DLLEXT="so"
        ;;
esac
AC_MSG_RESULT([$DLLEXT])

AC_SUBST(DLLEXT)

])




dnl ------ extrapaths.m4 ------
dnl Let user add extra includes and libs

AC_DEFUN([GGI_EXTRA_PATHS],
[

AC_ARG_WITH([extra-includes],
[  --with-extra-includes=DIR
                          add extra include paths (separator ':')],
  use_extra_includes="$withval",
  use_extra_includes=NO
)

if test -n "$use_extra_includes" && \
        test "$use_extra_includes" != "NO"; then
  ac_save_ifs=$IFS
  IFS=':'
  for dir in ${use_extra_includes} ; do
    if test -d "$dir" ; then
      extra_includes="$extra_includes -I$dir"
    else
      test -f "$dir" && \
        extra_includes="$extra_includes -include $dir"
    fi
  done
  IFS=$ac_save_ifs
  CPPFLAGS="$CPPFLAGS $extra_includes"
fi

AC_ARG_WITH([extra-libs],
[  --with-extra-libs=DIR   add extra library paths (separator ':')],
  use_extra_libs="$withval",
  use_extra_libs=NO
)
if test -n "$use_extra_libs" && \
        test "$use_extra_libs" != "NO"; then
   ac_save_ifs=$IFS
   IFS=':'
   for dir in $use_extra_libs; do
     if test -d "$dir" ; then
       extra_libraries="$extra_libraries -L$dir"
     else
       extra_libraries="$extra_libraries -l$dir"
     fi
   done
   IFS=$ac_save_ifs
   LDFLAGS="$LDFLAGS $extra_libraries"
fi

AC_SUBST(extra_includes)
AC_SUBST(extra_libraries)

])



dnl ------ os.m4 ------
dnl Add your OS here, if not listed

AC_DEFUN([GGI_CHECKOS],
[

case "${host_os}" in
  cygwin*)
	os="os_win32_cygwin"
	;;
  mingw*)
	os="os_win32_mingw"
	;;
  pw32*)
	os="os_win32_pw32"
	;;
  darwin* | rhapsody*)
	os="os_darwin"
        ;;
  freebsd*)
	os="os_freebsd"
	;;
  linux*)
	os="os_linux"
	;;
  netbsd*)
	os="os_netbsd"
	;;
  openbsd*)
	os="os_openbsd"
	;;
  solaris*)
	os="os_solaris"
	;;
  aix*)
	os="os_aix"
	;;
  *)
	os="os_default"
        ;;
esac

AM_CONDITIONAL(OS_WIN32, [test $os = "os_win32_cygwin" -o $os = "os_win32_mingw" -o $os = "os_win32_pw32"])
AM_CONDITIONAL(OS_WIN32_CYGWIN, test $os = "os_win32_cygwin")
AM_CONDITIONAL(OS_WIN32_MINGW, test $os = "os_win32_mingw")
AM_CONDITIONAL(OS_WIN32_PW32, test $os = "os_win32_pw32")

AM_CONDITIONAL(OS_DARWIN, test $os = "os_darwin")
AM_CONDITIONAL(OS_FREEBSD, test $os = "os_freebsd")
AM_CONDITIONAL(OS_LINUX, test $os = "os_linux")
AM_CONDITIONAL(OS_NETBSD, test $os = "os_netbsd")
AM_CONDITIONAL(OS_OPENBSD, test $os = "os_openbsd")
AM_CONDITIONAL(OS_SOLARIS, test $os = "os_solaris")
AM_CONDITIONAL(OS_AIX, test $os = "os_aix")
AM_CONDITIONAL(OS_DEFAULT, test $os = "os_default")

])




dnl ------ rellibdir.m4 -----
dnl Find a relative path that takes us from static_sysconfdir/ggi_subdir
dnl to static_libdir/ggi_subdir.

dnl This macro is easily fooled with //, /./ and /../ combinations.
dnl Also, I'm very far from a script guru. This macro can probably
dnl be written in a couple of lines if you know the right script
dnl knobs.

AC_DEFUN([GGI_SYSCONF_TO_LIB],
[
rel_ggisysconfdir="$static_sysconfdir/$ggi_subdir"
rel_ggilibdir="$static_libdir/$ggi_subdir"
again="yes"
until test "$again" = "no"; do
	again=""
	newcdir=""
	newldir=""
	as_save_IFS=$IFS
	IFS='/'
	for cdir in $rel_ggisysconfdir; do
		IFS=$as_save_IFS
		if test -n "$again"; then
			if test -n "$newcdir"; then
				newcdir="$newcdir/$cdir"
			else
				newcdir="$cdir"
			fi
			continue
		fi
		as_save_IFS=$IFS
		IFS='/'
		for ldir in $rel_ggilibdir; do
			IFS=$as_save_IFS
			if test -z "$again"; then
				if test "$ldir" = "$cdir"; then
					again="yes"
					newldir=""
					newcdir=""
				else
					again="no"
					newldir="$ldir"
					newcdir="$cdir"
				fi
				continue
			fi
			if test -n "$newldir"; then
				newldir="$newldir/$ldir"
			else
				newldir="$ldir"
			fi
		done
	done
	rel_ggisysconfdir="$newcdir"
	rel_ggilibdir="$newldir"
done
as_save_IFS=$IFS
IFS='/'
for cdir in $rel_ggisysconfdir; do
	rel_ggilibdir="../$rel_ggilibdir"
done
IFS=$as_save_IFS

ggi_sysconfdir_to_libdir="$rel_ggilibdir"
])


dnl ----- strings.m4 -----
dnl Check for safe and secure string functions

AC_DEFUN([GGI_CHECK_STRING_FUNCS],
[

dnl strings.h exists on SYSV systems
dnl and contains strcasecmp() and strncasecmp()
AC_CHECK_HEADERS(string.h strings.h)

AC_CHECK_FUNCS([strcasecmp strncasecmp \
	strncat strncpy snprintf vsnprintf \
	strlcpy strlcat asprintf \
	strtol strtoul strtoll strtoull])

])



dnl ----- checklib.m4 -----
dnl Check for libs using libtool

AC_DEFUN([GGI_CHECK_LIB],
[
   save_CC="$CC"
   CC="$SHELL ./libtool --mode=link $CC"
   AC_CHECK_LIB($1, $2, [
     CC="$save_CC"
     $3], [
     CC="$save_CC"
     $4])
])

dnl ----- checkint.m4 -----
dnl Add fallback if C99 inttypes are not there...
AC_DEFUN([GGI_NEED_INTTYPES],
[
if test "$ac_cv_header_inttypes_h" != "yes"; then
  AC_DEFINE(GG_NEED_INTTYPES, 1,
	    [Tell libgg to define integer types when building])
fi
])