summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 2577a0461829ddd9aad92e79e4e880eff109e36a (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
AC_INIT([mfi_agent], [1.0], [mike@crute.us])
AC_PREREQ([2.60])

AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AM_SILENT_RULES([yes])

AC_PROG_CC
AC_LANG_WERROR
AC_PROG_CC_C99
PKG_PROG_PKG_CONFIG
AC_CHECK_HEADER_STDBOOL

AC_SEARCH_LIBS(
    [ev_run],
    [ev],
    [found_libev=yes],
    [found_libev=no]
)
AC_CHECK_HEADER(
    [ev.h],
    ,
    found_libev=no
)
if test "x$found_libev" = xno; then
    AC_MSG_ERROR("libev not found")
fi

PKG_CHECK_MODULES(
	JSON_C,
	json-c,
	[found_json_c=yes],
	[found_json_c=no]
)
if test "x$found_json_c" = xno; then
	AC_MSG_ERROR("libjson-c not found")
fi

PKG_CHECK_MODULES(
	WEBSOCKETS,
	libwebsockets,
	[found_libwebsockets=yes],
	[found_libwebsockets=no]
)
if test "x$found_libwebsockets" = xno; then
	AC_MSG_ERROR("libwebsockets not found")
fi

AC_ARG_ENABLE(
    debug,
    AC_HELP_STRING([--enable-debug], [create a debug build])
)
AS_IF([test "x$enable_debug" = xyes], [
    AM_CFLAGS="-g -DDEBUG $AM_CFLAGS"
    AM_CFLAGS="$AM_CFLAGS -Wno-long-long -Wall -W -Wformat=2"
    AM_CFLAGS="$AM_CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
    AM_CFLAGS="$AM_CFLAGS -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare"
    AM_CFLAGS="$AM_CFLAGS -Wundef -Wbad-function-cast -Winline -Wcast-align"
    AM_CFLAGS="$AM_CFLAGS -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes"
    AM_CFLAGS="$AM_CFLAGS -Wno-unused-result"
])

AC_ARG_ENABLE(
    [production],
    AC_HELP_STRING([--enable-production], [produce a production-ready build])
)
AS_IF([test "x$enable_production" = xyes], [
    AM_CFLAGS="-s -Os $AM_CFLAGS"
])

if test "x$enable_debug" = xyes && test "x$enable_production" = xyes; then
    AC_MSG_ERROR([Production and Debug are mutually exclusive options])
fi

# Always build static binaries to make it easier to deploy
AM_LDFLAGS="-static $AM_LDFLAGS"

AM_CFLAGS="-Wall -Werror $AM_CFLAGS"

AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_LDFLAGS)

AC_CONFIG_FILES([Makefile])

AC_OUTPUT