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