Add more helpers for handling profile/service support
[platform/upstream/connman.git] / acinclude.m4
1 AC_DEFUN([AC_PROG_CC_PIE], [
2         AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
3                 echo 'void f(){}' > conftest.c
4                 if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
5                         ac_cv_prog_cc_pie=yes
6                 else
7                         ac_cv_prog_cc_pie=no
8                 fi
9                 rm -rf conftest*
10         ])
11 ])
12
13 AC_DEFUN([COMPILER_FLAGS], [
14         if (test "${CFLAGS}" = ""); then
15                 CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
16         fi
17         if (test "$USE_MAINTAINER_MODE" = "yes"); then
18                 CFLAGS+=" -Werror -Wextra"
19                 CFLAGS+=" -Wno-unused-parameter"
20                 CFLAGS+=" -Wno-missing-field-initializers"
21                 CFLAGS+=" -Wdeclaration-after-statement"
22                 CFLAGS+=" -Wmissing-declarations"
23                 CFLAGS+=" -Wredundant-decls"
24                 CFLAGS+=" -Wcast-align"
25         fi
26 ])
27
28 AC_DEFUN([SHAVE_ARG_ENABLE],
29 [
30   AC_ARG_ENABLE([shave],
31     AS_HELP_STRING(
32       [--enable-shave],
33       [use shave to make the build pretty [[default=no]]]),,
34       [enable_shave=no]
35     )
36   AC_CONFIG_FILES(shave shave-libtool)
37 ])
38
39 AC_DEFUN([SHAVE_INIT],
40 [
41   if test x"$enable_shave" = xyes; then
42     dnl where can we find the shave scripts?
43     m4_if([$1],,
44       [shavedir="$ac_pwd"],
45       [shavedir="$ac_pwd/$1"])
46     AC_SUBST(shavedir)
47
48     dnl make is now quiet
49     AC_SUBST([MAKEFLAGS], [-s])
50     AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
51
52     dnl we need sed
53     AC_CHECK_PROG(SED,sed,sed,false)
54
55     dnl substitute libtool
56     SHAVE_SAVED_LIBTOOL=$LIBTOOL
57     LIBTOOL="${SHELL} ${shavedir}/shave-libtool '${SHAVE_SAVED_LIBTOOL}'"
58     AC_SUBST(LIBTOOL)
59
60     dnl substitute cc/cxx
61     SHAVE_SAVED_CC=$CC
62     SHAVE_SAVED_CXX=$CXX
63     SHAVE_SAVED_FC=$FC
64     SHAVE_SAVED_F77=$F77
65     CC="${SHELL} ${shavedir}/shave cc ${SHAVE_SAVED_CC}"
66     CXX="${SHELL} ${shavedir}/shave cxx ${SHAVE_SAVED_CXX}"
67     FC="${SHELL} ${shavedir}/shave fc ${SHAVE_SAVED_FC}"
68     F77="${SHELL} ${shavedir}/shave f77 ${SHAVE_SAVED_F77}"
69     AC_SUBST(CC)
70     AC_SUBST(CXX)
71     AC_SUBST(FC)
72     AC_SUBST(F77)
73
74     V=@
75   else
76     V=1
77   fi
78   Q='$(V:1=)'
79   AC_SUBST(V)
80   AC_SUBST(Q)
81 ])
82
83 AC_DEFUN([GTK_DOC_CHECK],
84 [
85   AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
86   AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
87   dnl for overriding the documentation installation directory
88   AC_ARG_WITH([html-dir],
89     AS_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),,
90     [with_html_dir='${datadir}/gtk-doc/html'])
91   HTML_DIR="$with_html_dir"
92   AC_SUBST([HTML_DIR])
93
94   dnl enable/disable documentation building
95   AC_ARG_ENABLE([gtk-doc],
96     AS_HELP_STRING([--enable-gtk-doc],
97                    [use gtk-doc to build documentation [[default=no]]]),,
98     [enable_gtk_doc=no])
99
100   if test x$enable_gtk_doc = xyes; then
101     ifelse([$1],[],
102       [PKG_CHECK_EXISTS([gtk-doc],,
103                         AC_MSG_ERROR([gtk-doc not installed and --enable-gtk-doc requested]))],
104       [PKG_CHECK_EXISTS([gtk-doc >= $1],,
105                         AC_MSG_ERROR([You need to have gtk-doc >= $1 installed to build gtk-doc]))])
106   fi
107
108   AC_MSG_CHECKING([whether to build gtk-doc documentation])
109   AC_MSG_RESULT($enable_gtk_doc)
110
111   AC_PATH_PROGS(GTKDOC_CHECK,gtkdoc-check,)
112
113   AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes])
114   AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"])
115 ])