File: configure.ac

package info (click to toggle)
mpdcron 0.3%2Bgit20161228-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 1,304 kB
  • sloc: ansic: 12,825; ruby: 587; makefile: 178; sh: 95
file content (188 lines) | stat: -rw-r--r-- 6,408 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
182
183
184
185
186
187
188
dnl vim: set sw=4 sts=4 ts=4 noet ft=config foldmethod=marker foldmarker={{{,}}} :

dnl {{{ program, version
AC_PREREQ(2.59)

m4_define([mpdcron_version_major],  [0])
m4_define([mpdcron_version_minor],  [3])
m4_define([mpdcron_version_full],   [mpdcron_version_major.mpdcron_version_minor])
m4_define([mpdcron_version],        [mpdcron_version_full])

AC_INIT([mpdcron], [mpdcron_version],
		[https://github.com/alip/mpdcron/issues],
		[mpdcron], [http://alip.github.com/mpdcron/])

AC_CONFIG_SRCDIR([src/cron-main.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])

AM_INIT_AUTOMAKE([std-options foreign])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

VERSION_MAJOR=mpdcron_version_major
VERSION_MINOR=mpdcron_version_minor
VERSION_FULL=mpdcron_version_full
VERSION=mpdcron_version

AC_SUBST([VERSION_MAJOR])
AC_SUBST([VERSION_MINOR])
AC_SUBST([VERSION_FULL])

dnl {{{ git revision
AC_MSG_CHECKING([for git head])
if test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
	GITHEAD=`git describe 2>/dev/null`
	if test -z ${GITHEAD} ; then
		GITHEAD=`git rev-parse --short HEAD`
	fi
	if test -n "`git diff-index -m --name-only HEAD`" ; then
		GITHEAD=${GITHEAD}-dirty
	fi
	if test -n "${GITHEAD}" ; then
		GITHEAD="-${GITHEAD}"
	fi
fi
AC_MSG_RESULT([$GITHEAD])
AC_SUBST([GITHEAD])
dnl }}}
dnl }}}

dnl {{{ toolchain checks
AC_PROG_CC
AC_PROG_CC_C99
if test x"$ac_cv_prog_cc_c99" = x"no"; then
	AC_MSG_ERROR([mpdcron requires a C compiler that supports ISO C99!])
fi
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_PROG_SED
dnl }}}

dnl {{{ Make pkg-config work
PKG_PROG_PKG_CONFIG([0.9.0])
dnl }}}

dnl {{{ Check for libraries
GLIB_REQUIRED=2.16
GIO_REQUIRED=2.22
LIBDAEMON_REQUIRED=0.12
LIBMPDCLIENT_REQUIRED=2.2

PKG_CHECK_MODULES([glib], [glib-2.0 >= $GLIB_REQUIRED],,
				  [AC_MSG_ERROR([mpdcron requires glib-$GLIB_REQUIRED or newer])])
PKG_CHECK_MODULES([libdaemon], [libdaemon >= $LIBDAEMON_REQUIRED],,
				  [AC_MSG_ERROR([mpdcron requires libdaemon-$LIBDAEMON_REQUIRED or newer])])
PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= $LIBMPDCLIENT_REQUIRED],,
				  [AC_MSG_ERROR([mpdcron requires libmpdclient-$LIBMPDCLIENT_REQUIRED or newer])])
dnl }}}

dnl {{{ --enable-gmodule
AC_MSG_CHECKING([whether module support is wanted])
AC_ARG_ENABLE([gmodule],
			  [AS_HELP_STRING([--enable-gmodule],
							  [enable support for C modules (via GModule)])],
			  WANT_GMODULE="$enableval",
			  WANT_GMODULE="no")
AC_MSG_RESULT([$WANT_GMODULE])
AM_CONDITIONAL(HAVE_GMODULE, test x"$WANT_GMODULE" = x"yes")
if test x"$WANT_GMODULE" = x"yes"; then
	PKG_CHECK_MODULES([gmodule], [gmodule-2.0 >= $GLIB_REQUIRED],,
					  [AC_MSG_ERROR([mpdcron requires gmodule-$GLIB_REQUIRED or newer for module support])])
	AC_DEFINE([HAVE_GMODULE], 1, [Define for gmodule support])
fi
dnl }}}

dnl {{{ standard modules
ALL_STANDARD_MODULES="notification scrobbler stats"
AC_MSG_CHECKING([which standard modules are wanted])
AC_ARG_WITH([standard-modules],
			  [AS_HELP_STRING([--with-standard-modules=foo,bar,...
			   Build the specified standard modules:
			   all              Build all available standard modules
			   notification     Build the notification module
			   scrobbler        Build the scrobbler module
			   stats            Build the stats module])],
			   [standard_modules="`echo $with_standard_modules | tr ',' ' '`"],
			   [standard_modules=""])
standard_modules=`echo $standard_modules | sed -e "s,^all\$,$ALL_STANDARD_MODULES,"`
AC_MSG_RESULT([$standard_modules])
STANDARD_MODULES="$standard_modules"
AC_SUBST([STANDARD_MODULES])
WANT_NOTIFICATION=no
WANT_SCROBBLER=no
WANT_STATS=no
for m in $STANDARD_MODULES ; do
	if test x"$m" = x"notification" ; then
		if test x"$WANT_GMODULE" != x"yes"; then
			AC_MSG_WARN([GModule support is disabled, notification module will not be built])
		else
			# Notification requires notify-send
			AC_CHECK_PROGS(NOTIFY_SEND, notify-send, )
			if test x"$NOTIFY_SEND" = x; then
				AC_MSG_ERROR([notification standard module requires notify-send])
			else
				WANT_NOTIFICATION=yes
			fi
		fi
	fi
	if test x"$m" = x"scrobbler" ; then
		if test x"$WANT_GMODULE" != x"yes"; then
			AC_MSG_WARN([GModule support is disabled, scrobbler module will not be built])
		else
			# Scrobbler requires curl.
			PKG_CHECK_MODULES([libcurl], [libcurl], [WANT_SCROBBLER=yes],
							  AC_MSG_ERROR([scrobbler standard module requires curl]))
		fi
	fi
	if test x"$m" = x"stats" ; then
		if test x"$WANT_GMODULE" != x"yes"; then
			AC_MSG_WARN([GModule support is disabled, stats module will not be built])
		else
			# Stats module requires gio and sqlite3
			PKG_CHECK_MODULES([sqlite], [sqlite3], [WANT_STATS=yes],
							  AC_MSG_ERROR([stats standard module requires sqlite]))
			PKG_CHECK_MODULES([gio_unix], [gio-unix-2.0 >= $GIO_REQUIRED],
							  [HAVE_GIO_UNIX=yes],
							  [HAVE_GIO_UNIX=no])
			if test x"$HAVE_GIO_UNIX" = x"no" ; then
				PKG_CHECK_MODULES([gio], [gio-2.0 >= $GIO_REQUIRED], [WANT_STATS=yes],
								  [AC_MSG_ERROR([stats standard module requires gio-$GIO_REQUIRED or newer])])
				AC_DEFINE(HAVE_GIO_UNIX, 0, "Define for gio-unix")
			else
				AC_DEFINE(HAVE_GIO_UNIX, 1, "Define for gio-unix")
			fi
			MPDCRON_CFLAGS="$MPDCRON_CFLAGS -D_XOPEN_SOURCE=600"
			AC_CHECK_FUNCS(gmtime mktime strftime strptime getenv setenv)
		fi
	fi
done
AM_CONDITIONAL([WANT_NOTIFICATION], test x"$WANT_NOTIFICATION" = x"yes")
AM_CONDITIONAL([WANT_SCROBBLER], test x"$WANT_SCROBBLER" = x"yes")
AM_CONDITIONAL([WANT_STATS], test x"$WANT_STATS" = x"yes")
AM_CONDITIONAL([HAVE_GIO_UNIX], test x"$HAVE_GIO_UNIX" = x"yes")
dnl }}}

dnl {{{ Extra CFLAGS
WANTED_CFLAGS="-Wall -W -Wextra -Wvla -Wformat=2 -Wformat-security -Wformat-nonliteral -Winit-self -Wfloat-equal -Wno-deprecated-declarations -Wmissing-declarations -Wmissing-noreturn -Wmissing-prototypes -Wredundant-decls  -Wshadow -Wpointer-arith -Wstrict-prototypes -Wcast-qual -Wwrite-strings -pedantic"
for flag in $WANTED_CFLAGS ; do
	AX_CHECK_COMPILER_FLAGS([$flag], [MPDCRON_CFLAGS="$MPDCRON_CFLAGS $flag"],)
done
AC_SUBST([MPDCRON_CFLAGS])
dnl }}}

dnl {{{ Output
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
				 Makefile
				 src/Makefile
				 src/gmodule/Makefile
				 src/gmodule/notification/Makefile
				 src/gmodule/scrobbler/Makefile
				 src/gmodule/stats/Makefile
				 src/gmodule/stats/homescrape
				 data/Makefile
				 zsh-completion/Makefile
])
AC_OUTPUT
dnl }}}