From: Scott Wood Date: Sat, 18 Feb 2012 20:56:36 +0000 (-0600) Subject: makefile: introduce target flags (TFLAGS) X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=commitdiff_plain;h=cbc65abe11c50aed3d5e7be7d1e736d5ced4f4e8 makefile: introduce target flags (TFLAGS) set -m32/-m64 as appropriate also add some missing $(V) Signed-off-by: Scott Wood --- diff --git a/Makefile.head b/Makefile.head index e366517..03d0832 100644 --- a/Makefile.head +++ b/Makefile.head @@ -49,19 +49,22 @@ CINCS += -I$(TOP)/include/c -I$(TOP)/include/c/std \ WARN += -Wall -Werror OPT += -O2 DEBUG += -g3 -ABI += -freg-struct-return +TFLAGS += -freg-struct-return # Target and ABI flags ifeq ($(V),) V := @ else override V := endif -CXXFLAGS += $(DEFS) $(CXXINCS) $(CXXWARN) $(OPT) $(DEBUG) $(ABI) +CXXFLAGS += $(DEFS) $(CXXINCS) $(CXXWARN) $(OPT) $(DEBUG) $(TFLAGS) BUILDCXXFLAGS += $(BUILDDEFS) $(CXXWARN) $(OPT) $(DEBUG) -CFLAGS += $(CINCS) $(DEFS) $(CWARN) $(OPT) $(DEBUG) $(ABI) +CFLAGS += $(CINCS) $(DEFS) $(CWARN) $(OPT) $(DEBUG) $(TFLAGS) BUILDCFLAGS += $(BUILDDEFS) $(CWARN) $(OPT) $(DEBUG) +ASFLAGS += $(TFLAGS) +LDFLAGS += $(TFLAGS) + .PHONY: all default rerun dep servers clean distclean .SUFFIXES: diff --git a/Makefile.target b/Makefile.target index 19c773c..0c09d33 100644 --- a/Makefile.target +++ b/Makefile.target @@ -11,12 +11,14 @@ DEFS := $(EXTRADEFS) ifeq ($(ARCH),x86) CROSS := i686-polintos- DEFS += -DBITFIELD_LE -D__LITTLE_ENDIAN +TFLAGS += -m32 VALIDARCH := yes endif ifeq ($(ARCH),x64) CROSS := x86_64-polintos- DEFS += -DBITFIELD_LE -D__LITTLE_ENDIAN +TFLAGS += -m64 VALIDARCH := yes endif diff --git a/kernel/arch/x64/Makefile.final b/kernel/arch/x64/Makefile.final index 709adf0..6f848da 100644 --- a/kernel/arch/x64/Makefile.final +++ b/kernel/arch/x64/Makefile.final @@ -3,9 +3,9 @@ CXXFLAGS += -mno-red-zone -mcmodel=kernel -fno-omit-frame-pointer $(BUILDDIR)/kernel: $(OBJS) $(DIR)linker-script @echo $(COMP): Linking kernel: $@ - @$(MKDIR) $(dir $@) - @$(LD) $(OBJS) -o "$@" -T$(DIR)linker-script + $(V)$(MKDIR) $(dir $@) + $(V)$(LD) $(LDFLAGS) $(OBJS) -o "$@" -T$(DIR)linker-script $(BUILDDIR)/kernel.stripped: $(BUILDDIR)/kernel @echo $(COMP): Stripping kernel: $@ - @$(STRIP) $(BUILDDIR)/kernel -o "$@" + $(V)$(STRIP) $(BUILDDIR)/kernel -o "$@" diff --git a/kernel/arch/x86/Makefile.final b/kernel/arch/x86/Makefile.final index 090c11d..93aa5ed 100644 --- a/kernel/arch/x86/Makefile.final +++ b/kernel/arch/x86/Makefile.final @@ -2,8 +2,9 @@ DIR := arch/x86/ $(BUILDDIR)/kernel: $(OBJS) $(LIBS) $(DIR)linker-script @echo $(COMP): Linking kernel: $@ - @$(MKDIR) $(dir $@) - @$(CXX) $(OBJS) $(LIBS) -lgcc -lsupc++ -nostdlib -o "$@" -Wl,-T$(DIR)linker-script + $(V)$(MKDIR) $(dir $@) + $(V)$(CXX) $(LDFLAGS) $(OBJS) $(LIBS) -lgcc -lsupc++ \ + -nostdlib -o "$@" -Wl,-T$(DIR)linker-script # GRUB refuses to use the addresses in the multiboot header if it # finds a valid ELF header, so the dd hacks a zero into the high byte @@ -14,6 +15,6 @@ $(BUILDDIR)/kernel: $(OBJS) $(LIBS) $(DIR)linker-script $(BUILDDIR)/kernel.stripped: $(BUILDDIR)/kernel @echo $(COMP): Stripping kernel: $@ - @$(STRIP) $(BUILDDIR)/kernel -o "$@" - @dd if=/dev/zero of=$(BUILDDIR)/kernel.stripped conv=notrunc \ - bs=1 count=1 seek=67 + $(V)$(STRIP) $(BUILDDIR)/kernel -o "$@" + $(V)dd if=/dev/zero of=$(BUILDDIR)/kernel.stripped conv=notrunc \ + bs=1 count=1 seek=67