xref: /illumos-kvm-cmd/build.sh (revision 6c662a20)
1#!/bin/bash
2#
3# Copyright 2019 Joyent, Inc.
4#
5
6for dir in seabios vgabios kvm/test; do
7	[[ ! -f roms/${dir}/config.mak.tmpl ]] || \
8	    cp roms/${dir}/config.mak.tmpl roms/${dir}/config.mak
9done
10
11PNGDIR="${PWD}/libpng-1.5.4"
12PNGINC="${PNGDIR}/proto/usr/local/include"
13PNGLIB="${PNGDIR}/proto/usr/local/lib"
14
15. $(pwd)/../../../build.env
16
17#
18# Skip dangerous GCC options (not that any specific problems are known of here).
19#
20if [[ "$PRIMARY_COMPILER_VER" -gt 4 ]]; then
21	XCFLAGS=-fno-aggressive-loop-optimizations
22fi
23
24if [[ ! -d ${PNGDIR} ]]; then
25	(curl https://us-east.manta.joyent.com/Joyent_Dev/public/releng/kvm-cmd/libpng-1.5.4.tar.gz | \
26	    gtar -zxf -)
27	if [[ $? != "0" || ! -d ${PNGDIR} ]]; then
28		echo "Failed to get libpng."
29		rm -rf ${PNGDIR}
30		exit 1
31	fi
32fi
33
34if [[ ! -e ${PNGLIB}/libpng.a ]]; then
35	(cd ${PNGDIR} && \
36	    CC="${CC:-${STRAP_AREA}/usr/bin/gcc}" \
37	    LDFLAGS="-m64 -L${DESTDIR}/usr/lib/amd64 -L${DESTDIR}/lib/amd64" \
38	    CPPFLAGS="-isystem ${DESTDIR}/usr/include" \
39	    CFLAGS="-m64 $XCFLAGS" ./configure --disable-shared && \
40	    make && \
41	    mkdir -p ${PNGDIR}/proto && \
42	    make DESTDIR=${PNGDIR}/proto install)
43fi
44
45echo "==> Running configure"
46KVM_DIR="${KVM_DIR:-$(cd `pwd`/../kvm; pwd)}"
47CC="${CC:-${STRAP_AREA}/usr/bin/gcc}"
48XCFLAGS="$XCFLAGS -fno-builtin -I${PNGINC} -isystem ${DESTDIR}/usr/include -msave-args"
49XLDFLAGS="-nodefaultlibs -L${PNGLIB} -L${DESTDIR}/usr/lib/amd64 -L${DESTDIR}/lib/amd64"
50XLDFLAGS="${XLDFLAGS} -Wl,-zfatal-warnings -Wl,-zassert-deflib"
51XLDFLAGS="${XLDFLAGS} -lz -lm -lc -lvnd"
52./configure \
53    --cc=$CC \
54    --extra-cflags="${XCFLAGS}" \
55    --extra-ldflags="${XLDFLAGS}" \
56    --prefix=/smartdc \
57    --audio-card-list= \
58    --audio-drv-list= \
59    --disable-bluez \
60    --disable-brlapi \
61    --disable-curl \
62    --enable-debug \
63    --disable-docs \
64    --enable-kvm \
65    --enable-kvm-pit \
66    --enable-vnc-png \
67    --disable-kvm-device-assignment \
68    --disable-sdl \
69    --disable-vnc-jpeg \
70    --disable-vnc-sasl \
71    --disable-vnc-tls \
72    --enable-trace-backend=dtrace \
73    --kerneldir="$KVM_DIR" \
74    --cpu=x86_64
75
76if [[ $? != 0 ]]; then
77	echo "Failed to configure, bailing"
78	exit 1
79fi
80
81
82#
83# Make sure ctf utilities are in our path
84#
85KERNEL_SOURCE="${KERNEL_SOURCE:-$(pwd)/../../illumos}"
86CTFBINDIR="$KERNEL_SOURCE"/usr/src/tools/proto/root_i386-nd/opt/onbld/bin/i386
87export PATH="$PATH:$CTFBINDIR"
88
89if [[ -z "$CONFIGURE_ONLY" ]]; then
90	echo "==> Make"
91	V=1 gmake
92else
93	echo "Not running make per-request"
94fi
95