1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.61)
5AC_INIT([Osmo], [0.4.4], [pasp@users.sf.net])
6AC_CONFIG_MACRO_DIR([m4])
7AM_INIT_AUTOMAKE([-Wall foreign])
8AC_CONFIG_SRCDIR([src/contacts.c])
9AC_CONFIG_HEADER([config.h])
10AC_MSG_CHECKING(for type of build)
11PKG_PROG_PKG_CONFIG
12
13# Checks for enabled modules
14
15AC_ARG_WITH(contacts,
16    [[  --without-contacts      disable Contacts module]],
17    [if test "x$withval" = "xyes" ; then contacts="yes" ; else contacts="no"; fi],
18    contacts="yes")
19
20AC_ARG_WITH(tasks,
21    [[  --without-tasks         disable Tasks module]],
22    [if test "x$withval" = "xyes" ; then tasks="yes" ; else tasks="no"; fi],
23    tasks="yes")
24
25AC_ARG_WITH(notes,
26    [[  --without-notes         disable Notes module]],
27    [if test "x$withval" = "xyes" ; then notes="yes" ; else notes="no"; fi],
28    notes="yes")
29if test "x$notes" = "xyes"; then
30    AC_DEFINE([NOTES_ENABLED], [1], [Notes module enabled])
31fi
32
33# Checks for programs.
34SAVEDFLAGS=${CFLAGS}
35AC_PROG_CC
36CFLAGS=${SAVEDFLAGS}
37
38# Checks for header files.
39AC_HEADER_STDC
40AC_CHECK_HEADERS([libintl.h locale.h fcntl.h stdlib.h string.h sys/time.h unistd.h])
41
42# Checks for typedefs, structures, and compiler characteristics.
43AC_C_CONST
44AC_STRUCT_TM
45AC_TYPE_SIZE_T
46AC_SYS_LARGEFILE
47
48# Checks for library functions.
49AC_FUNC_STAT
50AC_FUNC_STRFTIME
51AC_CHECK_FUNCS([floor memset setlocale strncasecmp strstr strtol])
52
53# Checks for msgfmt
54AC_PATH_PROG(MSGFMT, msgfmt, msgfmt)
55
56# Checks for libraries.
57AM_PATH_GTK_3_0(3.10.0,,
58    AC_MSG_ERROR([GTK+ not found or too old (version < 3.10)]))
59
60AM_PATH_XML2(2.0.0,,
61    AC_MSG_ERROR([You do not appear to have libxml2 installed.]))
62
63PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.6.0)
64
65# Checks for libgringotts
66AC_CHECK_LIB(gringotts, grg_context_initialize_defaults, [lib=yes], [lib=no])
67libgringotts="no"
68if test "$lib" = "yes"; then
69    libgringotts="yes"
70fi
71if test "x$lib" = "xyes"; then
72    gringotts_LIBS="-lgringotts"
73    AC_DEFINE([HAVE_LIBGRINGOTTS], [1], [Defined to 1 if compile with libgringotts support])
74fi
75
76# Checks for libarchive
77PKG_CHECK_MODULES(LIBARCHIVE, libarchive >= 3.0.0, have_libarchive=true,
78    have_libarchive=false)
79if test "x$have_libarchive" = "xtrue"; then
80    libarchive="yes"
81    libarchive_LIBS="-larchive"
82    AC_DEFINE([HAVE_LIBARCHIVE], [1], [Defined to 1 if compile with libarchive support])
83else
84    libarchive="no"
85fi
86AM_CONDITIONAL([HAVE_LIBARCHIVE], test "x$have_libarchive" = "xtrue")
87
88# Checks for libical
89PKG_CHECK_MODULES(LIBICAL, libical >= 1.0, have_libical=true,
90    have_libical=false)
91if test "x$have_libical" = "xtrue"; then
92    AC_DEFINE([HAVE_LIBICAL], [1], [Definded to 1 if compile with libical support])
93    libical="yes"
94else
95    libical="no"
96fi
97AM_CONDITIONAL([HAVE_LIBICAL], test "x$have_libical" = "xtrue")
98
99# Checks for gspell
100PKG_CHECK_MODULES(GSPELL, gspell-1 >= 1.2.0, have_gspell=true,
101    have_gspell=false)
102if test "x$have_gspell" = "xtrue"; then
103    AC_DEFINE([HAVE_GSPELL], [1], [Definded to 1 if compile with gspell support])
104    gspell="yes"
105else
106    gspell="no"
107fi
108AM_CONDITIONAL([HAVE_GSPELL], test "x$have_gspell" = "xtrue")
109
110# Checks for libnotify
111PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.7.0, have_libnotify7=true,
112    have_libnotify7=false)
113if test "x$have_libnotify7" = "xtrue"; then
114    AC_DEFINE([HAVE_LIBNOTIFY], [1], [Definded to 1 if compile with libnotify support])
115    AC_DEFINE([HAVE_LIBNOTIFY7], [1], [Definded to 1 if compile with libnotify >= 0.7.0 support])
116    libnotify="yes"
117else
118    PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4.4, have_libnotify=true,
119        have_libnotify=false)
120    if test "x$have_libnotify" = "xtrue"; then
121        AC_DEFINE([HAVE_LIBNOTIFY], [1], [Definded to 1 if compile with libnotify support])
122        libnotify="yes"
123    else
124        libnotify="no"
125    fi
126fi
127AM_CONDITIONAL([TASKS_ENABLED], test "x$tasks" = "xyes")
128AM_CONDITIONAL([HAVE_LIBNOTIFY], test "x$have_libnotify" = "xtrue")
129
130if test "x$tasks" = "xyes"; then
131    AC_DEFINE([TASKS_ENABLED], [1], [Tasks module enabled])
132fi
133
134# Checks for libwebkit
135PKG_CHECK_MODULES(LIBWEBKIT, webkit2gtk-4.0 >= 2.8.0, have_libwebkit=true,
136    have_libwebkit=false)
137if test "x$have_libwebkit" = "xtrue"; then
138    libwebkit="yes"
139else
140    libwebkit="no"
141fi
142
143contacts="yes";
144htmlrender="no";
145if test "x$have_libwebkit" = "xfalse"; then
146        contacts="no";
147else
148    htmlrender="webkit";
149    contacts="yes";
150    AC_DEFINE([HAVE_LIBWEBKIT], [1], [Definded to 1 if compile with libwebkit support])
151    AC_DEFINE([HTMLRENDER], ["webkit"], [HTML render type])
152fi
153
154AM_CONDITIONAL([HAVE_LIBWEBKIT], test "x$libwebkit" = "xyes")
155
156if test "x$contacts" = "xyes"; then
157    AC_DEFINE([CONTACTS_ENABLED], [1], [Contacts module enabled])
158fi
159
160# Checks for Pango 1.20
161PKG_CHECK_MODULES(PANGO_1_20, pango >= 1.20, [HAVE_PANGO_1_20=yes], [HAVE_PANGO_1_20=no])
162if test "x$HAVE_PANGO_1_20" = xyes; then
163    AC_DEFINE(HAVE_PANGO_1_20, 1, [Define to 1 if you have Pango-1.20])
164fi
165
166# Checks for additional options
167
168AC_ARG_ENABLE(
169    reproducible,
170    [  --enable-reproducible=yes,no    make the build reproducible (default: no)],
171    reproducible="$enableval",
172    reproducible="no")
173if test "x$reproducible" = "xyes"; then
174    AC_DEFINE([REPRODUCIBLE_BUILD], [1], [Defined if doing a reproducible build])
175fi
176
177AC_ARG_ENABLE(
178    debug,
179    [  --enable-debug=yes,no   compile with debugging support (default: no)],
180    debug="$enableval",
181    debug="no")
182if test "x$debug" = "xyes"; then
183    BUILD_CFLAGS="-rdynamic -ggdb -g -O0"
184    AC_DEFINE([DEBUG_BUILD], [1], [Defined if doing a debug build])
185fi
186
187AC_ARG_ENABLE(
188    printing,
189    [  --enable-printing=yes,no   compile with printing support (default: yes)],
190    printing="$enableval",
191    printing="yes")
192if test "x$printing" = "xyes"; then
193    AC_DEFINE([PRINTING_SUPPORT], [1], [Defined if printing support is enabled])
194fi
195
196AC_ARG_ENABLE(
197    backup,
198    [  --enable-backup=yes,no   compile with backup support (default: yes)],
199    backup="$enableval",
200    backup="yes")
201if test "x$backup" = "xyes"; then
202    if test "x$libarchive" = "xyes"; then
203        if test "x$libgringotts" = "xyes"; then
204            AC_DEFINE([BACKUP_SUPPORT], [1], [Defined if backup support is enabled])
205        else
206            backup="no"
207        fi
208    else
209        backup="no"
210    fi
211fi
212
213AC_ARG_WITH([config-path],
214            AS_HELP_STRING([--with-config-path=PATH], [use a non-default config path. Deprecated, used for the configuration migration only]),
215            [configpath=$withval AC_SUBST([configpath])])
216AM_CONDITIONAL([CONFIGPATH], [test x$configpath != x])
217AC_ARG_WITH([config-dir],
218            AS_HELP_STRING([--with-config-dir=DIR], [use a non-default config directory. Deprecated, used for the configuration migration only]),
219            [configdir=$withval AC_SUBST([configdir])])
220AM_CONDITIONAL([CONFIGDIR], [test x$configdir != x])
221
222CFLAGS=${CFLAGS:="$BUILD_CFLAGS -Wall $PLATFORM_CFLAGS -D_GNU_SOURCE"}
223CXXFLAGS=${CXXFLAGS:="$CFLAGS"}
224CPPFLAGS=""
225LIBS="$gringotts_LIBS $libarchive_LIBS"
226
227AC_CONFIG_FILES([
228    Makefile
229    src/Makefile
230    po/Makefile
231    data/Makefile
232    data/icons/Makefile
233    data/icons/16x16/Makefile
234    data/icons/22x22/Makefile
235    data/icons/24x24/Makefile
236    data/icons/32x32/Makefile
237    data/icons/48x48/Makefile
238    data/icons/scalable/Makefile
239    data/pixmaps/Makefile
240    data/sounds/Makefile
241])
242AC_OUTPUT
243
244# WIN32 build
245AM_CONDITIONAL([WIN32], test "$WIN32" = "yes")
246
247echo "
248Configuration:
249
250    Prefix:             $prefix
251    Debug enabled:      $debug
252    Reproducible build: $reproducible
253
254    Backup support:     $backup (libgringotts and libarchive are required)
255    Printing support:   $printing
256    HTML renderer:      $htmlrender
257
258Enabled modules:
259
260    Calendar:           yes (always)
261    Tasks:              $tasks
262    Contacts:           $contacts (HTML renderer is required)
263    Notes:              $notes
264
265Optional features:
266
267    gspell:             $gspell
268    libical:            $libical
269    libnotify:          $libnotify
270    libarchive:         $libarchive
271    libgringotts:       $libgringotts
272"
273