1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.59])
5
6AC_INIT(c_FileTypeModule, 1.0.0)
7AC_CONFIG_SRCDIR([FileTypeModule.cpp])
8AC_CONFIG_AUX_DIR(config)
9AM_INIT_AUTOMAKE([foreign])
10AM_PROG_LIBTOOL
11AM_MAINTAINER_MODE
12AC_CONFIG_MACRO_DIR([m4])
13
14# Checks for programs.
15AC_LANG([C++])
16AC_PROG_CXX
17AC_PROG_CC
18AC_PROG_CPP
19
20# Not all compilers include /usr/local in the include and link path
21if test -e /usr/local/include; then
22    CFLAGS="$CFLAGS -I/usr/local/include"
23    LDFLAGS="$LDFLAGS -L/usr/local/lib"
24fi
25
26# Checks for libraries.
27
28# Checks for header files.
29AC_CHECK_HEADERS([stdlib.h string.h])
30
31# Checks for typedefs, structures, and compiler characteristics.
32AC_C_INLINE
33AC_TYPE_INT32_T
34AC_TYPE_INT64_T
35AC_TYPE_SIZE_T
36AC_TYPE_SSIZE_T
37AC_TYPE_UINT32_T
38AC_TYPE_UINT64_T
39AC_TYPE_UINT8_T
40
41# Checks for library functions.
42AC_FUNC_MALLOC
43AC_FUNC_REALLOC
44AC_CHECK_FUNCS([memset strtoul strtoull])
45
46# Check for methods in library and check for header files
47AC_CHECK_HEADERS([Poco/Foundation.h Poco/Net/HTTPCookie.h Poco/DOM/Entity.h Poco/Util/Timer.h],
48  [],
49  AC_MSG_ERROR([Poco include files not found.])
50)
51
52AC_CHECK_LIB([PocoFoundation],[main],[HAVE_POCOFOUNDATION=1],AC_MSG_ERROR([PocoFoundation library not found.]))
53if test "$HAVE_POCOFOUNDATION"; then
54    save_libs="${LIBS}"
55    LIBS="-lPocoFoundation"
56    AC_LINK_IFELSE(
57        [AC_LANG_PROGRAM(
58            [#include "Poco/UnicodeConverter.h"],
59            [std::wstring wstr; Poco::UnicodeConverter::toUTF16("hello", wstr);]
60        )],
61        [LIBS="$LIBS $save_libs"],
62        [AC_MSG_ERROR([linking with PocoFoundation failed.])]
63    )
64fi
65
66AC_CHECK_LIB([PocoUtil],[main],[HAVE_POCOUTIL=1],AC_MSG_ERROR([PocoUtil library not found.]))
67if test "$HAVE_POCOUTIL"; then
68    save_libs="${LIBS}"
69    LIBS="-lPocoUtil"
70    AC_LINK_IFELSE(
71        [AC_LANG_PROGRAM(
72            [#include "Poco/Util/Option.h"],
73            [Poco::Util::Option();]
74        )],
75        [LIBS="$LIBS $save_libs"],
76        [AC_MSG_ERROR([linking with PocoUtil failed.])]
77    )
78fi
79
80AC_CHECK_LIB([PocoXML],[main],[HAVE_POCOXML=1],AC_MSG_ERROR([PocoXML library not found.]))
81if test "$HAVE_POCOXML"; then
82    save_libs="${LIBS}"
83    LIBS="-lPocoXML"
84    AC_LINK_IFELSE(
85        [AC_LANG_PROGRAM(
86            [#include "Poco/DOM/DOMParser.h"],
87            [Poco::XML::DOMParser().parse("http://www.google.com");]
88        )],
89        [LIBS="$LIBS $save_libs"],
90        [AC_MSG_ERROR([linking with PocoXML failed.])]
91    )
92fi
93
94AC_CHECK_LIB([PocoNet],[main],[HAVE_POCONET=1],AC_MSG_ERROR([PocoNet library not found.]))
95if test "$HAVE_POCONET"; then
96    save_libs="${LIBS}"
97    LIBS="-lPocoNet"
98    AC_LINK_IFELSE(
99        [AC_LANG_PROGRAM(
100            [#include "Poco/Net/HTTPClientSession.h"],
101            [Poco::Net::HTTPClientSession();]
102        )],
103        [LIBS="$LIBS $save_libs"],
104        [AC_MSG_ERROR([linking with PocoNET failed.])]
105    )
106fi
107
108AC_CHECK_LIB([PocoZip],[main],[HAVE_POCOZIP=1],AC_MSG_ERROR([PocoZip library not found.]))
109if test "$HAVE_POCOZIP"; then
110    save_libs="${LIBS}"
111    LIBS="-lPocoZip"
112    AC_LINK_IFELSE(
113        [AC_LANG_PROGRAM(
114            [#include "Poco/Zip/ZipArchive.h"],
115            [Poco::Zip::ZipArchive::FileHeaders::const_iterator fh;]
116        )],
117        [LIBS="$LIBS $save_libs"],
118        [AC_MSG_ERROR([linking with PocoZip failed.])]
119    )
120fi
121
122# Check for libmagic
123AC_CHECK_HEADERS([magic.h],
124  [AC_CHECK_LIB([magic], [magic_open],
125     [with_magic=yes],
126     [AC_MSG_WARN([Found magic headers, but could not link to libmagic library.])],
127  )],
128  [AC_MSG_WARN([Cound not find magic headers.])]
129)
130AM_CONDITIONAL([HAS_LIBMAGIC], [test "x$with_magic" = "xyes"])
131
132# If libmagic was not found, we continue on and do not error.
133# The makefile will simply not compile anything.
134# This allows us to more easily build from the top-level makefile in the framework.
135
136if test "x$with_magic" = "xyes"; then
137
138# RUNTIME_MODULES_CONFIG_DIR
139AC_SUBST(RUNTIME_MODULES_CONFIG_DIR, "../../runtime/modules_config")
140
141# MODULES_ROOT_DIR is the tsk/framework/modules directory
142# MODULES_ROOT_DIR is relative to RUNTIME_MODULES_CONFIG_DIR/<module_name>
143# so that each module can do the following to populate config files to the runtime directory.
144#   mkdir -p $(RUNTIME_MODULES_CONFIG_DIR)/<module_name>
145#   (cd $(RUNTIME_MODULES_CONFIG_DIR)/<module_name>; ln -s $(MODULES_ROOT_DIR)/c_foobarModule/foobar_config.xml .)
146AC_SUBST(MODULES_ROOT_DIR, "../../../modules")
147
148# Check if the module is under tsk/framework/modules
149if test -f ../../modules/Makefile.am; then
150   AC_SUBST(FW_LIBS, "../../tsk/framework/libtskframework.la ../../../tsk/libtsk.la")
151   AC_SUBST(TSK_INCLUDE, "-I../../..")
152   AC_SUBST(FW_INCLUDE,  "-I../..")
153else
154   # Not part of tsk/framework/modules, check if Tsk and Framework has been installed
155   AC_SUBST(FW_LIBS, "")
156   AC_SUBST(TSK_INCLUDE, "")
157   AC_SUBST(FW_INCLUDE,  "")
158   AC_CHECK_HEADERS([tsk/libtsk.h],[],AC_MSG_ERROR([Tsk include files not found.]))
159   AC_CHECK_LIB([tsk],[main],[],AC_MSG_ERROR([Tsk library not found.]))
160   AC_CHECK_HEADERS([tsk/framework/framework.h],[],AC_MSG_ERROR([Framework include files not found.]))
161   AC_CHECK_LIB([tskframework],[main],[],AC_MSG_ERROR([tskframework library not found.]))
162fi
163
164else
165# action if libmagic is not found
166AC_MSG_WARN([libmagic library not found. FileTypeSigModule will not be built.])
167echo "libmagic for FileTypeModule" > missing_libs.txt
168fi
169
170AC_CONFIG_FILES([Makefile])
171
172AC_OUTPUT
173
174