summaryrefslogtreecommitdiff
path: root/configure.ac
blob: a5a5ab6445111751a9f1af09ea6310f77cc1bf0b (plain)
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
AC_PREREQ(2.61)
AC_INIT([uriparser], [0.8.2])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.10.1 foreign dist-zip dist-bzip2 no-dist-gzip subdir-objects])

AC_CONFIG_MACRO_DIR([m4])

AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_HEADER_STDC


## Toggle build options specific to Windows
case "${host}" in
	*-*-mingw*) WIN32="yes" ;;
	*cygwin*) WIN32="yes" ;;
	*) WIN32="no" ;;
esac
AM_CONDITIONAL([WIN32], test "$WIN32" = "yes")


## Check for wprintf
AC_MSG_CHECKING(for wprintf)
AC_LINK_IFELSE([AC_LANG_SOURCE([
	#include <stdio.h>
	#include <wchar.h>
	int main() {
	    wprintf((wchar_t *)0, 0);
	    return 0;
	}
])],[
	AC_DEFINE([HAVE_WPRINTF],, [Define if your C runtime provides the wprintf function.])
	AC_MSG_RESULT(yes)
],[
	AC_MSG_RESULT(no)
])


## Option for URI_SIZEDOWN
AC_ARG_ENABLE(sizedown, [
==============================================================================
Extra options:
AS_HELP_STRING(
	[--enable-sizedown], [save space whereever possible])
AS_HELP_STRING(
	[], [(resulting in slower code)])], [
	URI_SIZE_DOWN_YESNO=${enableval}
	if test ${enableval} = yes ; then
		CPPFLAGS="${CPPFLAGS} -DURI_SIZEDOWN"
	fi
],[
	URI_SIZE_DOWN_YESNO=no
])


## Option --disable-test
AC_ARG_ENABLE(test, [AS_HELP_STRING(
	[--disable-test], [disable 'make check' and libcpptest dependency]
)], [
	URI_TEST_YESNO=${enableval}
],[
	URI_TEST_YESNO=yes
])
AM_CONDITIONAL([URI_TEST_ENABLED], [test "${URI_TEST_YESNO}" = "yes"])


## Check for CppTest
if test "${URI_TEST_YESNO}" = "yes"; then
	PKG_CHECK_MODULES([CPPTEST], [
		libcpptest >= 1.1.0
	], [], [
		AC_MSG_ERROR([Please install libcpptest 1.1.0 or later.
			Alternatively, you could pass --disable-test to the call to configure.
			However, it is not recommended to disable the test suite.])
	])
fi


## Local headers must come very first. Otherwise we
## risk including headers of an already installed
## uriparser version if its path is in CPPFLAGS
CPPFLAGS="-I${srcdir}/include ${CPPFLAGS}"


## Character type selection
AC_ARG_ENABLE(char, [AS_HELP_STRING(
	[--disable-char], [disable code for type char *])], [
	CHAR_YESNO=${enableval}
],[
	CHAR_YESNO=yes
])
AC_ARG_ENABLE(wchar_t, [AS_HELP_STRING(
	[--disable-wchar_t], [disable code for type wchar_t *])], [
	WCHAR_T_YESNO=${enableval}
],[
	WCHAR_T_YESNO=yes
])
if test ${CHAR_YESNO} = no -a ${WCHAR_T_YESNO} = no ; then
	AC_MSG_ERROR([Parameters --disable-char and --disable-wchar_t cannot be used together.])
elif test ${CHAR_YESNO} = no -o ${WCHAR_T_YESNO} = no ; then
	if test ${CHAR_YESNO} = no ; then
		CPPFLAGS="${CPPFLAGS} -DURI_NO_ANSI"
		troublemaker='--disable-char'
	elif test ${WCHAR_T_YESNO} = no ; then
		CPPFLAGS="${CPPFLAGS} -DURI_NO_UNICODE"
		troublemaker='--disable-wchar_t'
	fi

	if test "${URI_TEST_YESNO}" = "yes"; then
		AC_MSG_ERROR([The test suite relies on code for both char * and wchar_t *.
			Either remove ${troublemaker} or add --disable-test, please.])
	fi
fi


## API documentation
AC_ARG_ENABLE(doc, [AS_HELP_STRING(
	[--disable-doc], [disable generation of API documentation with Doxygen])
==============================================================================], [
	URI_DOC_YESNO=${enableval}
],[
	URI_DOC_YESNO=yes
])
if test ${URI_DOC_YESNO} = yes ; then
	## Doxygen
	AC_CHECK_PROG(DOXY_CHECK, doxygen, found, missing)
	if test ${DOXY_CHECK} != "found" ; then
		AC_MSG_ERROR([Please install Doxygen first.])
	fi

	## Graphviz
	AC_CHECK_PROG(GRAPHVIZ_CHECK, dot, found, missing)
	if test ${GRAPHVIZ_CHECK} != "found" ; then
		AC_MSG_ERROR([Please install Graphviz first.])
	fi

	## HTML help, Qt Compressed Help
	host_triplet=`${ac_config_guess}`
	if echo "${host_triplet}" | grep cygwin &>/dev/null ; then
		GENERATE_HTMLHELP=YES
		QHG_LOCATION=../qhelpgenerator.exe
	else
		GENERATE_HTMLHELP=NO
		QHG_LOCATION=qhelpgenerator
	fi
	AC_SUBST(GENERATE_HTMLHELP)
	AC_SUBST(QHG_LOCATION)
	AC_SUBST(ac_abs_confdir, [${ac_abs_confdir}])
fi
AM_CONDITIONAL(URI_GENERATE_DOC, test ${URI_DOC_YESNO} = yes)


AC_CONFIG_FILES([
	liburiparser.pc
	Makefile
	doc/Makefile
	doc/Doxyfile
])
AC_CONFIG_FILES([doc/release.sh], [chmod a+x doc/release.sh])
AC_CONFIG_HEADERS([test/config.h])
AC_OUTPUT

cat <<CONFIG
===========================================================================

Configuration
  Prefix ............... ${prefix}
  Size down ............ ${URI_SIZE_DOWN_YESNO}
  Code for char * ...... ${CHAR_YESNO}
  Code for wchar_t * ... ${WCHAR_T_YESNO}
  Test suite ........... ${URI_TEST_YESNO}
  Documentation ........ ${URI_DOC_YESNO}

CONFIG

cat <<"INFO"
Continue with
  make
  make check
  sudo make install

INFO