summaryrefslogtreecommitdiffstats
path: root/purgatory
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2007-12-13 16:18:53 +0900
committerSimon Horman <horms@verge.net.au>2007-12-19 14:50:07 +0900
commitadf85cbc1756e56c1f52f56235a3c08b3c5b8e05 (patch)
tree480e2d89501d7e51f3c7abf3291930932c3a3371 /purgatory
parentac12ceecf15f637e024e6be9a030497e732a74eb (diff)
downloadkexec-tools-adf85cbc1756e56c1f52f56235a3c08b3c5b8e05.tar.gz
Build system simplification/standardisation
This change makes kexec-tools work more like a standard configure-make- make-install-type project: * Remove $(OBJDIR) stuff. To do an out-of-tree build, just configure from a different directory. * Use the implicit Makefile rules more, and just edit the compiler flags for specific targets. * Simplify compiler/linker flags - no need for EXTRA_* * Add TARGET_CC, and improve checks for BUILD_CC too. * Set arch-specific flags in arch-specific makefiles, not conditional on $(ARCH). * Generate dependency files in the main compile, rather than as a separate step. * Don't #include sha256.c, but re-build it into the purgatory. Still a work-in-progress. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'purgatory')
-rw-r--r--purgatory/Makefile63
-rw-r--r--purgatory/arch/ia64/Makefile3
-rw-r--r--purgatory/arch/ppc64/Makefile6
-rw-r--r--purgatory/include/string.h2
-rw-r--r--purgatory/purgatory.c4
5 files changed, 35 insertions, 43 deletions
diff --git a/purgatory/Makefile b/purgatory/Makefile
index adbd8148..35fd473b 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -7,59 +7,48 @@
# should keep us from accidentially include unsafe library functions
# or headers.
-ifeq ($(ARCH),ppc64)
-EXTRA_LDFLAGS = -melf64ppc
-endif
-
-PCFLAGS:=-Wall -Os \
- -I$(shell $(CC) -print-file-name=include) \
- -Ipurgatory/include -Ipurgatory/arch/$(ARCH)/include \
- $(CPPFLAGS) $(EXTRA_CPPFLAGS)
-
-PCFLAGS += $(call cc-option, -ffreestanding)
-PCFLAGS += $(call cc-option, -fnobuiltin)
-PCFLAGS += $(call cc-option, -fnostdinc)
-PCFLAGS += $(call cc-option, -fno-zero-initialized-in-bss)
-
PURGATORY_C_SRCS:=
PURGATORY_C_SRCS += purgatory/purgatory.c
PURGATORY_C_SRCS += purgatory/printf.c
PURGATORY_C_SRCS += purgatory/string.c
PURGATORY_S_OBJS:=
+PURGATORY:= purgatory/purgatory.ro
-include purgatory/arch/$(ARCH)/Makefile
+include $(srcdir)/purgatory/arch/$(ARCH)/Makefile
-
-PURGATORY_C_OBJS:= $(patsubst %.c, $(OBJDIR)/%.o, $(PURGATORY_C_SRCS))
-PURGATORY_C_DEPS:= $(patsubst %.c, $(OBJDIR)/%.d, $(PURGATORY_C_SRCS))
-PURGATORY_S_OBJS:= $(patsubst %.S, $(OBJDIR)/%.o, $(PURGATORY_S_SRCS))
-PURGATORY_S_DEPS:= $(patsubst %.S, $(OBJDIR)/%.d, $(PURGATORY_S_SRCS))
+PURGATORY_C_OBJS:= $(patsubst %.c, %.o, $(PURGATORY_C_SRCS))
+PURGATORY_C_DEPS:= $(patsubst %.c, %.d, $(PURGATORY_C_SRCS))
+PURGATORY_S_OBJS:= $(patsubst %.S, %.o, $(PURGATORY_S_SRCS))
+PURGATORY_S_DEPS:= $(patsubst %.S, %.d, $(PURGATORY_S_SRCS))
PURGATORY_SRCS:= $(PURGATORY_S_SRCS) $(PURGATORY_C_SRCS)
-PURGATORY_OBJS:= $(PURGATORY_S_OBJS) $(PURGATORY_C_OBJS)
+PURGATORY_OBJS:= $(PURGATORY_S_OBJS) $(PURGATORY_C_OBJS) purgatory/sha256.o
PURGATORY_DEPS:= $(PURGATORY_S_DEPS) $(PURGATORY_C_DEPS)
-PURGATORY:= $(OBJDIR)/purgatory/purgatory.ro
-include $(PURGATORY_DEPS)
+-include $(PURGATORY_DEPS)
-$(PURGATORY_C_DEPS): $(OBJDIR)/%.d: %.c
- $(MKDIR) -p $(@D)
- $(CC) $(PCFLAGS) -M $< | sed -e 's|$(patsubst %.d,%.o,$(@F))|$(patsubst %.d,%.o,$(@))|' > $@
+# sha256.c needs to be compiled without optimization, else
+# purgatory fails to execute on ia64.
+purgatory/sha256.o: CFLAGS += -O0
-$(PURGATORY_S_DEPS): $(OBJDIR)/%.d: %.S
- $(MKDIR) -p $(@D)
- $(CC) $(PCFLAGS) -M $< | sed -e 's|$(patsubst %.d,%.o,$(@F))|$(patsubst %.d,%.o,$(@))|' > $@
+purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
+ mkdir -p $(@D)
+ $(COMPILE.c) -o $@ $^
-$(PURGATORY_C_OBJS): $(OBJDIR)/%.o: %.c $(OBJDIR)/%.d
- $(MKDIR) -p $(@D)
- $(CC) $(PCFLAGS) -o $@ -c $<
+$(PURGATORY): CC=$(TARGET_CC)
+$(PURGATORY): CFLAGS+=-Os -fno-builtin -ffreestanding \
+ -fno-zero-initialized-in-bss
-$(PURGATORY_S_OBJS): $(OBJDIR)/%.o: %.S $(OBJDIR)/%.d
- $(MKDIR) -p $(@D)
- $(CC) $(PCFLAGS) -o $@ -c $<
+$(PURGATORY): CPPFLAGS+=-I$(srcdir)/purgatory/include \
+ -I$(srcdir)/purgatory/arch/$(ARCH)/include \
+ -I$(shell $(CC) -print-file-name=include)
+$(PURGATORY): LDFLAGS+=--no-undefined -nostartfiles -nostdlib -nodefaultlibs \
+ -e purgatory_start -r
-$(PURGATORY): $(PURGATORY_OBJS) $(UTIL_LIB)
+$(PURGATORY): $(PURGATORY_OBJS)
$(MKDIR) -p $(@D)
- $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
+ $(LD) $(LDFLAGS) -o $@ $^
+
+# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
echo::
@echo "PURGATORY_C_SRCS $(PURGATORY_C_SRCS)"
diff --git a/purgatory/arch/ia64/Makefile b/purgatory/arch/ia64/Makefile
index 953b3ee7..12d9f75a 100644
--- a/purgatory/arch/ia64/Makefile
+++ b/purgatory/arch/ia64/Makefile
@@ -1,9 +1,10 @@
#
# Purgatory ia64
#
-PCFLAGS += -ffixed-r28
PURGATORY_S_SRCS+= purgatory/arch/ia64/entry.S
PURGATORY_C_SRCS+= purgatory/arch/ia64/purgatory-ia64.c
PURGATORY_C_SRCS+= purgatory/arch/ia64/console-ia64.c
PURGATORY_C_SRCS+= purgatory/arch/ia64/vga.c
+$(PURGATORY): CFLAGS += -ffixed-r28
+
diff --git a/purgatory/arch/ppc64/Makefile b/purgatory/arch/ppc64/Makefile
index 0406278d..792a0b35 100644
--- a/purgatory/arch/ppc64/Makefile
+++ b/purgatory/arch/ppc64/Makefile
@@ -2,9 +2,11 @@
# Purgatory ppc
#
-PURGATORY_S_SRCS+= purgatory/arch/ppc64/v2wrap.S
+PURGATORY_S_SRCS += purgatory/arch/ppc64/v2wrap.S
PURGATORY_C_SRCS += purgatory/arch/ppc64/purgatory-ppc64.c
PURGATORY_C_SRCS += purgatory/arch/ppc64/console-ppc64.c
PURGATORY_C_SRCS += purgatory/arch/ppc64/crashdump_backup.c
-PCFLAGS += -m64 -mcall-aixdesc
+$(PURGATORY): CFLAGS += -m64 -mcall-aixdesc
+$(PURGATORY): ASFLAGS += -m64 -mcall-aixdesc
+$(PURGATORY): LDFLAGS += -melf64ppc
diff --git a/purgatory/include/string.h b/purgatory/include/string.h
index 87cc4e1c..14e172de 100644
--- a/purgatory/include/string.h
+++ b/purgatory/include/string.h
@@ -1,6 +1,8 @@
#ifndef STRING_H
#define STRING_H
+#include <stddef.h>
+
size_t strnlen(const char *s, size_t max);
void* memset(void* s, int c, size_t n);
void* memcpy(void *dest, const void *src, size_t len);
diff --git a/purgatory/purgatory.c b/purgatory/purgatory.c
index aacbb3b9..3889cf5b 100644
--- a/purgatory/purgatory.c
+++ b/purgatory/purgatory.c
@@ -1,4 +1,4 @@
-#include <stdarg.h>
+
#include <limits.h>
#include <stdint.h>
#include <purgatory.h>
@@ -46,5 +46,3 @@ void purgatory(void)
verify_sha256_digest();
post_verification_setup_arch();
}
-
-#include "../util_lib/sha256.c"