summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 8b50427f15720575bd88659d5bf63fc3916520d3 (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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)

AC_INIT([engrampa], [1.26.0], [https://github.com/mate-desktop/engrampa/issues], [engrampa], [https://mate-desktop.org])
AM_INIT_AUTOMAKE([1.9 foreign dist-xz no-dist-gzip check-news])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])

MATE_COMMON_INIT
MATE_DEBUG_CHECK([no])
MATE_COMPILE_WARNINGS

AC_PROG_CC
AM_DISABLE_STATIC
AC_PROG_LIBTOOL
PKG_PROG_PKG_CONFIG
GLIB_GSETTINGS

AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)

dnl ==========================================================================
dnl
dnl If you add a version number here, you *must* add an AC_SUBST line for
dnl it too, or it will never make it into the spec file!
dnl
dnl ==========================================================================

GLIB_REQUIRED=2.50.0
GIO_REQUIRED=2.50.0
GTK_REQUIRED=3.22.0
CAJA_REQUIRED=1.17.1
JSON_GLIB_REQUIRED=0.14.0
SM_REQUIRED=1.0.0
ICE_REQUIRED=1.0.0

AC_SUBST(GLIB_REQUIRED)
AC_SUBST(GIO_REQUIRED)
AC_SUBST(GTK_REQUIRED)
AC_SUBST(CAJA_REQUIRED)

dnl ===========================================================================

PKG_CHECK_MODULES(LIBEGG, [glib-2.0 >= $GLIB_REQUIRED
                           gtk+-3.0 >= $GTK_REQUIRED
                           sm >= $SM_REQUIRED
                           ice >= $ICE_REQUIRED])
AC_SUBST([LIBEGG_CFLAGS])
AC_SUBST([LIBEGG_LIBS])

dnl ===========================================================================

AC_ARG_ENABLE(run_in_place,
              AS_HELP_STRING([--enable-run-in-place],
                             [load ui data and extensions from the source tree]),,
              [enable_run_in_place=no])
AM_CONDITIONAL(RUN_IN_PLACE, test "x$enable_run_in_place" != xno)

dnl ===========================================================================

PKG_CHECK_MODULES(FR,					\
	glib-2.0 >= $GLIB_REQUIRED			\
	gthread-2.0					\
	gio-unix-2.0 >= $GIO_REQUIRED			\
	gtk+-3.0 >= $GTK_REQUIRED)
AC_SUBST(FR_CFLAGS)
AC_SUBST(FR_LIBS)

dnl ******************************

AC_ARG_ENABLE([caja_actions],
	[AS_HELP_STRING([--disable-caja-actions],
			[do not build the caja context menu actions])],,
	[enable_caja_actions=yes])

if test x"$enable_caja_actions" != x"no" ; then
	PKG_CHECK_MODULES(CAJA, \
			  libcaja-extension >= $CAJA_REQUIRED \
			  glib-2.0 \
			  gio-2.0)
	AC_SUBST(CAJA_CFLAGS)
	AC_SUBST(CAJA_LIBS)

fi
AM_CONDITIONAL(ENABLE_CAJA_ACTIONS, test "x$enable_caja_actions" = xyes)

AC_ARG_WITH(cajadir,
        AS_HELP_STRING([--with-cajadir=DIR],[Installation path for Caja extension @<:@auto@:>@]),
        [ac_with_cajadir=$withval],
        [ac_with_cajadir=""])
if test "${ac_with_cajadir}" = ""; then
        ac_with_cajadir=`$PKG_CONFIG --variable=extensiondir libcaja-extension`
fi

AC_MSG_NOTICE([installing caja plugin in ${ac_with_cajadir}])
AC_SUBST([CAJA_EXTENSION_DIR],[${ac_with_cajadir}])

dnl ******************************

PKG_CHECK_MODULES(JSON_GLIB,
		  [json-glib-1.0 >= $JSON_GLIB_REQUIRED
		   glib-2.0],
		  [enable_json_glib=yes],
		  [enable_json_glib=no])

if test x$enable_json_glib = xyes ; then
	AC_DEFINE(HAVE_JSON_GLIB, 1, [Define to 1 if json-glib support is included])
fi

AC_SUBST(JSON_GLIB_CFLAGS)
AC_SUBST(JSON_GLIB_LIBS)

AM_CONDITIONAL(ENABLE_JSON_GLIB, test x"$enable_json_glib" != x"no")

dnl ******************************

AC_CHECK_LIB(m, floor)

dnl ==========================================================================

AC_ARG_ENABLE(packagekit,
	      [AS_HELP_STRING([--disable-packagekit],[build without PackageKit support])],,
	      [enable_packagekit=yes])
