]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/build.sh
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / OvmfPkg / build.sh
index 5bfee725ad2d699bf5f11339043d4d37f8607b54..68215520256421111cc72802856b3a28b5f00327 100755 (executable)
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
@@ -41,7 +41,8 @@ fi
 # Configure defaults for various options
 #
 
-PROCESSOR=X64
+ARCH_IA32=no
+ARCH_X64=no
 BUILDTARGET=DEBUG
 BUILD_OPTIONS=
 PLATFORMFILE=
@@ -60,7 +61,13 @@ case `uname` in
     ;;
   Darwin*)
     Major=$(uname -r | cut -f 1 -d '.')
+    # Major is Darwin version, not OS X version.
+    # OS X Yosemite 10.10.2 returns 14.
     case $Major in
+      [156789])
+        echo OvmfPkg requires OS X Snow Leopard 10.6 or newer OS
+        exit 1
+        ;;
       10)
         TARGET_TOOLS=XCODE32
         ;;
@@ -68,14 +75,21 @@ case `uname` in
         TARGET_TOOLS=XCLANG
         ;;
        *)
-        echo OvmfPkg requires Snow Leopard or later OS
-        exit 1
+        # Mavericks and future assume XCODE5 (clang + lldb)
+        TARGET_TOOLS=XCODE5
         ;;
     esac
     ;;
   Linux*)
     gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
     case $gcc_version in
+      [1-3].*|4.[0-3].*)
+        echo OvmfPkg requires GCC4.4 or later
+        exit 1
+        ;;
+      4.4.*)
+        TARGET_TOOLS=GCC44
+        ;;
       4.5.*)
         TARGET_TOOLS=GCC45
         ;;
@@ -85,11 +99,14 @@ case `uname` in
       4.7.*)
         TARGET_TOOLS=GCC47
         ;;
-      4.[8-9].*)
+      4.8.*)
         TARGET_TOOLS=GCC48
         ;;
+      4.9.*|6.[0-2].*)
+        TARGET_TOOLS=GCC49
+        ;;
       *)
-        TARGET_TOOLS=GCC44
+        TARGET_TOOLS=GCC5
         ;;
     esac
 esac
@@ -120,7 +137,12 @@ do
   else
     case $LAST_ARG in
       -a)
-        PROCESSOR=$arg
+        if [[ x"$arg" != x"IA32" && x"$arg" != x"X64" ]]; then
+          echo Unsupported processor architecture: $arg
+          echo Only IA32 or X64 is supported
+          exit 1
+        fi
+        eval ARCH_$arg=yes
         ;;
       -b)
         BUILDTARGET=$arg
@@ -143,9 +165,28 @@ do
   shift
 done
 
+if [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "yes" ]]; then
+  PROCESSOR=IA32X64
+  Processor=Ia32X64
+  BUILD_OPTIONS="$BUILD_OPTIONS -a IA32 -a X64"
+  PLATFORM_BUILD_DIR=Ovmf3264
+  BUILD_ROOT_ARCH=X64
+elif [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "no" ]]; then
+  PROCESSOR=IA32
+  Processor=Ia32
+  BUILD_OPTIONS="$BUILD_OPTIONS -a IA32"
+  PLATFORM_BUILD_DIR=Ovmf$Processor
+  BUILD_ROOT_ARCH=$PROCESSOR
+else
+  PROCESSOR=X64
+  Processor=X64
+  BUILD_OPTIONS="$BUILD_OPTIONS -a X64"
+  PLATFORM_BUILD_DIR=Ovmf$Processor
+  BUILD_ROOT_ARCH=X64
+fi
+
 case $PROCESSOR in
   IA32)
-    Processor=Ia32
     if [ -n "$QEMU_COMMAND" ]; then
       #
       # The user set the QEMU_COMMAND variable. We'll use it to run QEMU.
@@ -162,8 +203,7 @@ case $PROCESSOR in
       exit 1
     fi
     ;;
-  X64)
-    Processor=X64
+  X64|IA32X64)
     if [ -z "$QEMU_COMMAND" ]; then
       #
       # The user didn't set the QEMU_COMMAND variable.
@@ -183,7 +223,9 @@ if [ -z "$PLATFORMFILE" ]; then
 fi
 
 if [[ "$RUN_QEMU" == "yes" ]]; then
-  qemu_version=$($QEMU_COMMAND -version 2>&1 | tail -1 | awk '{print $4}')
+  qemu_version=$($QEMU_COMMAND -version 2>&1 | \
+                   grep -o -E 'version [0-9]+\.[0-9]+\.[0-9]+' | \
+                     awk '{print $2}')
   case $qemu_version in
     1.[6-9].*|1.[1-9][0-9].*|2.*.*)
       ENABLE_FLASH=yes
@@ -213,9 +255,9 @@ fi
 #echo Remaining for qemu: $*
 #exit 1
 
-BUILD_ROOT=$WORKSPACE/Build/Ovmf$Processor/"$BUILDTARGET"_"$TARGET_TOOLS"
+BUILD_ROOT=$WORKSPACE/Build/$PLATFORM_BUILD_DIR/"$BUILDTARGET"_"$TARGET_TOOLS"
 FV_DIR=$BUILD_ROOT/FV
-BUILD_ROOT_ARCH=$BUILD_ROOT/$PROCESSOR
+BUILD_ROOT_ARCH=$BUILD_ROOT/$BUILD_ROOT_ARCH
 QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
 
 if  [[ ! -f `which build` || ! -f `which GenFv` ]];
@@ -246,9 +288,8 @@ if [[ "$RUN_QEMU" == "yes" ]]; then
   if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
     QEMU_COMMAND="$QEMU_COMMAND -hda fat:$BUILD_ROOT_ARCH"
   fi
-  QEMU_COMMAND="$QEMU_COMMAND $*"
-  echo Running: $QEMU_COMMAND
-  $QEMU_COMMAND
+  echo Running: $QEMU_COMMAND "$@"
+  $QEMU_COMMAND "$@"
   exit $?
 fi
 
@@ -256,6 +297,6 @@ fi
 # Build the edk2 OvmfPkg
 #
 echo Running edk2 build for OvmfPkg$Processor
-build -p $PLATFORMFILE $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -n $THREADNUMBER
+build -p $PLATFORMFILE $BUILD_OPTIONS -b $BUILDTARGET -t $TARGET_TOOLS -n $THREADNUMBER
 exit $?