aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 6914eb4fd5f892fb6b58a85813bef458f64917f4 (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
# configure.ac - autoconf script for the AArch64 bootwrapper
#
# Copyright (c) 2014 ARM Limited. All rights reserved.
#
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE.txt file.

AC_INIT([boot-wrapper], [v0.2])

AM_INIT_AUTOMAKE([foreign])

AC_ARG_ENABLE([aarch32-bw],
	      AS_HELP_STRING([--enable-aarch32-bw], [build a 32-bit boot-wrapper]),
	      [BOOTWRAPPER_ES=32], [BOOTWRAPPER_ES=64])
AM_CONDITIONAL([BOOTWRAPPER_32], [test "x$BOOTWRAPPER_ES" = "x32"])

AC_ARG_ENABLE([aarch32-kernel],
	AC_HELP_STRING([--enable-aarch32-kernel],
		       [start kernel in AArch32 instead of AArch64]),
	[KERNEL_ES=32 USE_PSCI=yes AC_SUBST([KERNEL_32], [1]) AC_DEFINE([KERNEL_32])],
	[KERNEL_ES=64])
AM_CONDITIONAL([KERNEL_32], [test "x$KERNEL_ES" = x32])

AS_IF([test "x$BOOTWRAPPER_ES" = x32 -a "x$KERNEL_ES" != x32],
	[AC_MSG_ERROR([a 32-bit boot-wrapper cannot launch a 64-bit kernel])]
)

# Allow a user to pass --with-kernel-dir
AC_ARG_WITH([kernel-dir],
	AS_HELP_STRING([--with-kernel-dir], [specify the root Linux kernel build directory (required)]),
	AC_SUBST([KERN_DIR], [$withval]),
	AC_MSG_ERROR([No kernel directory specified. Use --with-kernel-dir]))
AS_IF([test "x$KERNEL_ES" = x32],
	[KERN_IMAGE=$KERN_DIR/arch/arm/boot/zImage],
	[KERN_IMAGE=$KERN_DIR/arch/arm64/boot/Image])
KERN_DTB=$KERN_DIR/arch/arm64/boot/dts/rtsm_ve-aemv8a.dtb

# Allow the user to override the default DTB
AC_ARG_WITH([dtb],
	AS_HELP_STRING([--with-dtb], [Specify a particular DTB to use]),
	[KERN_DTB="$withval"])

AC_ARG_WITH([xen],
	AS_HELP_STRING([--with-xen], [Compile for Xen, and specify a particular Xen to use]),
	X_IMAGE=$withval)

AS_IF([test "x$X_IMAGE" == "x"], [],
      [AS_IF([test ! -f "$X_IMAGE"],
	     [AC_MSG_ERROR([Could not find Xen hypervisor binary: $X_IMAGE])]
      )]
)
AC_SUBST([XEN_IMAGE], [$X_IMAGE])
AM_CONDITIONAL([XEN], [test "x$X_IMAGE" != "x"])

# Ensure that the user has provided us with a sane kernel dir.
if ! test -d $KERN_DIR; then
	AC_MSG_ERROR([Could not find Linux kernel dir: $KERN_DIR.])
fi

AC_MSG_CHECKING([whether DTB file exists])
if ! test -f $KERN_DTB; then
	AC_MSG_RESULT([no])
	AC_MSG_ERROR([Could not find DTB file: $KERN_DTB])
else
	AC_MSG_RESULT([yes])
fi

AC_MSG_CHECKING([whether kernel image exists])
if ! test -f $KERN_IMAGE; then
	AC_MSG_RESULT([no])
	AC_MSG_ERROR([Could not find kernel image: $KERN_IMAGE])
else
	AC_MSG_RESULT([yes])
fi

AC_SUBST([KERNEL_IMAGE], [$KERN_IMAGE])
AC_SUBST([KERNEL_DTB], [$KERN_DTB])
AS_IF([test "x$X_IMAGE" != "x"],
      [AC_SUBST([IMAGE], ["xen-system.axf"])],
      [AC_SUBST([IMAGE], ["linux-system.axf"])]
)

# Allow a user to pass --enable-psci
AC_ARG_ENABLE([psci],
	AS_HELP_STRING([--enable-psci], [enable the psci boot method]),
	[USE_PSCI=$enableval])
AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes"])
AS_IF([test "x$USE_PSCI" = "xyes"], [], [USE_PSCI=no])

AS_IF([test "x$USE_PSCI" != "xyes" -a "x$KERNEL_ES" = "x32"],
	[AC_MSG_ERROR([With an AArch32 kernel, boot method must be PSCI.])]
)

# Allow a user to pass --with-initrd
AC_ARG_WITH([initrd],
	AS_HELP_STRING([--with-initrd], [embed an initrd in the kernel image]),
	USE_INITRD=$withval)
AC_SUBST([FILESYSTEM], [$USE_INITRD])
AM_CONDITIONAL([INITRD], [test "x$USE_INITRD" != "x"])

AS_IF([test "x$X_IMAGE" = "x"],[C_CONSOLE="ttyAMA0"],[C_CONSOLE="hvc0"])
C_CMDLINE="console=$C_CONSOLE earlyprintk=pl011,0x1c090000"
AC_ARG_WITH([cmdline],
	AS_HELP_STRING([--with-cmdline], [set a command line for the kernel]),
	[C_CMDLINE=$withval])
AC_SUBST([CMDLINE], [$C_CMDLINE])

X_CMDLINE="console=dtuart dtuart=serial0 no-bootscrub"
AC_ARG_WITH([xen-cmdline],
	AS_HELP_STRING([--with-xen-cmdline], [set Xen command line]),
	[X_CMDLINE=$withval])
AC_SUBST([XEN_CMDLINE], [$X_CMDLINE])

# Allow a user to pass --enable-gicv3
AC_ARG_ENABLE([gicv3],
	AS_HELP_STRING([--enable-gicv3], [enable GICv3 instead of GICv2]),
	[USE_GICV3=$enableval])
AM_CONDITIONAL([GICV3], [test "x$USE_GICV3" = "xyes"])
AS_IF([test "x$USE_GICV3" = "xyes"], [], [USE_GICV3=no])

# Ensure that we have all the needed programs
AC_PROG_CC
AC_PROG_CPP
AM_PROG_AS
AC_PROG_SED
AC_PROG_LN_S
AC_PATH_PROG([DTC], dtc, error, [$PATH$PATH_SEPARATOR$KERN_DIR/scripts/dtc])
if test "x$DTC" = "xerror"; then
	AC_MSG_ERROR([cannot find the device tree compiler (dtc)])
fi
AC_CHECK_TOOL(LD, ld)

AC_CONFIG_FILES([Makefile])

AC_OUTPUT

# Print the final config to the user.
echo ""
echo "  Boot wrapper configuration"
echo "  =========================="
echo ""
echo "  Linux kernel build dir:            ${KERN_DIR}"
echo "  Device tree blob:                  ${KERN_DTB}"
echo "  Linux kernel command line:         ${CMDLINE}"
echo "  Embedded initrd:                   ${FILESYSTEM:-NONE}"
echo "  Use PSCI?                          ${USE_PSCI}"
echo "  Use GICv3?                         ${USE_GICV3}"
echo "  Boot-wrapper execution state:      AArch${BOOTWRAPPER_ES}"
echo "  Kernel execution state:            AArch${KERNEL_ES}"
echo "  Xen image                          ${XEN_IMAGE:-NONE}"
if test "x${XEN_IMAGE}" != "x"; then
echo "  Xen command line:                  ${XEN_CMDLINE}"
fi
echo ""