summaryrefslogtreecommitdiff
path: root/configure.in
blob: 8a8edfa44e73a67fd993f3e125b6cc06d83eb010 (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
AC_PREREQ(2.54)

m4_define(memfault_version_major, 0)
m4_define(memfault_version_minor, 0)
m4_define(memfault_version_micro, 1)

AC_INIT([memfault],
       	memfault_version_major.memfault_version_minor.memfault_version_micro,
	[chris@chris-wilson.co.uk])

AM_INIT_AUTOMAKE([1.9])

AC_PROG_CC
AC_PROG_CC_C_O

dnl check compiler flags
AC_DEFUN([MEMFAULT_CC_TRY_FLAG], [
  AC_MSG_CHECKING([whether $CC supports $1])

  memfault_save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $1"

  AC_COMPILE_IFELSE([ ], [memfault_cc_flag=yes], [memfault_cc_flag=no])
  CFLAGS="$memfault_save_CFLAGS"

  if test "x$memfault_cc_flag" = "xyes"; then
    ifelse([$2], , :, [$2])
  else
    ifelse([$3], , :, [$3])
  fi
  AC_MSG_RESULT([$memfault_cc_flag])
])


dnl Use lots of warning flags with with gcc and compatible compilers

dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked.  So there's no need to do anything
dnl else.  If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)

MAYBE_WARN="-Wall -Wextra \
-Wsign-compare -Werror-implicit-function-declaration \
-Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
-Wdeclaration-after-statement -Wold-style-definition \
-Wno-missing-field-initializers -Wno-unused-parameter \
-Wno-attributes -Wno-long-long -Winline"


# invalidate cached value if MAYBE_WARN has changed
if test "x$memfault_cv_warn_maybe" != "x$MAYBE_WARN"; then
	unset memfault_cv_warn_cflags
fi
AC_CACHE_CHECK([for supported warning flags], memfault_cv_warn_cflags, [
	echo
	WARN_CFLAGS=""

	# Some warning options are not supported by all versions of
	# gcc, so test all desired options against the current
	# compiler.
	#
	# Note that there are some order dependencies
	# here. Specifically, an option that disables a warning will
	# have no net effect if a later option then enables that
	# warnings, (perhaps implicitly). So we put some grouped
	# options (-Wall and -Wextra) up front and the -Wno options
	# last.

	for W in $MAYBE_WARN; do
		MEMFAULT_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
	done

	memfault_cv_warn_cflags=$WARN_CFLAGS
	memfault_cv_warn_maybe=$MAYBE_WARN

	AC_MSG_CHECKING([which warning flags were supported])])
WARN_CFLAGS="$memfault_cv_warn_cflags"
MEMFAULT_CFLAGS="$MEMFAULT_CFLAGS $WARN_CFLAGS -ggdb3 -O0"
AC_SUBST([WARN_CFLAGS MEMFAULT_CFLAGS])

PKG_CHECK_MODULES(gtk, [gtk+-2.0 >= 2.12.0 gnet-2.0 libgtop-2.0])
AC_SUBST([gtk_CFLAGS gtk_LIBS])

AC_CONFIG_FILES([
Makefile
])

AC_OUTPUT