0a122b
From 4731e5c2fd12e1faf421d63b715c538d43c1dddb Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <4731e5c2fd12e1faf421d63b715c538d43c1dddb.1387298827.git.minovotn@redhat.com>
0a122b
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
From: "Michael S. Tsirkin" <mst@redhat.com>
0a122b
Date: Tue, 17 Dec 2013 15:18:15 +0100
0a122b
Subject: [PATCH 33/56] acpi: add rules to compile ASL source
0a122b
0a122b
RH-Author: Michael S. Tsirkin <mst@redhat.com>
0a122b
Message-id: <1387293161-4085-34-git-send-email-mst@redhat.com>
0a122b
Patchwork-id: 56339
0a122b
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 33/57] acpi: add rules to compile ASL source
0a122b
Bugzilla: 1034876
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
Detect presence of IASL compiler and use it
0a122b
to process ASL source. If not there, use pre-compiled
0a122b
files in-tree. Add script to update the in-tree files.
0a122b
0a122b
Note: distros are known to silently update iasl
0a122b
so detect correct iasl flags for the installed version on each run as
0a122b
opposed to at configure time.
0a122b
0a122b
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
0a122b
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
0a122b
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
0a122b
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Tested-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
(cherry picked from commit a31a864273bb501851a4d52a366c645d06a53991)
0a122b
0a122b
Conflicts:
0a122b
	configure
0a122b
---
0a122b
 configure              |  9 ++++++++-
0a122b
 hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
0a122b
 scripts/update-acpi.sh |  4 ++++
0a122b
 3 files changed, 34 insertions(+), 1 deletion(-)
0a122b
 create mode 100644 scripts/update-acpi.sh
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 configure              |  9 ++++++++-
0a122b
 hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
0a122b
 scripts/update-acpi.sh |  4 ++++
0a122b
 3 files changed, 34 insertions(+), 1 deletion(-)
0a122b
 create mode 100644 scripts/update-acpi.sh
0a122b
0a122b
diff --git a/configure b/configure
0a122b
index 1af1079..f86793d 100755
0a122b
--- a/configure
0a122b
+++ b/configure
0a122b
@@ -119,6 +119,7 @@ path_of() {
0a122b
 # default parameters
0a122b
 source_path=`dirname "$0"`
0a122b
 cpu=""
0a122b
+iasl="iasl"
0a122b
 interp_prefix="/usr/gnemul/qemu-%M"
0a122b
 static="no"
0a122b
 cross_prefix=""
0a122b
@@ -252,6 +253,8 @@ for opt do
0a122b
   ;;
0a122b
   --cc=*) CC="$optarg"
0a122b
   ;;
0a122b
+  --iasl=*) iasl="$optarg"
0a122b
+  ;;
0a122b
   --source-path=*) source_path="$optarg"
0a122b
   ;;
0a122b
   --cpu=*) cpu="$optarg"
0a122b
@@ -1074,6 +1077,7 @@ echo "Advanced options (experts only):"
0a122b
 echo "  --source-path=PATH       path of source code [$source_path]"
0a122b
 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
0a122b
 echo "  --cc=CC                  use C compiler CC [$cc]"
0a122b
+echo "  --iasl=IASL              use ACPI compiler IASL [$iasl]"
0a122b
 echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
0a122b
 echo "                           build time"
0a122b
 echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
0a122b
@@ -4056,6 +4060,9 @@ else
0a122b
 fi
0a122b
 echo "PYTHON=$python" >> $config_host_mak
0a122b
 echo "CC=$cc" >> $config_host_mak
0a122b
+if $iasl -h > /dev/null 2>&1; then
0a122b
+  echo "IASL=$iasl" >> $config_host_mak
0a122b
+fi
0a122b
 echo "CC_I386=$cc_i386" >> $config_host_mak
0a122b
 echo "HOST_CC=$host_cc" >> $config_host_mak
0a122b
 echo "OBJCC=$objcc" >> $config_host_mak
0a122b
@@ -4544,7 +4551,7 @@ for rom in seabios vgabios ; do
0a122b
     echo "BCC=bcc" >> $config_mak
0a122b
     echo "CPP=$cpp" >> $config_mak
0a122b
     echo "OBJCOPY=objcopy" >> $config_mak
0a122b
-    echo "IASL=iasl" >> $config_mak
0a122b
+    echo "IASL=$iasl" >> $config_mak
0a122b
     echo "LD=$ld" >> $config_mak
0a122b
 done
0a122b
 
0a122b
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
0a122b
index 205d22e..013d250 100644
0a122b
--- a/hw/i386/Makefile.objs
0a122b
+++ b/hw/i386/Makefile.objs
0a122b
@@ -4,3 +4,25 @@ obj-y += pc.o pc_piix.o pc_q35.o
0a122b
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
0a122b
 
0a122b
 obj-y += kvmvapic.o
0a122b
+
0a122b
+iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
0a122b
+    ; then echo "$(2)"; else echo "$(3)"; fi ;)
0a122b
+
0a122b
+ifdef IASL
0a122b
+#IASL Present. Generate hex files from .dsl
0a122b
+hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
0a122b
+	$(call quiet-command, cpp -P $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
0a122b
+	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
0a122b
+	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
0a122b
+	$(call quiet-command, $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
0a122b
+	$(call quiet-command, cat $*.off > $@, "  CAT $(TARGET_DIR)$@")
0a122b
+else
0a122b
+#IASL Not present. Restore pre-generated hex files.
0a122b
+hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated
0a122b
+	$(call quiet-command, cp -f $< $@, "  CP $(TARGET_DIR)$@")
0a122b
+endif
0a122b
+
0a122b
+.PHONY: cleanhex
0a122b
+cleanhex:
0a122b
+	rm -f hw/i386/*hex
0a122b
+clean: cleanhex
0a122b
diff --git a/scripts/update-acpi.sh b/scripts/update-acpi.sh
0a122b
new file mode 100644
0a122b
index 0000000..b5f05ff
0a122b
--- /dev/null
0a122b
+++ b/scripts/update-acpi.sh
0a122b
@@ -0,0 +1,4 @@
0a122b
+cd x86_64-softmmu
0a122b
+for file in hw/i386/*.hex; do
0a122b
+    cp -f $file ../$file.generated
0a122b
+done
0a122b
-- 
0a122b
1.7.11.7
0a122b