summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 8474f7dca21e714f93665497b118c519c1feb26f (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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
dnl 
dnl configure.ac for kexec-tools
dnl 
dnl 

dnl ---Required
AC_INIT(kexec-tools, 2.0.20.git)
AC_CONFIG_AUX_DIR(./config)
AC_CONFIG_HEADERS([include/config.h])
AC_LANG(C)
AC_PROG_CC


dnl -- Compilation platform configuration
dnl -- the host specifices the host machine for the kexec binary, the
dnl -- the target specifies the architecture of the kernel to be kexeced.
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

dnl Compute ARCH from target cpu info
case $target_cpu in
	i?86 )
		ARCH="i386"
		;;
	powerpc )
		ARCH="ppc"
		SUBARCH="BE"
		;;
	powerpc64 )
		ARCH="ppc64"
		SUBARCH="BE"
		;;
	powerpc64le )
		ARCH="ppc64"
		SUBARCH="LE"
		;;
	aarch64* )
		ARCH="arm64"
		;;
	arm* )
		ARCH="arm"
		;;
	s390x|s390 )
		ARCH="s390"
		;;
	sh4|sh4a|sh3|sh )
		ARCH="sh"
		;;
	mips* )
		ARCH="mips"
		;;
	cris|crisv32 )
		ARCH="cris"
		;;
	ia64|x86_64|alpha|m68k )
		ARCH="$target_cpu"
		;;
	* )
		AC_MSG_ERROR([unsupported architecture $target_cpu])
		;;
esac

dnl ---Options

OBJDIR=`pwd`/objdir
if test "${host_alias}" ; then
	OBJDIR="$OBJDIR-${host_alias}"
fi

if test "x$BUILD_CFLAGS" = "x" ; then
	BUILD_CFLAGS='-O2 -Wall'
fi

if test "x$TARGET_CFLAGS" = "x" ; then
	TARGET_CFLAGS='-O2 -Wall'
fi

AC_ARG_WITH([objdir], AC_HELP_STRING([--with-objdir=<dir>],[select directory for object files]),
	[ OBJDIR="$withval" ], [ OBJDIR="$OBJDIR" ])

AC_ARG_WITH([gamecube],
		AC_HELP_STRING([--with-gamecube],[enable gamecube support]),
		AC_DEFINE(WITH_GAMECUBE, 1,
			[Define to include gamecube support]))

AC_ARG_WITH([zlib], AC_HELP_STRING([--without-zlib],[disable zlib support]),
	[ with_zlib="$withval"], [ with_zlib=yes ] )

AC_ARG_WITH([lzma], AC_HELP_STRING([--without-lzma],[disable lzma support]),
	[ with_lzma="$withval"], [ with_lzma=yes ] )

AC_ARG_WITH([xen], AC_HELP_STRING([--without-xen],
	[disable extended xen support]), [ with_xen="$withval"], [ with_xen=yes ] )

AC_ARG_WITH([booke],
		AC_HELP_STRING([--with-booke],[build for booke]),
		AC_DEFINE(CONFIG_BOOKE,1,
			[Define to build for BookE]))

dnl ---Programs
dnl To specify a different compiler, just 'export CC=/path/to/compiler'
if test "${build}" != "${host}" ; then
	AC_CHECK_PROGS(BUILD_CC, [${build_alias}-gcc ${build}-gcc gcc])
else
	BUILD_CC="$CC"
fi

dnl Find the compiler tool chain
AC_PROG_CPP
AC_CHECK_TOOL([LD], ld, "no", $PATH)
AC_CHECK_TOOL([AS], as, "no", $PATH)
AC_CHECK_TOOL([OBJCOPY], objcopy, "no", $PATH)
AC_CHECK_TOOL([AR], ar, "", $PATH)
AC_CHECK_TOOL([STRIP], strip, "no", $PATH)

dnl Find compiler for target
if test "${target}" != "${host}" ; then
	AC_CHECK_PROGS(TARGET_CC, [${target_alias}-gcc ${target}-gcc gcc])
	AC_CHECK_PROGS(TARGET_LD, [${target_alias}-ld ${target}-ld ld])
else
	TARGET_CC="$CC"
	TARGET_LD="$LD"
fi

AC_MSG_CHECKING([whether $TARGET_CC accepts -fno-zero-initialized-in-bss])
saved_CFLAGS="$CFLAGS"
saved_CC="$CC"
CC="$TARGET_CC"
CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,,)],
		  PURGATORY_EXTRA_CFLAGS="-fno-zero-initialized-in-bss"
		  AC_MSG_RESULT([Yes]), AC_MSG_RESULT([No]))
CFLAGS="$saved_CFLAGS"
CC="$saved_CC"

AC_SUBST(PURGATORY_EXTRA_CFLAGS, [$PURGATORY_EXTRA_CFLAGS])

