summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 0aae7661e9def1f747d75181c170ff9f6142e076 (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
# Copyright (C) 2014 Luke Shumaker <lukeshu@sbcglobal.net>

## Because of a test borrowed from flashrom's Makefile:
#
# Copyright (C) 2005 coresystems GmbH <stepan@coresystems.de>
# Copyright (C) 2009,2010,2012 Carl-Daniel Hailfinger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

## Because of a test borrowed from grub's configure.ac:
#
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
#
# This configure.ac is free software; the author
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

dnl My goal with this file is to check for all of the dependencies
dnl that aren't in 'base-devel' on Parabola, or 'build-essential' on
dnl Trisquel 7.
dnl
dnl That is, it doesn't quite check for everything, but gives the user
dnl a pretty good idea of "do I have the packages I need to build
dnl this?"
dnl
dnl Also, it sets MAINTAINER_MODE in config.mk, which decides whether
dnl to build static tools for both architectures.

AC_PREREQ([2.69])

if test -f version.txt ; then
  PACKAGE_VERSION=`cat version.txt`
else
  PACKAGE_VERSION=`git describe`
fi

AC_INIT([libreboot], ${PACKAGE_VERSION}, [info@gluglug.org.uk], [], [http://libreboot.org/])

missing=''

dnl 'sh' does not nescessarily imply 'bash'
AC_CHECK_PROG(HAVE_BASH,bash,yes)
test "x$HAVE_BASH" = xyes || missing="$missing bash"

AC_CHECK_PROG(HAVE_BSDTAR,bsdtar,yes)
test "x$HAVE_BSDTAR" = xyes || missing="$missing bsdtar"

AC_CHECK_PROG(HAVE_GIT,git,yes)
test "x$HAVE_GIT" = xyes || missing="$missing git"

AC_CHECK_PROG(HAVE_IASL,iasl,yes)
test "x$HAVE_IASL" = xyes || missing="$missing iasl"

dnl I know that /bin/python => Python 3 works,
dnl I haven't verified that /bin/python => Python 2 works.
dnl (needed for grub's build)
AC_CHECK_PROG(HAVE_PYTHON,python,yes)
test "x$HAVE_PYTHON" = xyes || missing="$missing python"

AC_CHECK_PROG(HAVE_SVN,svn,yes)
test "x$HAVE_SVN" = xyes || missing="$missing svn"

AC_CHECK_PROG(HAVE_WGET,wget,yes)
test "x$HAVE_WGET" = xyes || missing="$missing wget"

if test "x$missing" != x ; then
  AC_MSG_ERROR([The following needed programs were not found:$missing])
fi

m4_include(m4/ax_check_compile_flag.m4)
m4_include(m4/ax_check_link_flag.m4)

dnl This check is from grub's configure.ac
AC_MSG_CHECKING([for unifont])
FONT_SOURCE=
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
  for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
    if test -f "$dir/unifont.$ext"; then
      md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
      # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
      if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
        continue
      fi
      FONT_SOURCE="$dir/unifont.$ext"
      break 2
    fi
  done
done
if test "x$FONT_SOURCE" = x ; then
  AC_MSG_RESULT([no])
fi
AC_MSG_RESULT([yes])

dnl This test is based on memtest86+
AC_LANG_PUSH([C])
AX_CHECK_COMPILE_FLAG([-march=i486 -m32], [], [AC_MSG_ERROR([Cannot compile for 32-bit])], [], [AC_LANG_SOURCE
#include <stdint.h>
#include <sys/io.h>
])

MAINTAINER_MODE=y
AC_SUBST(MAINTAINER_MODE)

dnl This check is from flashrom's Makefile
AX_CHECK_LINK_FLAG([-static -m64], [],
  [
   if test "x$MAINTAINER_MODE" != x ; then
     AC_MSG_NOTICE([Cannot compile statically for 64-bit; disabling maintainer mode])
     MAINTAINER_MODE=
   fi
  ],
  [-lz -lpci],
  [AC_LANG_SOURCE
 #define index shadow_workaround_index
#if !defined __NetBSD__ && !defined __DragonFly__
#include <pci/pci.h>
#else
#include <pciutils/pci.h>
#endif
struct pci_access *pacc;
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	pacc = pci_alloc();
	return 0;
}
])

dnl This check is from flashrom's Makefile
AX_CHECK_LINK_FLAG([-static -m32], [],
  [
   if test "x$MAINTAINER_MODE" != x ; then
     AC_MSG_NOTICE([Cannot compile statically for 32-bit; disabling maintainer mode])
     MAINTAINER_MODE=
   fi
  ],
  [-lz -lpci],
  [AC_LANG_SOURCE
#define index shadow_workaround_index
#if !defined __NetBSD__ && !defined __DragonFly__
#include <pci/pci.h>
#else
#include <pciutils/pci.h>
#endif
struct pci_access *pacc;
int main(int argc, char **argv)
{
	(void) argc;
	(void) argv;
	pacc = pci_alloc();
	return 0;
}
])
AC_LANG_POP([C])

AC_CONFIG_FILES([config.mk])
AC_OUTPUT