summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 2851b6612fbd04b224b748a9df3f326e03ede87e (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
AC_INIT(libr.c)
AM_INIT_AUTOMAKE(libr,0.6.0)
AC_CONFIG_SRCDIR([src/libr.c])

AC_PROG_CC
AC_PROG_CC_STDC
AC_HEADER_STDC
AC_PROG_INSTALL
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.17)

# It is important to build both a static and a shared version of the libr 
# library.  The shared version is for future-proofing, whereas the static 
# version should be used to make a more portable binary until libr is
# more widely distributed (as in distributed at all).
AC_ENABLE_SHARED
AC_ENABLE_STATIC

# Setup libtool
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)

## Handle optional libraries (only header files are used)
PKG_CHECK_MODULES(LIBGLADE, libglade-2.0 >= 2.0.0)

## Handle required components
# Is this the best check for zlib that can be made?
AC_CHECK_HEADERS(zlib.h math.h pthread.h)
EXTRA_LIBS="-lz -lm -lpthread"
EXTRA_CFLAGS="-fvisibility=hidden"
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(EXTRA_LIBS)

## Handle backend configuration
LIBR_BACKEND="bfd"
BACKEND_NAME="libbfd"
AC_ARG_ENABLE(libelf, [  --enable-libelf         use the libelf backend ], [
	if   test "$enableval" = "yes" ; then
		LIBR_BACKEND="elf"
		BACKEND_NAME="libelf"
	fi
])
AC_ARG_ENABLE(libbfd, [  --enable-libbfd         use the libbfd backend (default) ], [
	if test "$enableval" == "yes" ; then
		LIBR_BACKEND="bfd"
		BACKEND_NAME="libbfd"
	fi
])
AC_ARG_ENABLE(ro, [  --enable-ro             use the read-only backend ], [
	if test "$enableval" == "yes" ; then
		LIBR_BACKEND="ro"
		BACKEND_NAME="readonly"
	fi
])
echo "Using ${BACKEND_NAME} backend."
if test "${LIBR_BACKEND}" == "bfd" ; then
	AC_CHECK_HEADER([bfd.h], [], [
		AC_MSG_ERROR([Could not find libbfd header file (bfd.h)! This file is usually included in the package binutils-dev.])
	])
	BACKEND_PKG="binutils"
	BACKEND_LIBS="-lbfd"
	BACKEND_CFLAGS=""
	AC_SUBST(BACKEND_LIBS)
	AC_SUBST(BACKEND_CFLAGS)
elif test "${LIBR_BACKEND}" == "elf" ; then
	# Is libelf 0.8.2 safe enough? testing is currently on 0.8.6
	BACKEND_PKG="elfutils"
	pkg_modules="libelf >= 0.8.2"
	PKG_CHECK_MODULES(BACKEND, [$pkg_modules])
fi
AC_SUBST(BACKEND_NAME)
AC_SUBST(LIBR_BACKEND)
AC_SUBST(BACKEND_PKG)


AC_CONFIG_HEADERS(config.h)
AC_OUTPUT(
	src/Makefile
	man/Makefile
	po/Makefile.in
	Makefile
)