dnl Find the helper functions
AC_PROG_INSTALL
AC_CHECK_PROG([MKDIR],    mkdir,    mkdir,    "no", [$PATH])
AC_CHECK_PROG([RM],       rm,       rm,       "no", [$PATH])
AC_CHECK_PROG([CP],       cp,       cp,       "no", [$PATH])
AC_CHECK_PROG([LN],       ln,       ln,       "no", [$PATH])
AC_CHECK_PROG([TAR],      tar,      tar,      "no", [$PATH])
AC_CHECK_PROG([RPMBUILD], rpmbuild, rpmbuild, "no", [$PATH])
AC_CHECK_PROG([SED],      sed,      sed,      "no", [$PATH])
AC_CHECK_PROG([FIND],     find,     find,     "no", [$PATH])
AC_CHECK_PROG([XARGS],    xargs,    xargs,    "no", [$PATH])
AC_CHECK_PROG([DIRNAME],  dirname,  dirname,  "no", [$PATH])

dnl See if I have a usable copy of zlib available
if test "$with_zlib" = yes ; then
	AC_CHECK_HEADER(zlib.h,
		[AC_CHECK_LIB(z, inflateInit_, ,
		AC_MSG_NOTICE([zlib support disabled]))])
fi

dnl See if I have a usable copy of lzma available
if test "$with_lzma" = yes ; then
	AC_CHECK_HEADER(lzma.h,
		[AC_CHECK_LIB(lzma, lzma_code, ,
		AC_MSG_NOTICE([lzma support disabled]))])
fi

dnl find Xen control stack libraries
if test "$with_xen" = yes ; then
	AC_CHECK_HEADER(xenctrl.h,
		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
		AC_MSG_NOTICE([Xen support disabled]))])
fi

dnl Link libxenctrl.so at run-time rather than build-time
if test "$with_xen" = dl ; then
	AC_CHECK_HEADER(dlfcn.h,
		[AC_CHECK_LIB(dl, dlopen, ,
			AC_MSG_ERROR([Dynamic library linking not available]))],
		AC_MSG_ERROR([Dynamic library linking header not available]))
	AC_DEFINE(CONFIG_LIBXENCTRL_DL, 1, [Define to 1 to link libxenctrl.so at run-time rather than build-time])
	AC_CHECK_HEADER(xenctrl.h,
		[AC_CHECK_LIB(xenctrl, xc_kexec_load,
		AC_DEFINE(HAVE_LIBXENCTRL, 1, ), # required define, and prevent -lxenctrl
		AC_MSG_NOTICE([Xen support disabled]))])
fi

dnl Check for the Xen kexec_status hypercall - reachable from --with-xen=yes|dl
if test "$ac_cv_lib_xenctrl_xc_kexec_load" = yes ; then
	AC_CHECK_LIB(xenctrl, xc_kexec_status,
		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
			[The kexec_status call is available]),
		AC_MSG_NOTICE([The kexec_status call is not available]))
fi

dnl ---Sanity checks
if test "$CC"      = "no"; then AC_MSG_ERROR([cc not found]); fi
if test "$CPP"     = "no"; then AC_MSG_ERROR([cpp not found]); fi
if test "$LD"      = "no"; then AC_MSG_ERROR([ld not found]); fi
if test "$AS"      = "no"; then AC_MSG_ERROR([as not found]); fi
if test "$OBJCOPY" = "no"; then	AC_MSG_ERROR([objcopy not found]); fi
if test "$AR"      = "no"; then	AC_MSG_ERROR([ar not found]); fi

if test "$MKDIR"   = "no"; then AC_MSG_ERROR([ mkdir not found]); fi
if test "$RM"      = "no"; then AC_MSG_ERROR([ rm not found]); fi
if test "$CP"      = "no"; then AC_MSG_ERROR([ cp not found]); fi
if test "$LN"      = "no"; then AC_MSG_ERROR([ ln not found]); fi
if test "$TAR"     = "no"; then AC_MSG_ERROR([ tar not found]); fi
if test "$RPM"     = "no"; then AC_MSG_ERROR([ rpm not found]); fi
if test "$SED"     = "no"; then AC_MSG_ERROR([ sed not found]); fi
if test "$FIND"    = "no"; then AC_MSG_ERROR([ find not found]); fi
if test "$XARGS"   = "no"; then AC_MSG_ERROR([ xargs not found]); fi
if test "$DIRNAME" = "no"; then AC_MSG_ERROR([ dirname not found]); fi
if test "$STRIP"   = "no"; then AC_MSG_ERROR([ strip not found]); fi

dnl ---Output variables...
AC_SUBST([BUILD_CC])
AC_SUBST([BUILD_CFLAGS])
AC_SUBST([TARGET_CC])
AC_SUBST([TARGET_LD])
AC_SUBST([TARGET_CFLAGS])
AC_SUBST([ASFLAGS])

AC_SUBST([ARCH])
AC_SUBST([SUBARCH])
AC_SUBST([OBJDIR])
AC_SUBST([INSTALL])

dnl ---Output
AC_OUTPUT([Makefile])