File: configure.ac

package info (click to toggle)
grap 1.41-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 832 kB
  • ctags: 601
  • sloc: cpp: 3,064; yacc: 1,063; lex: 1,046; makefile: 163; sh: 153; awk: 5
file content (181 lines) | stat: -rw-r--r-- 4,982 bytes parent folder | download
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
dnl -*-m4-*-
dnl Process this file with autoconf to produce a configure script.
AC_INIT(grap, 1.41, faber@lunabase.org)
AC_CONFIG_HEADER(config.h)
AC_LANG_CPLUSPLUS

dnl Note to self: it's possible to get separate tables out of byacc.  It
dnl is confusing because g++ optimizes away the const static tables that
dnl byacc generates, and compiling those tables aren't the problem
dnl anyway.  So don't try it again.

dnl Checks for programs.
AC_PROG_CXX

dnl Set g++ specific compiler options 
TVF_PROG_GXX_SUBST(GXXFLAGS,-Wall)
TVF_PROG_GXX_SUBST(NO_UNDEF,-Wno-unused)
TVF_PROG_GXX_SUBST(SUPPRESS_OPT,-O0)

AC_PROG_LEX
AC_PROG_YACC
AC_PROG_INSTALL
TVF_PROG_INSTALL_D
TVF_PROG_MKDEP
TVF_OS_VERSION

AC_ARG_WITH(defines-dir, 
    [  --with-defines-dir=dir  directory in which to install grap.defines],
AC_SUBST(DEFINES_DIR,$withval),
AC_SUBST(DEFINES_DIR, "$datadir/grap"))

AC_ARG_WITH(example-dir, 
    [  --with-example-dir=dir  directory in which to install examples],
AC_SUBST(EXAMPLE_DIR,$withval),
AC_SUBST(EXAMPLE_DIR, "$datadir/examples/grap"))

AC_ARG_WITH(doc-dir, 
    [  --with-doc-dir=dir      directory in which to install documents],
AC_SUBST(DOC_DIR,$withval),
AC_SUBST(DOC_DIR,"$datadir/doc/grap"))

AC_SUBST(INSTALL_DOCS)

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
if test $ac_cv_header_stdc = "no"; then
	AC_CHECK_HEADERS(stdlib.h)
fi
AC_CHECK_HEADERS(unistd.h errno.h limits)

AC_CHECK_HEADERS(unordered_map hash_map ext/hash_map, [
	AC_COMPILE_IFELSE(
		AC_LANG_PROGRAM([
#ifdef HAVE_UNORDERED_MAP
#include <unordered_map>
#endif
#ifdef HAVE_HASH_MAP
#include <hash_map>
#endif
#ifdef HAVE_EXT_HASH_MAP
#include <ext/hash_map>
#endif
],[
   std::hash<char *> h;
]),
[ AC_DEFINE(HASH_SPACE, std) break],
	AC_COMPILE_IFELSE(
		AC_LANG_PROGRAM([
#ifdef HAVE_UNORDERED_MAP
#include <unordered_map>
#endif
#ifdef HAVE_HASH_MAP
#include <hash_map>
#endif
#ifdef HAVE_EXT_HASH_MAP
#include <ext/hash_map>
#endif
],[
   __gnu_cxx::hash<char *> h;
]),
[ AC_DEFINE(HASH_SPACE, __gnu_cxx) break;],[]))]
)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T

dnl Checks for library functions.
TVF_FUNC_DECL(snprintf,stdio.h)
TVF_FUNC_DECL(strdup, stdio.h string.h,REPLACE)
TVF_FUNC_DECL(strerror, stdio.h string.h,REPLACE)

TVF_DECL_RANDOM
TVF_DECL_OPTARG

if test "$ac_cv_func_snprintf" = "no"; then
AC_CACHE_CHECK(if sprintf returns an int, grap_cv_sprintf_int,
AC_TRY_RUN([
changequote(<<, >>)dnl
#include <stdio.h>
main(int argc, char* argv) {
	char a<<[10]>>;
	if ( (char *) sprintf(a,"ten") == a ) exit(1);
	else exit(0);
}
changequote([, ])dnl
],grap_cv_sprintf_int="yes",grap_cv_sprintf_int="no",echo ""))

if test "$grap_cv_sprintf_int" = "no" ; then 
AC_DEFINE(SPRINTF_NOT_INT)
fi
fi

test "x$prefix" = xNONE && prefix="$ac_default_prefix"

# expand the data directory parameter.  Repeatedly eval the contents
# of ddir until it has no $ in it.
ddir=$datadir
while echo $ddir | grep '\$' > /dev/null ; do 
	ddir=`eval echo $ddir`
done
AC_DEFINE_UNQUOTED(DEFINES,"${ddir}/grap/grap.defines")

# expand the examples directory parameter.  Repeatedly eval the contents
# of ddir until it has no $ in it.
ddir=$EXAMPLE_DIR
while echo $ddir | grep '\$' > /dev/null ; do 
	ddir=`eval echo $ddir`
done
AC_DEFINE_UNQUOTED(EXAMPLES_DIR,"${ddir}")

# expand the data directory parameter.  Repeatedly eval the contents
# of ddir until it has no $ in it.
ddir=$DOC_DIR
while echo $ddir | grep '\$' > /dev/null ; do 
	ddir=`eval echo $ddir`
done
AC_DEFINE_UNQUOTED(DOCS_DIR,"${ddir}")



dnl if the caller has overridden the decision on suppressing
dnl optimization, use their decision, otherwise optimization has already
dnl been suppressed above
AC_MSG_CHECKING(whether to optimize grap_tokenizer)
AC_ARG_ENABLE(optimize-grap_tokenizer, 
[  --enable-optimize-grap_tokenizer   do not prevent optimization of the 
                                     grap_tokenize.cc file], 
ac_cv_grap_opt_tok="yes",
AC_CACHE_VAL(ac_cv_grap_opt_tok, ac_cv_grap_opt_tok="no"))
AC_MSG_RESULT($ac_cv_grap_opt_tok)

if test "$ac_cv_grap_opt_tok" = "yes" ; then 
	SUPPRESS_OPT=""
fi

AC_MSG_CHECKING(whether configure called from a FreeBSD port)
AC_ARG_WITH(freebsd-ports,
[  --with-freebsd-ports    configure called by a FreeBSD ports makefile],
ac_cv_grap_opt_port="yes",  
AC_CACHE_VAL(ac_cv_grap_opt_port, ac_cv_grap_opt_port="no"))
AC_MSG_RESULT($ac_cv_grap_opt_port)
if test $ac_cv_grap_opt_port = "no" ; then
	INSTALL_DEPS="all grap.defines grap.1 install-docs"
else
	INSTALL_DEPS="all grap.defines grap.1"
fi
AC_SUBST(INSTALL_DEPS)

AC_MSG_CHECKING(whether to force safer mode)
AC_ARG_WITH(safer-mode,
[  --with-safer-mode       disable sprintf to avoid attacks],
ac_cv_grap_safer_mode="yes",  
AC_CACHE_VAL(ac_cv_grap_safer_mode, ac_cv_grap_safer_mode="no"))
AC_MSG_RESULT($ac_cv_grap_safer_mode)
if test $ac_cv_grap_safer_mode = "yes" ; then
	AC_DEFINE(GRAP_SAFER)
fi

TVF_CREATE_DOT_DEPEND
AC_OUTPUT(examples/Makefile Makefile)