if test "x$enable_packagekit" != "xno"; then
	AC_DEFINE(ENABLE_PACKAGEKIT, 1, [define to enable PackageKit installer])
fi
AM_CONDITIONAL(ENABLE_PACKAGEKIT, test x"$enable_packagekit" != x"no")

dnl ******************************

GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [GetText Package])

AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.19.8])
AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8])
AM_CONDITIONAL([USE_NLS], [test "x${USE_NLS}" = "xyes"])

dnl ******************************

AC_ARG_ENABLE([magic],
              AS_HELP_STRING([--enable-magic], [use libmagic to detect file type]),,
              [enable_magic=no])

zstd_mime_type="application/zstd"
if test x"$enable_magic" = x"yes" ; then
	save_LIBS="$LIBS"
	LIBS="$LIBS -lmagic"
	AC_MSG_CHECKING([whether libmagic works])
	AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <magic.h>
int main () { magic_t m = magic_open(MAGIC_NONE); }
])],
		       [AC_MSG_RESULT([yes])],
		       [AC_MSG_RESULT([no])
		        AC_MSG_ERROR([libmagic is needed for magic])])

	dnl *******************************************
	dnl This check can be removed with file >= 5.38
	dnl *******************************************
	AC_MSG_CHECKING([for zstd mime type])
	AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
#include <string.h>
#include <magic.h>]],
		[[
    FILE *fptr;
    char *test_file = "test.zst";
    char *default_mime_type = "application/zstd";
    int status = 0;
    if ((fptr = fopen (test_file,"wb")) == NULL) {
        status = 1;
    } else {
	const unsigned char data[5] = "\x28\xb5\x2f\xfd\0";
        int i;
	for (i = 0; i < strlen (data); i++)
            fwrite (&data[i], 1, 1, fptr);
        fclose (fptr);
        magic_t magic_cookie = magic_open (MAGIC_MIME_TYPE);
        if (magic_cookie == NULL) {
            status = 1;
        } else {
            if (magic_load (magic_cookie, NULL) != 0) {
                status = 1;
            } else {
                const char *mime = magic_file (magic_cookie, test_file);
                status = (strcmp (default_mime_type, mime) == 0);
            }
            magic_close(magic_cookie);
        }
	remove (test_file);
    }
    return status;]])],
		[zstd_mime_type="application/x-zstd"],
		[zstd_mime_type="application/zstd"]
	)
	AC_MSG_RESULT($zstd_mime_type)
	dnl *******************************************

	LIBS="$save_LIBS"

	MAGIC_CFLAGS=
	MAGIC_LIBS=-lmagic

	AC_SUBST(MAGIC_CFLAGS)
	AC_SUBST(MAGIC_LIBS)

	AC_DEFINE(ENABLE_MAGIC, 1, [define to enable magic])
fi

AM_CONDITIONAL(ENABLE_MAGIC, test x"$enable_magic" != x"no")
ZSTD_MIME_TYPE="$zstd_mime_type"
AC_SUBST(ZSTD_MIME_TYPE)
AC_DEFINE_UNQUOTED(ZSTD_MIME_TYPE, "$zstd_mime_type", [define zstd mime type])

AC_ARG_VAR([CPIO], [Path to the `cpio` command])
AC_PATH_PROGS(CPIO, gcpio cpio, cpio)
AC_DEFINE_UNQUOTED(CPIO_PATH, "${CPIO}", [Path to cpio])

dnl ******************************

YELP_HELP_INIT

dnl ******************************

AC_CONFIG_FILES([Makefile
		 data/Makefile
		 data/engrampa.appdata.xml.in
		 data/engrampa.desktop.in
		 data/org.mate.engrampa.gschema.xml
		 data/icons/Makefile
		 mate-submodules/Makefile
		 mate-submodules/libegg/Makefile
		 src/Makefile
		 src/sh/Makefile
		 src/ui/Makefile
		 caja/Makefile
		 caja/libcaja-engrampa.caja-extension.desktop.in
		 help/Makefile
		 po/Makefile.in])
AC_OUTPUT

echo "
Configure summary:

	${PACKAGE_STRING}
	`echo $PACKAGE_STRING | sed "s/./=/g"`

	Source code location:      ${srcdir}
	Compiler:                  ${CC}
	Compiler flags:            ${CFLAGS}
	Warning flags:             ${WARN_CFLAGS}
	Linker flags:              ${LDFLAGS}
	Caja support:              ${enable_caja_actions}
	PackageKit support:        ${enable_packagekit}
	Run in place               ${enable_run_in_place}
	Use libmagic:              ${enable_magic}
	JSON support:              ${enable_json_glib}
	Native Language support:   ${USE_NLS}
"