diff options
Diffstat (limited to 'Makefile.main')
-rw-r--r-- | Makefile.main | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/Makefile.main b/Makefile.main new file mode 100644 index 0000000..884c0c2 --- /dev/null +++ b/Makefile.main @@ -0,0 +1,154 @@ +# -*-Makefile-*- +# +# This is the main Makefile + +# Target tools +CC=$(CROSS)gcc$(POSTFIX) +LD=$(CROSS)ld$(POSTFIX) +AS=$(CROSS)as +AR=$(CROSS)ar +NM=$(CROSS)nm +OBJCOPY=$(CROSS)objcopy +OBJDUMP=$(CROSS)objdump +SIZE=$(CROSS)size +LD_TEXT=0x0 +NM += --synthetic + +# Base warnings +CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -Werror-implicit-function-declaration -Wdeclaration-after-statement \ + -Wno-pointer-sign -Wextra -Wno-sign-compare \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wwrite-strings -Wcast-align -Wjump-misses-init \ + -Winit-self \ + -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn \ + -Wframe-larger-than=2048 \ + -Wstack-usage=4096 + +# Host tools and options +HOSTCC=gcc +HOSTEND=$(shell uname -m | sed -e 's/^i.*86$$/LITTLE/' -e 's/^x86.*/LITTLE/' -e 's/^ppc.*/BIG/') +HOSTCFLAGS=-O1 $(CWARNS) -DHAVE_$(HOSTEND)_ENDIAN +VALGRIND=valgrind -q --show-reachable=yes --error-exitcode=99 + +# Target options + +OPTS=-Os -ffunction-sections +DBG=-g + +CPPFLAGS := -I$(SRC)/include -Iinclude -MMD -include $(SRC)/include/config.h +CPPFLAGS += -I$(SRC)/libfdt -I$(SRC)/libflash -I$(SRC)/libc/include -I$(SRC) +ifeq ($(PORE),1) +CPPFLAGS += -I$(SRC)/libpore -D__HAVE_LIBPORE__ +endif +CPPFLAGS += -D__SKIBOOT__ -nostdinc +CPPFLAGS += -isystem $(shell $(CC) -print-file-name=include) +CPPFLAGS += -DBITS_PER_LONG=64 -m64 -DHAVE_BIG_ENDIAN +# Ideally we want -ffreestanding and remove our copy of stdint.h +# but that means uint64_t becomes an ulong instead of an ullong +# causing all our printf's to warn ... so leave that alone for now +#CPPFLAGS += -ffreestanding + +CFLAGS := -fno-strict-aliasing -fno-stack-protector -pie +CFLAGS += $(CWARNS) $(OPTS) $(DBG) + +LDFLAGS := -m64 -static -nostdlib -Wl,--gc-sections -pie +LDFLAGS += -Wl,-Ttext-segment,$(LD_TEXT) -Wl,-N -Wl,--build-id=none +LDFLAGS += -Wl,--no-multi-toc +LDRFLAGS=-melf64ppc +# Debug stuff +#LDFLAGS += -Wl,-v -Wl,-Map,foomap + +AFLAGS := -D__ASSEMBLY__ + +# Special tool flags: +# Do not use the floating point unit +CFLAGS += -msoft-float +# Do not use string instructions +CFLAGS += -mno-string +# do not use load/store multiple word instrcutions +CFLAGS += -mno-multiple +# Do not use load/store update. You REALLY do not want to use this! +# The async safety of the ABI stack depends on the atomicity +# of update on store. +#CFLAGS += -mno-update + +ifneq ($(KERNEL),) +CPPFLAGS += -DBUILTIN_KERNEL="$(KERNEL)" +endif + +.SECONDARY: + +vpath %.c $(SRC) +vpath %.S $(SRC) + +default: all + +include/asm-offsets.h: asm/asm-offsets.s + @mkdir -p include + $(call Q,GN, $(SRC)/make_offsets.sh $< >$@, $@) + +TARGET = skiboot + +include $(SRC)/asm/Makefile.inc +include $(SRC)/core/Makefile.inc +include $(SRC)/hw/Makefile.inc +include $(SRC)/platforms/Makefile.inc +include $(SRC)/libfdt/Makefile.inc +include $(SRC)/libflash/Makefile.inc +include $(SRC)/libpore/Makefile.inc +include $(SRC)/libc/Makefile.inc +include $(SRC)/ccan/Makefile.inc +include $(SRC)/$(DEVSRC)/Makefile.inc + +all: $(SUBDIRS) $(TARGET).lid $(TARGET).map + +OBJS := $(ASM) $(CORE) $(HW) $(PLATFORMS) $(LIBFDT) $(LIBFLASH) +ifeq ($(PORE),1) +OBJS += $(LIBPORE) +endif +OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) gitid.o + +$(TARGET).lid: $(TARGET).elf + $(OBJCOPY) -O binary -S $^ $@ + +$(TARGET).elf: $(OBJS) $(TARGET).lds $(KERNEL) + $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(OBJS) -o $@, $@) + +$(TARGET).map: $(TARGET).elf + $(call Q,NM, $(NM) -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@) + +$(SUBDIRS): + $(call Q,MKDIR,mkdir $@, $@) + +-include $(wildcard *.d) +-include $(wildcard $(SUBDIRS:%=%/*.d)) + +# Set V=1 if you want to see everything. +include $(SRC)/Makefile.rules + +gitid.c: + @echo "const char gitid[] = \"`cd $(SRC); git describe --always --dirty`\";" > $@ + +include $(shell find $(SRC)/* -name Makefile.check) + +tags: + find . -name '*.[chS]' | xargs ctags + +TAGS: + find . -name '*.[chS]' | xargs etags + +.PHONY: tags TAGS check gitid.c + +cscope: + find . -name '*.[chS]' | xargs cscope + +clean: + $(RM) *.[odsa] $(SUBDIRS:%=%/*.[odsa]) + $(RM) $(TARGET).elf $(TARGET).lid $(TARGET).map $(TARGET).lds + $(RM) include/asm-offsets.h gitid.c + +distclean: clean + $(RM) *~ $(SUBDIRS:%=%/*~) include/*~ + |