summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in22
-rw-r--r--doc/Makefile5
-rw-r--r--include/Makefile9
-rw-r--r--kdump/Makefile1
-rw-r--r--kexec/Makefile18
-rw-r--r--kexec/arch/alpha/Makefile4
-rw-r--r--kexec/arch/arm/Makefile10
-rw-r--r--kexec/arch/i386/Makefile23
-rw-r--r--kexec/arch/ia64/Makefile15
-rw-r--r--kexec/arch/ppc/Makefile17
-rw-r--r--kexec/arch/ppc64/Makefile17
-rw-r--r--kexec/arch/s390/Makefile10
-rw-r--r--kexec/arch/sh/Makefile14
-rw-r--r--kexec/arch/x86_64/Makefile24
-rw-r--r--kexec_test/Makefile15
-rw-r--r--purgatory/Makefile24
-rw-r--r--purgatory/arch/alpha/Makefile4
-rw-r--r--purgatory/arch/arm/Makefile5
-rw-r--r--purgatory/arch/i386/Makefile28
-rw-r--r--purgatory/arch/ia64/Makefile13
-rw-r--r--purgatory/arch/ppc/Makefile9
-rw-r--r--purgatory/arch/ppc64/Makefile19
-rw-r--r--purgatory/arch/s390/Makefile5
-rw-r--r--purgatory/arch/sh/Makefile7
-rw-r--r--purgatory/arch/x86_64/Makefile29
-rw-r--r--util/Makefile1
-rw-r--r--util_lib/Makefile2
27 files changed, 245 insertions, 105 deletions
diff --git a/Makefile.in b/Makefile.in
index 62a8cef..e5f063e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -123,11 +123,23 @@ all: $(TARGETS)
# collect objects to be removed in 'make clean'
clean =
+# collect objects to be removed in 'make clean'
+dist = AUTHORS COPYING News TODO Makefile.in configure.ac \
+ kexec-tools.spec.in config/
+
# utility function for converting a list of files (with extension) to
# file.o (or file.d) format.
objify = $(addsuffix .o, $(basename $(1)))
depify = $(addsuffix .d, $(basename $(1)))
+# Documentation
+#
+include $(srcdir)/doc/Makefile
+
+# Headers
+#
+include $(srcdir)/include/Makefile
+
# Utility function library
#
include $(srcdir)/util_lib/Makefile
@@ -155,20 +167,13 @@ include $(srcdir)/kdump/Makefile
#
# kexec_test (test program)
#
-ifeq ($(ARCH),i386)
-include $(srcdir)/kexec_test/Makefile
-endif
-ifeq ($(ARCH),x86_64)
include $(srcdir)/kexec_test/Makefile
-endif
SPEC=$(PACKAGE_NAME).spec
GENERATED_SRCS:= $(SPEC)
TARBALL=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar
TARBALL.gz=$(TARBALL).gz
-SRCS:= AUTHORS COPYING News TODO Makefile.in configure.ac \
- kexec-tools.spec.in config doc include kexec purgatory kexec_test \
- kdump util util_lib configure
+SRCS:= $(dist)
PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
PGSRCS:=$(foreach s, $(GENERATED_SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
@@ -188,6 +193,7 @@ $(TARBALL): $(SRCS) $(GENERATED_SRCS)
$(LN) -sf . $(PACKAGE_NAME)-$(PACKAGE_VERSION)
$(TAR) -rf $@ $(PGSRCS)
$(RM) -f $(PACKAGE_NAME)-$(PACKAGE_VERSION)
+ @echo $(dist)
$(TARBALL.gz): $(TARBALL)
gzip -c < $^ > $@
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 0000000..3442e09
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,5 @@
+dist += doc/Makefile \
+ doc/linux-i386-boot.txt \
+ doc/linux-i386-zero-page.txt \
+ doc/multiboot.html \
+ doc/nbi-spec.txt
diff --git a/include/Makefile b/include/Makefile
new file mode 100644
index 0000000..eebbd24
--- /dev/null
+++ b/include/Makefile
@@ -0,0 +1,9 @@
+dist += include/Makefile \
+ include/config.h \
+ include/x86/x86-linux.h \
+ include/x86/mb_info.h \
+ include/x86/mb_header.h \
+ include/elf.h \
+ include/boot/linuxbios_tables.h \
+ include/boot/beoboot.h \
+ include/boot/elf_boot.h
diff --git a/kdump/Makefile b/kdump/Makefile
index 25c187b..4a788f9 100644
--- a/kdump/Makefile
+++ b/kdump/Makefile
@@ -10,6 +10,7 @@ KDUMP_DEPS = $(call depify, $(KDUMP_OBJS))
KDUMP = $(SBINDIR)/kdump
KDUMP_MANPAGE = $(MANDIR)/man8/kdump.8
+dist += kdump/Makefile $(KDUMP_SRCS) kdump/kdump.8
clean += $(KDUMP_OBJS) $(KDUMP_DEPS) $(KDUMP) $(KDUMP_MANPAGE)
-include $(KDUMP_DEPS)
diff --git a/kexec/Makefile b/kexec/Makefile
index 7832a13..36bfa3a 100644
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -23,7 +23,23 @@ KEXEC_SRCS += kexec/crashdump-xen.c
KEXEC_GENERATED_SRCS += $(PURGATORY_HEX_C)
-include $(srcdir)/kexec/arch/$(ARCH)/Makefile
+dist += kexec/Makefile $(KEXEC_SRCS) $(KEXEC_GENERATED_SRCS) \
+ kexec/crashdump-elf.c \
+ kexec/crashdump.h kexec/kexec-elf-boot.h \
+ kexec/kexec-elf.h kexec/kexec-sha256.h \
+ kexec/kexec-syscall.h kexec/kexec.h kexec/kexec.8
+
+include $(srcdir)/kexec/arch/alpha/Makefile
+include $(srcdir)/kexec/arch/arm/Makefile
+include $(srcdir)/kexec/arch/i386/Makefile
+include $(srcdir)/kexec/arch/ia64/Makefile
+include $(srcdir)/kexec/arch/ppc/Makefile
+include $(srcdir)/kexec/arch/ppc64/Makefile
+include $(srcdir)/kexec/arch/s390/Makefile
+include $(srcdir)/kexec/arch/sh/Makefile
+include $(srcdir)/kexec/arch/x86_64/Makefile
+
+KEXEC_SRCS += $($(ARCH)_KEXEC_SRCS)
KEXEC_OBJS = $(call objify, $(KEXEC_SRCS) $(KEXEC_GENERATED_SRCS))
KEXEC_DEPS = $(call depify, $(KEXEC_OBJS))
diff --git a/kexec/arch/alpha/Makefile b/kexec/arch/alpha/Makefile
new file mode 100644
index 0000000..4575d61
--- /dev/null
+++ b/kexec/arch/alpha/Makefile
@@ -0,0 +1,4 @@
+alpha_KEXEC_SRCS=
+dist += kexec/arch/alpha/Makefile kexec/arch/alpha/include/arch/options.h
+ $(alpha_KEXEC_SRCS)
+
diff --git a/kexec/arch/arm/Makefile b/kexec/arch/arm/Makefile
index eb7f194..e05e4c7 100644
--- a/kexec/arch/arm/Makefile
+++ b/kexec/arch/arm/Makefile
@@ -1,6 +1,10 @@
#
# kexec arm (linux booting linux)
#
-KEXEC_SRCS+= kexec/arch/arm/kexec-elf-rel-arm.c
-KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
-KEXEC_SRCS+= kexec/arch/arm/kexec-arm.c
+arm_KEXEC_SRCS= kexec/arch/arm/kexec-elf-rel-arm.c
+arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
+arm_KEXEC_SRCS+= kexec/arch/arm/kexec-arm.c
+
+dist += kexec/arch/arm/Makefile $(arm_KEXEC_SRCS) \
+ kexec/arch/arm/kexec-arm.h \
+ kexec/arch/arm/include/arch/options.h
diff --git a/kexec/arch/i386/Makefile b/kexec/arch/i386/Makefile
index 7bda300..f2d9636 100644
--- a/kexec/arch/i386/Makefile
+++ b/kexec/arch/i386/Makefile
@@ -1,12 +1,17 @@
#
# kexec i386 (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/i386/kexec-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-elf-rel-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
-KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
-KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
-KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c
+i386_KEXEC_SRCS = kexec/arch/i386/kexec-x86.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-rel-x86.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
+i386_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
+i386_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c
+
+dist += kexec/arch/i386/Makefile $(i386_KEXEC_SRCS) \
+ kexec/arch/i386/kexec-x86.h kexec/arch/i386/crashdump-x86.h \
+ kexec/arch/i386/x86-linux-setup.h \
+ kexec/arch/i386/include/arch/options.h
diff --git a/kexec/arch/ia64/Makefile b/kexec/arch/ia64/Makefile
index ea0bdb0..f6b3789 100644
--- a/kexec/arch/ia64/Makefile
+++ b/kexec/arch/ia64/Makefile
@@ -1,9 +1,14 @@
#
# kexec ia64 (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/ia64/kexec-iomem.c
-KEXEC_SRCS += kexec/arch/ia64/kexec-ia64.c
-KEXEC_SRCS += kexec/arch/ia64/kexec-elf-ia64.c
-KEXEC_SRCS += kexec/arch/ia64/kexec-elf-rel-ia64.c
-KEXEC_SRCS += kexec/arch/ia64/crashdump-ia64.c
+ia64_KEXEC_SRCS = kexec/arch/ia64/kexec-iomem.c
+ia64_KEXEC_SRCS += kexec/arch/ia64/kexec-ia64.c
+ia64_KEXEC_SRCS += kexec/arch/ia64/kexec-elf-ia64.c
+ia64_KEXEC_SRCS += kexec/arch/ia64/kexec-elf-rel-ia64.c
+ia64_KEXEC_SRCS += kexec/arch/ia64/crashdump-ia64.c
+
+dist += kexec/arch/ia64/Makefile $(ia64_KEXEC_SRCS) \
+ kexec/arch/ia64/kexec-ia64.h kexec/arch/ia64/crashdump-ia64.h \
+ kexec/arch/ia64/include/arch/options.h
+
diff --git a/kexec/arch/ppc/Makefile b/kexec/arch/ppc/Makefile
index 52295ae..1550c20 100644
--- a/kexec/arch/ppc/Makefile
+++ b/kexec/arch/ppc/Makefile
@@ -1,9 +1,14 @@
#
# kexec ppc (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/ppc/kexec-ppc.c
-KEXEC_SRCS += kexec/arch/ppc/kexec-elf-ppc.c
-KEXEC_SRCS += kexec/arch/ppc/kexec-elf-rel-ppc.c
-KEXEC_SRCS += kexec/arch/ppc/kexec-dol-ppc.c
-KEXEC_SRCS += kexec/arch/ppc/ppc-setup-simple.S
-KEXEC_SRCS += kexec/arch/ppc/ppc-setup-dol.S
+ppc_KEXEC_SRCS = kexec/arch/ppc/kexec-ppc.c
+ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-ppc.c
+ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-rel-ppc.c
+ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-dol-ppc.c
+ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-simple.S
+ppc_KEXEC_SRCS += kexec/arch/ppc/ppc-setup-dol.S
+
+dist += kexec/arch/ppc/Makefile $(ppc_KEXEC_SRCS) \
+ kexec/arch/ppc/kexec-ppc.h kexec/arch/ppc/ppc_asm.h \
+ kexec/arch/ppc/include/arch/options.h
+
diff --git a/kexec/arch/ppc64/Makefile b/kexec/arch/ppc64/Makefile
index b3de3a6..90250f6 100644
--- a/kexec/arch/ppc64/Makefile
+++ b/kexec/arch/ppc64/Makefile
@@ -1,9 +1,14 @@
#
# kexec ppc64 (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-rel-ppc64.c
-KEXEC_SRCS += kexec/arch/ppc64/kexec-zImage-ppc64.c
-KEXEC_SRCS += kexec/arch/ppc64/fs2dt.c
-KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-ppc64.c
-KEXEC_SRCS += kexec/arch/ppc64/kexec-ppc64.c
-KEXEC_SRCS += kexec/arch/ppc64/crashdump-ppc64.c
+ppc64_KEXEC_SRCS = kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-zImage-ppc64.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/fs2dt.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-ppc64.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-ppc64.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/crashdump-ppc64.c
+
+dist += kexec/arch/ppc64/Makefile $(ppc64_KEXEC_SRCS) \
+ kexec/arch/ppc64/kexec-ppc64.h kexec/arch/ppc64/crashdump-ppc64.h \
+ kexec/arch/ppc64/include/arch/options.h
+
diff --git a/kexec/arch/s390/Makefile b/kexec/arch/s390/Makefile
index 2e496b0..9fddc60 100644
--- a/kexec/arch/s390/Makefile
+++ b/kexec/arch/s390/Makefile
@@ -1,6 +1,10 @@
#
# kexec s390 (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/s390/kexec-s390.c
-KEXEC_SRCS += kexec/arch/s390/kexec-image.c
-KEXEC_SRCS += kexec/arch/s390/kexec-elf-rel-s390.c
+s390_KEXEC_SRCS = kexec/arch/s390/kexec-s390.c
+s390_KEXEC_SRCS += kexec/arch/s390/kexec-image.c
+s390_KEXEC_SRCS += kexec/arch/s390/kexec-elf-rel-s390.c
+
+dist += kexec/arch/s390/Makefile $(s390_KEXEC_SRCS) \
+ kexec/arch/s390/kexec-s390.h \
+ kexec/arch/s390/include/arch/options.h
diff --git a/kexec/arch/sh/Makefile b/kexec/arch/sh/Makefile
index 4d49490..1595ed3 100644
--- a/kexec/arch/sh/Makefile
+++ b/kexec/arch/sh/Makefile
@@ -1,8 +1,12 @@
#
# kexec sh (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/sh/kexec-sh.c
-KEXEC_SRCS += kexec/arch/sh/kexec-zImage-sh.c
-KEXEC_SRCS += kexec/arch/sh/kexec-netbsd-sh.c
-KEXEC_SRCS += kexec/arch/sh/kexec-elf-rel-sh.c
-KEXEC_SRCS += kexec/arch/sh/netbsd_booter.S
+sh_KEXEC_SRCS += kexec/arch/sh/kexec-sh.c
+sh_KEXEC_SRCS += kexec/arch/sh/kexec-zImage-sh.c
+sh_KEXEC_SRCS += kexec/arch/sh/kexec-netbsd-sh.c
+sh_KEXEC_SRCS += kexec/arch/sh/kexec-elf-rel-sh.c
+sh_KEXEC_SRCS += kexec/arch/sh/netbsd_booter.S
+
+dist += kexec/arch/sh/Makefile $(sh_KEXEC_SRCS) \
+ kexec/arch/sh/kexec-sh.h \
+ kexec/arch/sh/include/arch/options.h
diff --git a/kexec/arch/x86_64/Makefile b/kexec/arch/x86_64/Makefile
index c3a4d4e..c59c41f 100644
--- a/kexec/arch/x86_64/Makefile
+++ b/kexec/arch/x86_64/Makefile
@@ -1,13 +1,17 @@
#
# kexec x86_64 (linux booting linux)
#
-KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
-KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
-KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
-KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
-KEXEC_SRCS += kexec/arch/x86_64/crashdump-x86_64.c
-KEXEC_SRCS += kexec/arch/x86_64/kexec-x86_64.c
-KEXEC_SRCS += kexec/arch/x86_64/kexec-elf-x86_64.c
-KEXEC_SRCS += kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+x86_64_KEXEC_SRCS = kexec/arch/i386/kexec-elf-x86.c
+x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
+x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
+x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
+x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
+x86_64_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
+x86_64_KEXEC_SRCS += kexec/arch/x86_64/crashdump-x86_64.c
+x86_64_KEXEC_SRCS += kexec/arch/x86_64/kexec-x86_64.c
+x86_64_KEXEC_SRCS += kexec/arch/x86_64/kexec-elf-x86_64.c
+x86_64_KEXEC_SRCS += kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+
+dist += kexec/arch/x86_64/Makefile $(x86_64_KEXEC_SRCS) \
+ kexec/arch/x86_64/kexec-x86_64.h kexec/arch/x86_64/crashdump-x86_64.h \
+ kexec/arch/x86_64/include/arch/options.h
diff --git a/kexec_test/Makefile b/kexec_test/Makefile
index 3f0d0fe..4848fc4 100644
--- a/kexec_test/Makefile
+++ b/kexec_test/Makefile
@@ -4,6 +4,19 @@
RELOC:=0x10000
KEXEC_TEST_SRCS:= kexec_test/kexec_test16.S kexec_test/kexec_test.S
+dist += kexec_test/Makefile $(KEXEC_TEST_SRCS) \
+ kexec_test/x86-setup-legacy-pic.S
+
+BUILD_KEXEC_TEST = no
+ifeq ($(ARCH),i386)
+BUILD_KEXEC_TEST = yes
+endif
+ifeq ($(ARCH),x86_64)
+BUILD_KEXEC_TEST = yes
+endif
+
+ifeq ($(BUILD_KEXEC_TEST),yes)
+
KEXEC_TEST_OBJS = $(call objify, $(KEXEC_TEST_SRCS))
KEXEC_TEST_DEPS = $(call depify, $(KEXEC_TEST_OBJS))
@@ -23,3 +36,5 @@ $(KEXEC_TEST): $(KEXEC_TEST_OBJS)
mkdir -p $(@D)
#$(LINK.o) -o $@ $^
$(LD) $(LDFLAGS) -o $@ $^
+
+endif
diff --git a/purgatory/Makefile b/purgatory/Makefile
index e7d2f15..9ffa522 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -13,7 +13,20 @@ PURGATORY_SRCS += purgatory/purgatory.c
PURGATORY_SRCS += purgatory/printf.c
PURGATORY_SRCS += purgatory/string.c
-include $(srcdir)/purgatory/arch/$(ARCH)/Makefile
+dist += purgatory/Makefile $(PURGATORY_SRCS) \
+ purgatory/include/purgatory.h purgatory/include/string.h
+
+include $(srcdir)/purgatory/arch/alpha/Makefile
+include $(srcdir)/purgatory/arch/arm/Makefile
+include $(srcdir)/purgatory/arch/i386/Makefile
+include $(srcdir)/purgatory/arch/ia64/Makefile
+include $(srcdir)/purgatory/arch/ppc/Makefile
+include $(srcdir)/purgatory/arch/ppc64/Makefile
+include $(srcdir)/purgatory/arch/s390/Makefile
+include $(srcdir)/purgatory/arch/sh/Makefile
+include $(srcdir)/purgatory/arch/x86_64/Makefile
+
+PURGATORY_SRCS+=$($(ARCH)_PURGATORY_SRCS)
PURGATORY_OBJS = $(call objify, $(PURGATORY_SRCS)) purgatory/sha256.o
PURGATORY_DEPS = $(call depify, $(PURGATORY_OBJS))
@@ -31,13 +44,16 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
$(COMPILE.c) -o $@ $^
$(PURGATORY): CC=$(TARGET_CC)
-$(PURGATORY): CFLAGS+=-Os -fno-builtin -ffreestanding \
+$(PURGATORY): CFLAGS+=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+ -Os -fno-builtin -ffreestanding \
-fno-zero-initialized-in-bss
-$(PURGATORY): CPPFLAGS+=-I$(srcdir)/purgatory/include \
+$(PURGATORY): CPPFLAGS+=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+ -I$(srcdir)/purgatory/include \
-I$(srcdir)/purgatory/arch/$(ARCH)/include \
-I$(shell $(CC) -print-file-name=include)
-$(PURGATORY): LDFLAGS+=--no-undefined -nostartfiles -nostdlib -nodefaultlibs \
+$(PURGATORY): LDFLAGS+=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
+ --no-undefined -nostartfiles -nostdlib -nodefaultlibs \
-e purgatory_start -r
$(PURGATORY): $(PURGATORY_OBJS)
diff --git a/purgatory/arch/alpha/Makefile b/purgatory/arch/alpha/Makefile
index 02f62b2..c58693f 100644
--- a/purgatory/arch/alpha/Makefile
+++ b/purgatory/arch/alpha/Makefile
@@ -2,5 +2,7 @@
# Purgatory alpha
#
-PURGATORY_SRCS +=
+alpha_PURGATORY_SRCS =
+
+dist += purgatory/arch/alpha/Makefile $(alpha_PURGATORY_SRCS)
diff --git a/purgatory/arch/arm/Makefile b/purgatory/arch/arm/Makefile
index 566ff42..690377e 100644
--- a/purgatory/arch/arm/Makefile
+++ b/purgatory/arch/arm/Makefile
@@ -2,5 +2,8 @@
# Purgatory arm
#
-PURGATORY_SRCS +=
+arm_PURGATORY_SRCS =
+
+dist += purgatory/arch/arm/Makefile $(arm_PURGATORY_SRCS)
+
diff --git a/purgatory/arch/i386/Makefile b/purgatory/arch/i386/Makefile
index 55cc7af..1532219 100644
--- a/purgatory/arch/i386/Makefile
+++ b/purgatory/arch/i386/Makefile
@@ -2,14 +2,20 @@
# Purgatory i386
#
-PURGATORY_SRCS += purgatory/arch/i386/entry32-16.S
-PURGATORY_SRCS += purgatory/arch/i386/entry32-16-debug.S
-PURGATORY_SRCS += purgatory/arch/i386/entry32.S
-PURGATORY_SRCS += purgatory/arch/i386/setup-x86.S
-PURGATORY_SRCS += purgatory/arch/i386/stack.S
-PURGATORY_SRCS += purgatory/arch/i386/compat_x86_64.S
-PURGATORY_SRCS += purgatory/arch/i386/purgatory-x86.c
-PURGATORY_SRCS += purgatory/arch/i386/console-x86.c
-PURGATORY_SRCS += purgatory/arch/i386/vga.c
-PURGATORY_SRCS += purgatory/arch/i386/pic.c
-PURGATORY_SRCS += purgatory/arch/i386/crashdump_backup.c
+i386_PURGATORY_SRCS = purgatory/arch/i386/entry32-16.S
+i386_PURGATORY_SRCS += purgatory/arch/i386/entry32-16-debug.S
+i386_PURGATORY_SRCS += purgatory/arch/i386/entry32.S
+i386_PURGATORY_SRCS += purgatory/arch/i386/setup-x86.S
+i386_PURGATORY_SRCS += purgatory/arch/i386/stack.S
+i386_PURGATORY_SRCS += purgatory/arch/i386/compat_x86_64.S
+i386_PURGATORY_SRCS += purgatory/arch/i386/purgatory-x86.c
+i386_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c
+i386_PURGATORY_SRCS += purgatory/arch/i386/vga.c
+i386_PURGATORY_SRCS += purgatory/arch/i386/pic.c
+i386_PURGATORY_SRCS += purgatory/arch/i386/crashdump_backup.c
+
+dist += purgatory/arch/i386/Makefile $(i386_PURGATORY_SRCS) \
+ purgatory/arch/i386/purgatory-x86.h \
+ purgatory/arch/i386/include/arch/io.h \
+ purgatory/arch/i386/include/arch/debug.h
+
diff --git a/purgatory/arch/ia64/Makefile b/purgatory/arch/ia64/Makefile
index 9dda91d..32c3d97 100644
--- a/purgatory/arch/ia64/Makefile
+++ b/purgatory/arch/ia64/Makefile
@@ -1,10 +1,13 @@
#
# Purgatory ia64
#
-PURGATORY_SRCS += purgatory/arch/ia64/entry.S
-PURGATORY_SRCS += purgatory/arch/ia64/purgatory-ia64.c
-PURGATORY_SRCS += purgatory/arch/ia64/console-ia64.c
-PURGATORY_SRCS += purgatory/arch/ia64/vga.c
+ia64_PURGATORY_SRCS += purgatory/arch/ia64/entry.S
+ia64_PURGATORY_SRCS += purgatory/arch/ia64/purgatory-ia64.c
+ia64_PURGATORY_SRCS += purgatory/arch/ia64/console-ia64.c
+ia64_PURGATORY_SRCS += purgatory/arch/ia64/vga.c
-$(PURGATORY): CFLAGS += -ffixed-r28
+ia64_PURGATORY_EXTRA_CFLAGS = -ffixed-r28
+
+dist += purgatory/arch/ia64/Makefile $(ia64_PURGATORY_SRCS) \
+ purgatory/arch/ia64/io.h purgatory/arch/ia64/purgatory-ia64.h
diff --git a/purgatory/arch/ppc/Makefile b/purgatory/arch/ppc/Makefile
index c40b4b5..69fd46c 100644
--- a/purgatory/arch/ppc/Makefile
+++ b/purgatory/arch/ppc/Makefile
@@ -2,7 +2,10 @@
# Purgatory ppc
#
-PURGATORY_SRCS += purgatory/arch/ppc/misc.S
-PURGATORY_SRCS += purgatory/arch/ppc/purgatory-ppc.c
-PURGATORY_SRCS += purgatory/arch/ppc/console-ppc.c
+ppc_PURGATORY_SRCS += purgatory/arch/ppc/misc.S
+ppc_PURGATORY_SRCS += purgatory/arch/ppc/purgatory-ppc.c
+ppc_PURGATORY_SRCS += purgatory/arch/ppc/console-ppc.c
+
+dist += purgatory/arch/ppc/Makefile $(ppc_PURGATORY_SRCS) \
+ purgatory/arch/ppc/purgatory-ppc.h purgatory/arch/ppc/ppc_asm.h
diff --git a/purgatory/arch/ppc64/Makefile b/purgatory/arch/ppc64/Makefile
index a62484e..aaa4046 100644
--- a/purgatory/arch/ppc64/Makefile
+++ b/purgatory/arch/ppc64/Makefile
@@ -1,12 +1,15 @@
#
-# Purgatory ppc
+# Purgatory ppc64
#
-PURGATORY_SRCS += purgatory/arch/ppc64/v2wrap.S
-PURGATORY_SRCS += purgatory/arch/ppc64/purgatory-ppc64.c
-PURGATORY_SRCS += purgatory/arch/ppc64/console-ppc64.c
-PURGATORY_SRCS += purgatory/arch/ppc64/crashdump_backup.c
+ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/v2wrap.S
+ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/purgatory-ppc64.c
+ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/console-ppc64.c
+ppc64_PURGATORY_SRCS += purgatory/arch/ppc64/crashdump_backup.c
-$(PURGATORY): CFLAGS += -m64 -mcall-aixdesc
-$(PURGATORY): ASFLAGS += -m64 -mcall-aixdesc
-$(PURGATORY): LDFLAGS += -melf64ppc
+ppc64_PURGATORY_EXTRA_CFLAGS += -m64 -mcall-aixdesc
+ppc64_PURGATORY_EXTRA_ASFLAGS += -m64 -mcall-aixdesc
+ppc64_PURGATORY_EXTRA_LDFLAGS += -melf64ppc
+
+dist += purgatory/arch/ppc64/Makefile $(ppc64_PURGATORY_SRCS) \
+ purgatory/arch/ppc64/purgatory-ppc64.h
diff --git a/purgatory/arch/s390/Makefile b/purgatory/arch/s390/Makefile
index 9c795d1..d5f3068 100644
--- a/purgatory/arch/s390/Makefile
+++ b/purgatory/arch/s390/Makefile
@@ -2,6 +2,7 @@
# Purgatory s390
#
-PURGATORY_SRCS +=
-PURGATORY_SRCS +=
+s390_PURGATORY_SRCS =
+
+dist += purgatory/arch/s390/Makefile $(s390_PURGATORY_SRCS)
diff --git a/purgatory/arch/sh/Makefile b/purgatory/arch/sh/Makefile
index 537d260..33ad4db 100644
--- a/purgatory/arch/sh/Makefile
+++ b/purgatory/arch/sh/Makefile
@@ -1,7 +1,8 @@
#
-# Purgatory alpha
+# Purgatory sh
#
-PURGATORY_SRCS +=
-PURGATORY_SRCS +=
+sh_PURGATORY_SRCS =
+
+dist += purgatory/arch/sh/Makefile $(sh_PURGATORY_SRCS)
diff --git a/purgatory/arch/x86_64/Makefile b/purgatory/arch/x86_64/Makefile
index e8fe96c..01fbbf3 100644
--- a/purgatory/arch/x86_64/Makefile
+++ b/purgatory/arch/x86_64/Makefile
@@ -2,14 +2,21 @@
# Purgatory x86_64
#
-PURGATORY_SRCS += purgatory/arch/i386/entry32-16.S
-PURGATORY_SRCS += purgatory/arch/i386/entry32-16-debug.S
-PURGATORY_SRCS += purgatory/arch/x86_64/entry64-32.S
-PURGATORY_SRCS += purgatory/arch/x86_64/entry64.S
-PURGATORY_SRCS += purgatory/arch/x86_64/setup-x86_64.S
-PURGATORY_SRCS += purgatory/arch/x86_64/stack.S
-PURGATORY_SRCS += purgatory/arch/x86_64/purgatory-x86_64.c
-PURGATORY_SRCS += purgatory/arch/i386/crashdump_backup.c
-PURGATORY_SRCS += purgatory/arch/i386/console-x86.c
-PURGATORY_SRCS += purgatory/arch/i386/vga.c
-PURGATORY_SRCS += purgatory/arch/i386/pic.c
+x86_64_PURGATORY_SRCS += purgatory/arch/x86_64/entry64-32.S
+x86_64_PURGATORY_SRCS += purgatory/arch/x86_64/entry64.S
+x86_64_PURGATORY_SRCS += purgatory/arch/x86_64/setup-x86_64.S
+x86_64_PURGATORY_SRCS += purgatory/arch/x86_64/stack.S
+x86_64_PURGATORY_SRCS += purgatory/arch/x86_64/purgatory-x86_64.c
+
+dist += purgatory/arch/x86_64/Makefile $(x86_64_PURGATORY_SRCS) \
+ purgatory/arch/x86_64/include/arch/io.h \
+ purgatory/arch/x86_64/include/arch/debug.h \
+ purgatory/arch/x86_64/purgatory-x86_64.h
+
+# Done add sources in i386/ to dist, as i386/Makefile adds them
+x86_64_PURGATORY_SRCS = purgatory/arch/i386/entry32-16.S
+x86_64_PURGATORY_SRCS += purgatory/arch/i386/entry32-16-debug.S
+x86_64_PURGATORY_SRCS += purgatory/arch/i386/crashdump_backup.c
+x86_64_PURGATORY_SRCS += purgatory/arch/i386/console-x86.c
+x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c
+x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c
diff --git a/util/Makefile b/util/Makefile
index 6fee925..89732a1 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -7,4 +7,5 @@ $(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
$(BIN_TO_HEX): CC=$(BUILD_CC)
$(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS)
+dist += util/Makefile util/bin-to-hex.c
clean += util/bin-to-hex.o $(BIN_TO_HEX)
diff --git a/util_lib/Makefile b/util_lib/Makefile
index 5b4bd22..54ccdc5 100644
--- a/util_lib/Makefile
+++ b/util_lib/Makefile
@@ -10,6 +10,8 @@ UTIL_LIB = libutil.a
-include $(UTIL_LIB_DEPS)
+dist += util_lib/Makefile $(UTIL_LIB_SRCS) \
+ util_lib/include/sha256.h util_lib/include/ip_checksum.h
clean += $(UTIL_LIB_OBJS) $(UTIL_LIB_DEPS) $(UTIL_LIB)
$(UTIL_LIB): CPPFLAGS += -I$(srcdir)/util_lib/include