1# This file is part of MiniDLNA.
2#
3# MiniDLNA is free software; you can redistribute it and/or modify it
4# under the terms of the GNU Lesser General Public License as
5# published by the Free Software Foundation; either version 2 of the
6# License, or (at your option) any later version.
7#
8# MiniDLNA is distributed in the hope that it will be useful, but WITHOUT
9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11# License for more details.
12#
13# You should have received a copy of the GNU Lesser General Public
14# License along with MiniDLNA; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16# USA.
17AC_INIT(MiniDLNA,1.1.3,,minidlna)
18#LT_INIT
19
20AC_CANONICAL_TARGET
21AM_INIT_AUTOMAKE([subdir-objects])
22AC_CONFIG_HEADERS([config.h])
23AM_SILENT_RULES([yes])
24
25m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_USE_SYSTEM_EXTENSIONS])
26
27#MiniDLNA
28
29AM_ICONV
30AM_GNU_GETTEXT([external])
31AM_GNU_GETTEXT_VERSION(0.18)
32
33# Checks for programs.
34AC_PROG_AWK
35AC_PROG_CC
36AM_PROG_CC_C_O
37AC_PROG_INSTALL
38AC_PROG_LN_S
39AC_PROG_MAKE_SET
40
41# Default string definitions
42AC_DEFINE_UNQUOTED([OS_URL],"http://sourceforge.net/projects/minidlna/",[OS URL])
43AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURER],"Justin Maggard", [Manufacturer])
44AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURERURL],"http://www.netgear.com/", [Manufacturer URL])
45AC_DEFINE_UNQUOTED([ROOTDEV_MODELNAME],"Windows Media Connect compatible (MiniDLNA)", [Model name])
46AC_DEFINE_UNQUOTED([ROOTDEV_MODELDESCRIPTION],"MiniDLNA on " OS_NAME, [Model description])
47AC_DEFINE_UNQUOTED([ROOTDEV_MODELURL],OS_URL,[Model URL])
48
49
50################################################################################################################
51# Checks for typedefs, structures, and compiler characteristics.
52AC_C_INLINE
53AC_TYPE_MODE_T
54AC_TYPE_OFF_T
55AC_TYPE_PID_T
56AC_TYPE_SIZE_T
57m4_ifdef([AC_TYPE_UINT8_T], [AC_TYPE_UINT8_T])
58m4_ifdef([AC_TYPE_INT32_T], [AC_TYPE_INT32_T])
59m4_ifdef([AC_TYPE_UINT32_T], [AC_TYPE_UINT32_T])
60m4_ifdef([AC_TYPE_UINT64_T], [AC_TYPE_UINT64_T])
61m4_ifdef([AC_TYPE_SSIZE_T], [AC_TYPE_SSIZE_T])
62AC_STRUCT_DIRENT_D_TYPE
63AC_STRUCT_ST_BLOCKS
64AC_HEADER_STDBOOL
65AC_C_BIGENDIAN
66
67# Checks for library functions.
68AC_FUNC_FORK
69AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
70AC_CHECK_FUNCS([gethostname getifaddrs gettimeofday inet_ntoa memmove memset mkdir realpath select sendfile setlocale socket strcasecmp strchr strdup strerror strncasecmp strpbrk strrchr strstr strtol strtoul])
71AC_CHECK_DECLS([SEEK_HOLE])
72AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [use clock_gettime])],)
73
74#
75# Check for struct ip_mreqn
76#
77AC_MSG_CHECKING(for struct ip_mreqn)
78AC_TRY_COMPILE([#include <netinet/in.h>], [
79    struct ip_mreqn mreq;
80    mreq.imr_address.s_addr = 0;
81], [
82    # Yes, we have it...
83    AC_MSG_RESULT(yes)
84    AC_DEFINE([HAVE_STRUCT_IP_MREQN],[],[Support for struct ip_mreqn])
85], [
86    # We'll just have to try and use struct ip_mreq
87    AC_MSG_RESULT(no)
88    AC_MSG_CHECKING(for struct ip_mreq)
89    AC_TRY_COMPILE([#include <netinet/in.h>], [
90        struct ip_mreq mreq;
91        mreq.imr_interface.s_addr = 0;
92    ], [
93        # Yes, we have it...
94        AC_MSG_RESULT(yes)
95        AC_DEFINE([HAVE_STRUCT_IP_MREQ],[],[Support for struct ip_mreq])
96    ], [
97        # No multicast support
98        AC_MSG_ERROR([No multicast support])
99    ])
100])
101
102################################################################################################################
103# Special include directories
104case $host in
105    *-*-darwin*)
106        DARWIN_OS=1
107        SEARCH_DIR="/opt/local"
108        INCLUDE_DIR="$SEARCH_DIR/include"
109        ;;
110    *-*-solaris*)
111        AC_DEFINE([SOLARIS], [1], [we are on solaris])
112        ;;
113    *-*-cygwin*)
114        CYGWIN_OS=1
115        ;;
116    *-*-freebsd*)
117        FREEBSD_OS=1
118        ;;
119    *-*-openbsd*)
120        OPENBSD_OS=1
121        ;;
122    *-*-linux*)
123        if test -f /etc/redhat-release; then
124            INCLUDE_DIR="/usr/include/ffmpeg"
125        fi
126        ;;
127esac
128
129AC_CHECK_HEADERS(syscall.h sys/syscall.h mach/mach_time.h)
130AC_MSG_CHECKING([for __NR_clock_gettime syscall])
131AC_COMPILE_IFELSE(
132    [AC_LANG_PROGRAM(
133        [
134            #include <asm/unistd.h>
135        ],
136        [
137            #ifndef __NR_clock_gettime
138            #error
139            #endif
140        ]
141    )],
142    [
143        AC_MSG_RESULT([yes])
144        AC_DEFINE([HAVE_CLOCK_GETTIME_SYSCALL], [1], [Whether the __NR_clock_gettime syscall is defined])
145    ],
146    [
147        AC_MSG_RESULT([no])
148    ])
149
150AC_CHECK_HEADER(linux/netlink.h,
151    [AC_DEFINE([HAVE_NETLINK],[1],[Support for Linux netlink])], [], [#include <sys/socket.h>])
152
153################################################################################################################
154### Library checks
155
156CPPFLAGS_SAVE="$CPPFLAGS"
157for dir in "" /usr/local $INCLUDE_DIR; do
158    if test -n "$dir"; then
159        CPPFLAGS="$CPPFLAGS_SAVE -I$dir"
160    fi
161    AC_CHECK_HEADERS([libavutil/avutil.h ffmpeg/libavutil/avutil.h libav/libavutil/avutil.h avutil.h ffmpeg/avutil.h libav/avutil.h], [HAVE_LIBAVUTIL=1])
162    if test -z "$HAVE_LIBAVUTIL"; then
163        unset ac_cv_header_avutil_h
164        unset ac_cv_header_libavutil_avutil_h
165        unset ac_cv_header_ffmpeg_avutil_h
166        unset ac_cv_header_ffmpeg_libavutil_avutil_h
167        unset ac_cv_header_libav_avutil_h
168        unset ac_cv_header_libav_libavutil_avutil_h
169        continue
170    fi
171    break
172done
173if test -z "$HAVE_LIBAVUTIL"; then
174    AC_MSG_ERROR([libavutil headers not found or not usable])
175fi
176
177CPPFLAGS_SAVE="$CPPFLAGS"
178for dir in "" /usr/local $INCLUDE_DIR; do
179    if test -n "$dir"; then
180        CPPFLAGS="$CPPFLAGS_SAVE -I$dir"
181    fi
182    AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/libavcodec/avcodec.h libav/libavcodec/avcodec.h avcodec.h ffmpeg/avcodec.h libav/avcodec.h], [HAVE_LIBAVCODEC=1])
183    if test -z "$HAVE_LIBAVCODEC"; then
184        unset ac_cv_header_avcodec_h
185        unset ac_cv_header_libavcodec_avcodec_h
186        unset ac_cv_header_ffmpeg_avcodec_h
187        unset ac_cv_header_ffmpeg_libavcodec_avcodec_h
188        unset ac_cv_header_libav_avcodec_h
189        unset ac_cv_header_libav_libavcodec_avcodec_h
190        continue
191    fi
192    break
193done
194if test -z "$HAVE_LIBAVCODEC"; then
195    AC_MSG_ERROR([libavcodec headers not found or not usable])
196fi
197
198CPPFLAGS_SAVE="$CPPFLAGS"
199for dir in "" /usr/local $INCLUDE_DIR; do
200    if test -n "$dir"; then
201        CPPFLAGS="$CPPFLAGS_SAVE -I$dir"
202    fi
203    AC_CHECK_HEADERS([libavformat/avformat.h ffmpeg/libavformat/avformat.h libav/libavformat/avformat.h avformat.h ffmpeg/avformat.h libav/avformat.h], [HAVE_LIBAVFORMAT=1])
204    if test -z "$HAVE_LIBAVFORMAT"; then
205        unset ac_cv_header_avformat_h
206        unset ac_cv_header_libavformat_avformat_h
207        unset ac_cv_header_ffmpeg_avformat_h
208        unset ac_cv_header_ffmpeg_libavformat_avformat_h
209        unset ac_cv_header_libav_avformat_h
210        unset ac_cv_header_libav_libavformat_avformat_h
211        continue
212    fi
213    break
214done
215if test -z "$HAVE_LIBAVFORMAT"; then
216    AC_MSG_ERROR([libavformat headers not found or not usable])
217fi
218
219CPPFLAGS_SAVE="$CPPFLAGS"
220for dir in "" /usr/local $INCLUDE_DIR; do
221    if test -n "$dir"; then
222        CPPFLAGS="$CPPFLAGS -I$dir"
223    fi
224    AC_CHECK_HEADERS([jpeglib.h sqlite3.h libexif/exif-loader.h id3tag.h ogg/ogg.h vorbis/codec.h FLAC/metadata.h],,[unset $as_ac_Header; break],)
225    if test x"$ac_cv_header_jpeglib_h" != x"yes"; then
226        CPPFLAGS="$CPPFLAGS_SAVE"
227        continue
228    elif test x"$ac_cv_header_sqlite3_h" != x"yes"; then
229        CPPFLAGS="$CPPFLAGS_SAVE"
230        continue
231    elif test x"$ac_cv_header_libexif_exif_loader_h" != x"yes"; then
232        CPPFLAGS="$CPPFLAGS_SAVE"
233        continue
234    elif test x"$ac_cv_header_id3tag_h" != x"yes"; then
235        CPPFLAGS="$CPPFLAGS_SAVE"
236        continue
237    elif test x"$ac_cv_header_ogg_ogg_h" != x"yes"; then
238        CPPFLAGS="$CPPFLAGS_SAVE"
239        continue
240    elif test x"$ac_cv_header_vorbis_codec_h" != x"yes"; then
241        CPPFLAGS="$CPPFLAGS_SAVE"
242        continue
243    elif test x"$ac_cv_header_FLAC_metadata_h" != x"yes"; then
244        CPPFLAGS="$CPPFLAGS_SAVE"
245        continue
246    else
247        break;
248    fi
249done
250test x"$ac_cv_header_jpeglib_h" != x"yes" && AC_MSG_ERROR([libjpeg headers not found or not usable])
251test x"$ac_cv_header_sqlite3_h" != x"yes" && AC_MSG_ERROR([libsqlite3 headers not found or not usable])
252test x"$ac_cv_header_libexif_exif_loader_h" != x"yes" && AC_MSG_ERROR([libexif headers not found or not usable])
253test x"$ac_cv_header_id3tag_h" != x"yes" && AC_MSG_ERROR([libid3tag headers not found or not usable])
254test x"$ac_cv_header_ogg_ogg_h" != x"yes" && AC_MSG_ERROR([libogg headers not found or not usable])
255test x"$ac_cv_header_vorbis_codec_h" != x"yes" && AC_MSG_ERROR([libvorbis headers not found or not usable])
256test x"$ac_cv_header_FLAC_metadata_h" != x"yes" && AC_MSG_ERROR([libFLAC headers not found or not usable])
257
258CFLAGS_SAVE="$CFLAGS"
259CFLAGS="$CFLAGS -Wall -Werror"
260AC_MSG_CHECKING([if we should use the daemon() libc function])
261AC_COMPILE_IFELSE(
262     [AC_LANG_PROGRAM(
263         [
264             #include <stdlib.h>
265             #include <unistd.h>
266         ],
267         [
268            return daemon(0, 0);
269         ]
270     )],
271     [
272         AC_DEFINE([USE_DAEMON], [1],
273                   [use the system's builtin daemon()])
274         AC_MSG_RESULT([yes])
275     ],
276     [
277         AC_MSG_RESULT([no])
278     ])
279
280AC_MSG_CHECKING([if scandir declaration requires const char cast])
281AC_COMPILE_IFELSE(
282     [AC_LANG_PROGRAM(
283         [
284             #include <stdlib.h>
285             #include <sys/types.h>
286             #include <dirent.h>
287         ],
288         [
289            int filter(struct dirent *d);
290            struct dirent **ptr = NULL;
291            char *name = NULL;
292            (void)scandir(name, &ptr, filter, alphasort);
293         ]
294     )],
295     [
296         AC_MSG_RESULT([no])
297     ],
298     [
299         AC_DEFINE([SCANDIR_CONST], [1],
300                   [scandir needs const char cast])
301
302         AC_MSG_RESULT([yes])
303     ])
304
305AC_MSG_CHECKING([for linux sendfile support])
306AC_COMPILE_IFELSE(
307     [AC_LANG_PROGRAM(
308         [
309             #include <sys/types.h>
310             #include <sys/sendfile.h>
311         ],
312         [
313             int tofd = 0, fromfd = 0;
314             off_t offset;
315             size_t total = 0;
316             ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
317             return nwritten;
318         ]
319     )],
320     [
321         AC_MSG_RESULT([yes])
322         AC_DEFINE([HAVE_LINUX_SENDFILE_API], [1], [Whether linux sendfile() API is available])
323     ],
324     [
325         AC_MSG_RESULT([no])
326     ])
327
328AC_MSG_CHECKING([for darwin sendfile support])
329AC_COMPILE_IFELSE(
330     [AC_LANG_PROGRAM(
331         [
332             #include <stdlib.h>
333             #include <sys/types.h>
334             #include <sys/socket.h>
335             #include <sys/uio.h>
336         ],
337         [
338             int fd = 0, s = 0;
339             off_t offset = 0, len;
340             struct sf_hdtr *hdtr = NULL;
341             int flags = 0;
342             int ret;
343             ret = sendfile(fd, s, offset, &len, hdtr, flags);
344             return ret;
345         ]
346     )],
347     [
348         AC_MSG_RESULT([yes])
349         AC_DEFINE([HAVE_DARWIN_SENDFILE_API], [1], [Whether darwin sendfile() API is available])
350     ],
351     [
352         AC_MSG_RESULT([no])
353     ])
354
355AC_MSG_CHECKING([for freebsd sendfile support])
356AC_COMPILE_IFELSE(
357     [AC_LANG_PROGRAM(
358         [
359             #include <stdlib.h>
360             #include <sys/types.h>
361             #include <sys/socket.h>
362             #include <sys/uio.h>
363         ],
364         [
365             int fromfd=0, tofd=0, ret, total=0;
366             off_t offset=0, nwritten;
367             struct sf_hdtr hdr;
368             struct iovec hdtrl;
369             hdr.headers = &hdtrl;
370             hdr.hdr_cnt = 1;
371             hdr.trailers = NULL;
372             hdr.trl_cnt = 0;
373             hdtrl.iov_base = NULL;
374             hdtrl.iov_len = 0;
375             ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
376         ]
377     )],
378     [
379         AC_MSG_RESULT([yes])
380         AC_DEFINE([HAVE_FREEBSD_SENDFILE_API], [1], [Whether freebsd sendfile() API is available])
381     ],
382     [
383         AC_MSG_RESULT([no])
384     ])
385CFLAGS="$CFLAGS_SAVE"
386
387LDFLAGS_SAVE="$LDFLAGS"
388for dir in "" /usr/local $SEARCH_DIR; do
389    if test -n "$dir"; then
390        LDFLAGS="$LDFLAGS -L$dir/lib"
391    fi
392    AC_CHECK_LIB([jpeg], [jpeg_set_defaults], [LIBJPEG_LIBS="-ljpeg"], [unset ac_cv_lib_jpeg_jpeg_set_defaults; LDFLAGS="$LDFLAGS_SAVE"; continue])
393    break
394done
395test x"$ac_cv_lib_jpeg_jpeg_set_defaults" = x"yes" || AC_MSG_ERROR([Could not find libjpeg])
396AC_SUBST(LIBJPEG_LIBS)
397
398LDFLAGS_SAVE="$LDFLAGS"
399for dir in "" /usr/local $SEARCH_DIR; do
400    if test -n "$dir"; then
401        LDFLAGS="$LDFLAGS -L$dir/lib"
402    fi
403    AC_CHECK_LIB([exif], [exif_data_new_from_file], [LIBEXIF_LIBS="-lexif"], [unset ac_cv_lib_exif_exif_data_new_from_file; LDFLAGS="$LDFLAGS_SAVE"; continue])
404    break
405done
406test x"$ac_cv_lib_jpeg_jpeg_set_defaults" = x"yes" || AC_MSG_ERROR([Could not find libexif])
407AC_SUBST(LIBEXIF_LIBS)
408
409LDFLAGS_SAVE="$LDFLAGS"
410for dir in "" /usr/local $SEARCH_DIR; do
411    if test -n "$dir"; then
412        LDFLAGS="$LDFLAGS -L$dir/lib"
413    fi
414    AC_CHECK_LIB([id3tag -lz], [id3_file_open], [LIBID3TAG_LIBS="-lid3tag -lz"], [unset ac_cv_lib_id3tag_id3_file_open; LDFLAGS="$LDFLAGS_SAVE"; continue])
415    break
416done
417test x"$ac_cv_lib_id3tag__lz___id3_file_open" = x"yes" || AC_MSG_ERROR([Could not find libid3tag])
418AC_SUBST(LIBID3TAG_LIBS)
419
420LDFLAGS_SAVE="$LDFLAGS"
421for dir in "" /usr/local $SEARCH_DIR; do
422    if test -n "$dir"; then
423        LDFLAGS="$LDFLAGS -L$dir/lib"
424    fi
425    AC_CHECK_LIB(sqlite3, sqlite3_open, [LIBSQLITE3_LIBS="-lsqlite3"], [unset ac_cv_lib_sqlite3_sqlite3_open; LDFLAGS="$LDFLAGS_SAVE"; continue])
426    AC_CHECK_LIB(sqlite3, sqlite3_malloc, [AC_DEFINE([HAVE_SQLITE3_MALLOC], [1], [Define to 1 if the sqlite3_malloc function exists.])])
427    AC_CHECK_LIB(sqlite3, sqlite3_prepare_v2, [AC_DEFINE([HAVE_SQLITE3_PREPARE_V2], [1], [Define to 1 if the sqlite3_prepare_v2 function exists.])])
428    break
429done
430test x"$ac_cv_lib_sqlite3_sqlite3_open" = x"yes" || AC_MSG_ERROR([Could not find libsqlite3])
431AC_SUBST(LIBSQLITE3_LIBS)
432
433LDFLAGS_SAVE="$LDFLAGS"
434for dir in "" /usr/local $SEARCH_DIR; do
435    if test -n "$dir"; then
436        LDFLAGS="$LDFLAGS -L$dir/lib"
437    fi
438    AC_CHECK_LIB([avformat -lavcodec -lavutil -lz], [avformat_open_input], [LIBAVFORMAT_LIBS="-lavformat -lavcodec -lavutil -lz"],
439		 [AC_CHECK_LIB([avformat -lavcodec -lavutil -lz], [av_open_input_file], [LIBAVFORMAT_LIBS="-lavformat -lavcodec -lavutil -lz"],
440		  [unset ac_cv_lib_avformat_av_open_input_file; unset ac_cv_lib_avformat_avformat_open_input; LDFLAGS="$LDFLAGS_SAVE"; continue])])
441    break
442done
443if test x"$ac_cv_lib_avformat__lavcodec__lavutil__lz___av_open_input_file" != x"yes" &&
444   test x"$ac_cv_lib_avformat__lavcodec__lavutil__lz___avformat_open_input" != x"yes"; then
445   AC_MSG_ERROR([Could not find libavformat - part of ffmpeg])
446fi
447AC_SUBST(LIBAVFORMAT_LIBS)
448
449AC_CHECK_LIB(pthread, pthread_create)
450
451# test if we have vorbisfile
452# prior versions had ov_open_callbacks in libvorbis, test that, too.
453AC_CHECK_LIB(vorbisfile, ov_open_callbacks,
454        [AC_CHECK_HEADERS([vorbis/vorbisfile.h],
455         AM_CONDITIONAL(HAVE_VORBISFILE, true)
456         AC_DEFINE(HAVE_VORBISFILE,1,[Have vorbisfile]),
457         AM_CONDITIONAL(HAVE_VORBISFILE, false))],
458         AM_CONDITIONAL(HAVE_VORBISFILE, false),
459         -lvorbis -logg)
460AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init_stream,
461        [AC_CHECK_HEADERS([FLAC/all.h],
462         AM_CONDITIONAL(HAVE_FLAC, true)
463         AC_DEFINE(HAVE_FLAC,1,[Have flac]),
464         AM_CONDITIONAL(HAVE_FLAC, false))],
465         AM_CONDITIONAL(HAVE_FLAC, false),
466        -logg)
467# test without -logg to see whether we really need it (libflac can be without)
468AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init_ogg_stream,
469         AM_CONDITIONAL(HAVE_FLAC, true)
470         AC_DEFINE(HAVE_FLAC,1,[Have flac])
471         AM_CONDITIONAL(NEED_OGG, false),
472        [AM_CONDITIONAL(NEED_OGG, true)])
473AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
474        AM_CONDITIONAL(NEED_VORBIS, false),
475        AM_CONDITIONAL(NEED_VORBIS, true),
476        -logg)
477
478AC_CHECK_LIB(avahi-client, avahi_threaded_poll_new,
479        [AC_CHECK_HEADERS([avahi-common/thread-watch.h],
480         AM_CONDITIONAL(HAVE_AVAHI, true)
481         AC_DEFINE(HAVE_AVAHI,1,[Have avahi]),
482         AM_CONDITIONAL(HAVE_AVAHI, false))],
483         AM_CONDITIONAL(HAVE_AVAHI, false),
484        -lavahi-client -lavahi-common)
485
486################################################################################################################
487### Header checks
488
489AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h libintl.h locale.h netdb.h netinet/in.h poll.h stddef.h stdlib.h string.h sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/queue.h sys/socket.h sys/time.h unistd.h])
490test x"$ac_cv_header_poll_h" != x"yes" && AC_MSG_ERROR([poll.h not found or not usable])
491test x"$ac_cv_header_sys_queue_h" != x"yes" && AC_MSG_ERROR([sys/queue.h not found or not usable])
492
493AC_CHECK_FUNCS(inotify_init,
494[
495    AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
496    AM_CONDITIONAL(HAVE_INOTIFY, true)
497],
498[
499    AC_MSG_CHECKING([for __NR_inotify_init syscall])
500    AC_COMPILE_IFELSE(
501         [AC_LANG_PROGRAM(
502             [
503                 #include <asm/unistd.h>
504             ],
505             [
506                 #ifndef __NR_inotify_init
507                 #error
508                 #endif
509             ]
510         )],
511         [
512             AC_MSG_RESULT([yes])
513             AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
514             AM_CONDITIONAL(HAVE_INOTIFY, true)
515         ],
516         [
517             AC_MSG_RESULT([no])
518             AM_CONDITIONAL(HAVE_INOTIFY, false)
519         ])
520])
521
522AC_CHECK_FUNCS(kqueue, AM_CONDITIONAL(HAVE_KQUEUE, true), AM_CONDITIONAL(HAVE_KQUEUE, false))
523
524################################################################################################################
525### Build Options
526
527AC_ARG_WITH(log-path,
528	AS_HELP_STRING([--with-log-path=PATH],[Default log path]),
529	[with_logpath="$withval"],[with_logpath="/var/log"])
530AC_DEFINE_UNQUOTED([DEFAULT_LOG_PATH],"${with_logpath}",[Log path])
531
532
533AC_ARG_WITH(db-path,
534	AS_HELP_STRING([--with-db-path=PATH],[Default DB path]),
535	[with_dbpath="$withval"],[with_dbpath="/var/cache/minidlna"])
536AC_DEFINE_UNQUOTED([DEFAULT_DB_PATH],"${with_dbpath}",[DB path])
537
538AC_ARG_WITH(os-name,
539	AS_HELP_STRING([--with-os-name=NAME],[OS Name]),
540	[with_osname="$withval"],[with_osname="$(uname -s)"])
541AC_DEFINE_UNQUOTED([OS_NAME],"${with_osname}",[OS Name])
542
543AC_ARG_WITH(os-version,
544	AS_HELP_STRING([--with-os-version=VERS],[OS Version]),
545	[with_osver="$withval"],[with_osver="$(uname -r)"])
546AC_DEFINE_UNQUOTED([OS_VERSION],"${with_osver}",[OS Version])
547
548AC_ARG_WITH(os-url,
549	AS_HELP_STRING([--with-os-url=URL],[OS URL]),
550	[with_osurl="$withval"],[with_osurl="http://www.netgear.com"])
551AC_DEFINE_UNQUOTED([OS_URL],"${with_osurl}",[OS URL])
552
553
554AC_MSG_CHECKING([whether to enable TiVo support])
555AC_ARG_ENABLE(tivo,
556	[  --enable-tivo           enable TiVo support],[
557	if test "$enableval" = "yes"; then
558		AC_DEFINE(TIVO_SUPPORT, 1, [Define to 1 if you want to enable TiVo support])
559		AM_CONDITIONAL(TIVO_SUPPORT, true)
560		AC_MSG_RESULT([yes])
561	else
562		AM_CONDITIONAL(TIVO_SUPPORT, false)
563		AC_MSG_RESULT([no])
564	fi
565	],[
566		AM_CONDITIONAL(TIVO_SUPPORT, false)
567		AC_MSG_RESULT([no])
568	]
569)
570
571AC_MSG_CHECKING([whether to enable generic NETGEAR device support])
572AC_ARG_ENABLE(netgear,
573	[  --enable-netgear        enable generic NETGEAR device support],[
574	if test "$enableval" = "yes"; then
575		AC_DEFINE([NETGEAR],[1],[Define to 1 if you want to enable generic NETGEAR device support])
576		AC_DEFINE_UNQUOTED([OS_URL],"http://www.netgear.com/")
577		AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURERURL],"http://www.netgear.com/")
578		AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURER],"NETGEAR")
579		AC_DEFINE_UNQUOTED([ROOTDEV_MODELNAME],"Windows Media Connect compatible (ReadyDLNA)")
580		AC_DEFINE_UNQUOTED([ROOTDEV_MODELDESCRIPTION],"ReadyDLNA")
581                AC_MSG_RESULT([yes])
582        else
583                AC_MSG_RESULT([no])
584        fi
585        ],[
586                AC_MSG_RESULT([no])
587        ]
588)
589
590AC_MSG_CHECKING([whether to enable NETGEAR ReadyNAS support])
591AC_ARG_ENABLE(readynas,
592	[  --enable-readynas       enable NETGEAR ReadyNAS support],[
593	if test "$enableval" = "yes"; then
594		AC_DEFINE([NETGEAR],[1],[Define to 1 if you want to enable generic NETGEAR device support])
595		AC_DEFINE([READYNAS],[1],[Define to 1 if you want to enable NETGEAR ReadyNAS support])
596		AC_DEFINE([TIVO_SUPPORT], 1, [Define to 1 if you want to enable TiVo support])
597		AC_DEFINE_UNQUOTED([OS_URL],"http://www.readynas.com/")
598		AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURERURL],"http://www.netgear.com/")
599		AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURER],"NETGEAR")
600		AC_DEFINE_UNQUOTED([ROOTDEV_MODELNAME],"Windows Media Connect compatible (ReadyDLNA)")
601		AC_DEFINE_UNQUOTED([ROOTDEV_MODELDESCRIPTION],"ReadyDLNA")
602		AM_CONDITIONAL(TIVO_SUPPORT, true)
603		AC_MSG_RESULT([yes])
604	else
605		AC_MSG_RESULT([no])
606	fi
607	],[
608		AC_MSG_RESULT([no])
609	]
610)
611
612AC_MSG_CHECKING([whether to build a static binary executable])
613AC_ARG_ENABLE(static,
614	[  --enable-static         build a static binary executable],[
615	if test "$enableval" = "yes"; then
616		CFLAGS="$CFLAGS -DSTATIC"
617		LDFLAGS="$LDFLAGS -static"
618                AC_MSG_RESULT([yes])
619        else
620                AC_MSG_RESULT([no])
621        fi
622        ],[
623                AC_MSG_RESULT([no])
624        ]
625)
626
627AC_MSG_CHECKING([whether to enable LTO])
628AC_ARG_ENABLE(lto,
629	[  --enable-lto            enable link-time optimization],[
630	if test "$enableval" = "yes"; then
631		CFLAGS="$CFLAGS -flto"
632                AC_MSG_RESULT([yes])
633        else
634                AC_MSG_RESULT([no])
635        fi
636        ],[
637                AC_MSG_RESULT([no])
638        ]
639)
640
641
642case "$target_os" in
643	darwin*)
644		;;
645        freebsd*)
646                VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
647                OS_URL=http://www.freebsd.org/
648                ;;
649	solaris*)
650		AC_DEFINE([USE_IPF], [1], [Define to enable IPF])
651		AC_DEFINE([LOG_PERROR], [0], [Define to enable logging])
652		AC_DEFINE([SOLARIS_KSTATS], [1], [Define to enable Solaris Kernel Stats])
653		;;
654	kfreebsd*)
655                OS_URL=http://www.debian.org/
656		;;
657        linux*)
658		;;
659        openbsd*)
660                OS_URL=http://www.openbsd.org/
661                ;;
662        *)
663                echo "Unknown OS : $target_os"
664                ;;
665esac
666
667
668AC_OUTPUT([ po/Makefile.in
669Makefile
670])
671