summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: e7594c5136bc60f76f270375f67dd3657de5d91e (plain) (blame)
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
#-------------------------------------------------------------------------------
#                                                                           Init
#-------------------------------------------------------------------------------
AC_PREREQ(2.59)
AC_INIT([calcurse],
        m4_esyscmd([build-aux/git-version-gen .version]),
        [bugs@calcurse.org])
AM_INIT_AUTOMAKE
#m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.14.1])
AC_CONFIG_SRCDIR([src/calcurse.c])
AC_CONFIG_HEADER([config.h])
#-------------------------------------------------------------------------------
#                                                         Checks for system type
#-------------------------------------------------------------------------------
AC_CANONICAL_HOST
#-------------------------------------------------------------------------------
#                                                            Checks for programs
#-------------------------------------------------------------------------------
AC_PROG_CC
AC_C_BIGENDIAN
#-------------------------------------------------------------------------------
#                                                        Checks for header files
#-------------------------------------------------------------------------------
AC_HEADER_STDC
AC_CHECK_HEADERS([ctype.h getopt.h locale.h math.h signal.h stdio.h stdlib.h   \
		  string.h sys/stat.h sys/types.h sys/wait.h time.h unistd.h   \
		  fcntl.h paths.h errno.h limits.h regex.h])
#-------------------------------------------------------------------------------
#                                                         Checks for system libs
#-------------------------------------------------------------------------------
AX_WITH_CURSES
if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
  AC_MSG_ERROR(Either ncurses or ncursesw library is required to build calcurse!)
fi

LIBS="$LIBS $CURSES_LIBS"

AC_CHECK_HEADERS([pthread.h], [
    AC_CHECK_LIB(pthread, pthread_create, [
	LIBS="$LIBS -pthread"
	AC_DEFINE(HAVE_LIBPTHREAD, 1, 
		  [Define to 1 if you have the 'pthread' library (-pthread).])
    ], 
    AC_MSG_ERROR(The pthread library is required in order to build calcurse!))
], AC_MSG_ERROR(The pthread header is required in order to build calcurse!))

AC_CHECK_HEADERS([math.h], [
    AC_CHECK_LIB(m, exp, [
	LIBS="$LIBS -lm"
	AC_DEFINE(HAVE_LIBMATH, 1, 
		  [Define to 1 if you have the 'math' library (-lm).])
    ], 
    AC_MSG_ERROR(The math library is required in order to build calcurse!))
], AC_MSG_ERROR(The math header is required in order to build calcurse!))
#-------------------------------------------------------------------------------
#                                           Check whether to build documentation
#-------------------------------------------------------------------------------
AC_ARG_ENABLE(docs,
              AS_HELP_STRING([--disable-docs], [skip documentation]),
              [enabledocs=$enableval], [enabledocs=yes])
if test x"$enabledocs" != x"yes"; then
  enabledocs=no
  AC_MSG_WARN([Skipping documentation!])
fi
AC_MSG_CHECKING([whether to include documentation])
AC_MSG_RESULT($enabledocs)
AM_CONDITIONAL(ENABLE_DOCS, test x"$enabledocs" = x"yes")

AC_ARG_WITH(asciidoc,
            AS_HELP_STRING([--with-asciidoc],
                           [use AsciiDoc to regenerate documentation]),
                           [use_asciidoc=$withval],
                           [use_asciidoc="auto"])
if test x"$use_asciidoc" = x"auto"; then
  AC_PATH_PROG([ASCIIDOC], [asciidoc])
  if test -z "$ASCIIDOC"; then
    have_asciidoc=no
    AC_MSG_WARN([AsciiDoc not found - cannot rebuild documentation!])
    if test -f "doc/manual.html" && test -f "doc/submitting-patches.html"; then
      AC_MSG_WARN([Using pre-built documentation.])
    else
      AC_MSG_ERROR(Asciidoc is required to build documentation.)
    fi
  else
    have_asciidoc=yes
  fi
  AC_PATH_PROG([A2X], [a2x])
  if test -z "$A2X"; then
    have_a2x=no
    AC_MSG_WARN([a2x not found - cannot rebuild man pages!])
    if test -f "doc/calcurse.1"; then
      AC_MSG_WARN([Using pre-built man pages.])
    else
      AC_MSG_ERROR(a2x is required to build man pages.)
    fi
  else
    have_a2x=yes
  fi
elif test x"$use_asciidoc" = x"yes"; then
  AC_PATH_PROG([ASCIIDOC], [asciidoc])
  if test -z "$ASCIIDOC"; then
    AC_MSG_ERROR([AsciiDoc not found and "--with-asciidoc" specified!])
  fi
  AC_PATH_PROG([A2X], [a2x])
  if test -z "$A2X"; then
    AC_MSG_ERROR([a2x not found and "--with-asciidoc" specified!])
  fi
  have_asciidoc=yes
elif test x"$use_asciidoc" = x"no"; then
  AC_MSG_WARN([Will not rebuild documentation!])
  have_asciidoc=no
  have_a2x=no
fi
AM_CONDITIONAL(HAVE_ASCIIDOC, test $have_asciidoc = yes)
AM_CONDITIONAL(HAVE_A2X, test $have_a2x = yes)
#-------------------------------------------------------------------------------
#                                                            Compilation options
#-------------------------------------------------------------------------------
CFLAGS="$CFLAGS -Wall"

AC_ARG_ENABLE(memory_debug,
              AS_HELP_STRING([--enable-memory-debug], 
                             [use memory debug functions]),
                             memdebug=$enableval)
if test "$memdebug" != "yes"; then
   memdebug=no
   AC_DEFINE(CALCURSE_MEMORY_DEBUG_DISABLED, 1, 
             [Define to 1 if you do not want memory debug.])
else
   AC_DEFINE(CALCURSE_MEMORY_DEBUG, 1, 
             [Define to 1 if you want memory debug.])
fi
AC_MSG_CHECKING([if memory debug should be used])
AC_MSG_RESULT($memdebug)
AM_CONDITIONAL(CALCURSE_MEMORY_DEBUG, test x$memdebug = xyes)
#-------------------------------------------------------------------------------
#                                                               Create Makefiles
#-------------------------------------------------------------------------------
AC_OUTPUT(Makefile doc/Makefile src/Makefile test/Makefile \
          scripts/Makefile po/Makefile.in po/Makefile \
          contrib/caldav/Makefile contrib/vdir/Makefile)
#-------------------------------------------------------------------------------
#                                                                        Summary
#-------------------------------------------------------------------------------
echo
echo "========================================================================"
echo "$PACKAGE is configured as follows."
echo "Please check that this configuration matches your expectations."
echo "Also give a look at the config.h file to check for preprocessor symbols."
echo
echo "Host system type   : $host"
echo
echo "Options used to compile and link:"
echo "  PREFIX           = $prefix"
echo "  VERSION          = $PACKAGE_VERSION"
echo "  CC               = $CC"
echo "  CFLAGS           = $CFLAGS"
echo "  CPPFLAGS         = $CPPFLAGS"
echo "  DEFS             = $DEFS"
echo "  LD               = $LD"
echo "  LDFLAGS          = $LDFLAGS"
echo "  LIBS             = $LIBS"
echo "========================================================================"
echo