summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 3144a693b0f4fcb1937ca84dbbdb3c7519df6336 (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
AC_PREREQ(2.61)
AC_INIT([uriparser], [0.9.1], [https://github.com/uriparser/uriparser/issues],
		[uriparser], [https://uriparser.github.io/])
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_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CXX
LT_INIT
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 functions
AC_CHECK_FUNCS([wprintf])
AC_CHECK_FUNCS([reallocarray])  # needs AC_USE_SYSTEM_EXTENSIONS (#define _GNU_SOURCE)


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


## Check for Googletest
if test "${URI_TEST_YESNO}" = "yes"; then
	PKG_CHECK_MODULES([GTEST], [
		gtest >= 1.8.1
	], [], [
		AC_MSG_ERROR([Please install Googletest 1.8.1 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([config.h])
AC_OUTPUT

cat <<INFO
===========================================================================

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

Continue with
  make
  make check
  sudo make install

INFO