diff --git a/Makefile.objs b/Makefile.objs
index cc8f506..5d50645 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -158,7 +158,7 @@ trace-events-subdirs += net
 trace-events-subdirs += target/arm
 trace-events-subdirs += target/i386
 trace-events-subdirs += target/sparc
-trace-events-y += target/s390x/trace-events
+trace-events-subdirs += target/s390x
 trace-events-y += target/ppc/trace-events
 trace-events-y += qom/trace-events
 trace-events-y += linux-user/trace-events
diff --git a/Makefile.target b/Makefile.target
index b14ab45..38ef518 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -162,6 +162,29 @@ GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h
 
 endif # CONFIG_SOFTMMU
 
+ifeq ($(TARGET_BASE_ARCH),s390x)
+# build and run feature list generator
+feat-src = $(SRC_PATH)/target/$(TARGET_BASE_ARCH)/
+feat-dst = $(BUILD_DIR)/$(TARGET_DIR)
+ifneq ($(MAKECMDGOALS),clean)
+GENERATED_HEADERS += $(feat-dst)gen-features.h
+endif
+
+$(feat-dst)gen-features.h: $(feat-dst)gen-features.h-timestamp
+	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
+$(feat-dst)gen-features.h-timestamp: $(feat-dst)gen-features
+	$(call quiet-command,$< >$@,"GEN","$(TARGET_DIR)gen-features.h")
+
+$(feat-dst)gen-features: $(feat-src)gen-features.c
+	$(call quiet-command,$(HOST_CC) $(QEMU_INCLUDES) -o $@ $<,"CC","$(TARGET_DIR)gen-features")
+
+clean-target:
+	rm -f gen-features.h-timestamp
+	rm -f gen-features.h
+	rm -f gen-features
+
+endif
+
 # Workaround for http://gcc.gnu.org/PR55489, see configure.
 %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
 
diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs
index c573633..98f6f95 100644
--- a/target/s390x/Makefile.objs
+++ b/target/s390x/Makefile.objs
@@ -4,22 +4,5 @@ obj-y += gdbstub.o cpu_models.o cpu_features.o
 obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o
 obj-$(CONFIG_KVM) += kvm.o
 
-# build and run feature list generator
-feat-src = $(SRC_PATH)/target/$(TARGET_BASE_ARCH)/
-feat-dst = $(BUILD_DIR)/$(TARGET_DIR)
-ifneq ($(MAKECMDGOALS),clean)
-GENERATED_HEADERS += $(feat-dst)gen-features.h
-endif
-
-$(feat-dst)gen-features.h: $(feat-dst)gen-features.h-timestamp
-	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
-$(feat-dst)gen-features.h-timestamp: $(feat-dst)gen-features
-	$(call quiet-command,$< >$@,"GEN","$(TARGET_DIR)gen-features.h")
-
-$(feat-dst)gen-features: $(feat-src)gen-features.c
-	$(call quiet-command,$(HOST_CC) $(QEMU_INCLUDES) -o $@ $<,"CC","$(TARGET_DIR)gen-features")
-
-clean-target:
-	rm -f gen-features.h-timestamp
-	rm -f gen-features.h
-	rm -f gen-features
+trace-obj-y += trace.o
+trace-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace.o
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 0a39d31..db92ea1 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -30,7 +30,7 @@
 #include "qemu/cutils.h"
 #include "qemu/timer.h"
 #include "qemu/error-report.h"
-#include "trace.h"
+#include "target/s390x/trace.h"
 #include "qapi/visitor.h"
 #include "migration/vmstate.h"
 #include "exec/exec-all.h"
diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c
index 590bfa4..b2ff2fc 100644
--- a/target/s390x/ioinst.c
+++ b/target/s390x/ioinst.c
@@ -13,7 +13,7 @@
 
 #include "cpu.h"
 #include "hw/s390x/ioinst.h"
-#include "trace.h"
+#include "target/s390x/trace.h"
 #include "hw/s390x/s390-pci-bus.h"
 
 int ioinst_disassemble_sch_ident(uint32_t value, int *m, int *cssid, int *ssid,
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index 97afe02..c861a58 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -38,7 +38,7 @@
 #include "qapi/qmp/qjson.h"
 #include "exec/gdbstub.h"
 #include "exec/address-spaces.h"
-#include "trace.h"
+#include "target/s390x/trace.h"
 #include "qapi-event.h"
 #include "hw/s390x/s390-pci-inst.h"
 #include "hw/s390x/s390-pci-bus.h"
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index b11a027..100f888 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -20,7 +20,7 @@
 #include "exec/address-spaces.h"
 #include "cpu.h"
 #include "sysemu/kvm.h"
-#include "trace.h"
+#include "target/s390x/trace.h"
 #include "hw/s390x/storage-keys.h"
 
 /* #define DEBUG_S390 */
