Makefile (2512B)
1 all: build-all 2 # Dummy command so that make thinks it has done something 3 @true 4 5 include config-host.mak 6 CFLAGS = -O2 -g 7 MAKEFLAGS += -rR 8 9 NULL := 10 SPACE := $(NULL) # 11 TARGET_PREFIX := $(patsubst %/,%:$(SPACE),$(TARGET_DIR)) 12 13 quiet-@ = $(if $(V),,@$(if $1,printf "%s\n" "$(TARGET_PREFIX)$1" && )) 14 quiet-command = $(call quiet-@,$2 $@)$1 15 16 VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in 17 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) 18 $(call set-vpath, $(SRC_PATH)) 19 20 # Flags for dependency generation 21 QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d 22 23 %.o: %.c 24 $(call quiet-command,$(CC) $(EXTRA_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \ 25 -c -o $@ $<,Compiling) 26 27 %.o: %.S 28 $(call quiet-command,$(CCAS) $(EXTRA_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \ 29 -c -o $@ $<,Assembling) 30 31 .PHONY : all clean build-all distclean 32 33 OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ 34 virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o 35 36 EXTRA_CFLAGS += -Wall 37 EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE 38 EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables 39 EXTRA_CFLAGS += -msoft-float 40 EXTRA_CFLAGS += -std=gnu99 41 LDFLAGS += -Wl,-pie -nostdlib 42 43 cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null 44 cc-option = if $(call cc-test, $1); then \ 45 echo "$(TARGET_PREFIX)$1 detected" && echo "EXTRA_CFLAGS += $1" >&3; else \ 46 echo "$(TARGET_PREFIX)$1 not detected" $(if $2,&& echo "EXTRA_CFLAGS += $2" >&3); fi 47 48 config-cc.mak: Makefile 49 $(quiet-@)($(call cc-option,-Wno-stringop-overflow); \ 50 $(call cc-option,-fno-stack-protector); \ 51 $(call cc-option,-Wno-array-bounds); \ 52 $(call cc-option,-Wno-gnu); \ 53 $(call cc-option,-march=z900,-march=z10)) 3> config-cc.mak 54 -include config-cc.mak 55 56 LDFLAGS += -Wl,-pie -nostdlib 57 58 build-all: s390-ccw.img s390-netboot.img 59 60 s390-ccw.elf: $(OBJECTS) 61 $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),Linking) 62 63 s390-ccw.img: s390-ccw.elf 64 $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,Stripping $< into) 65 66 $(OBJECTS): Makefile 67 68 ifneq ($(wildcard $(SRC_PATH)/../../roms/SLOF/lib/libnet),) 69 include $(SRC_PATH)/netboot.mak 70 else 71 s390-netboot.img: 72 @echo "s390-netboot.img not built since roms/SLOF/ is not available." 73 endif 74 75 ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS)) 76 -include $(ALL_OBJS:%.o=%.d) 77 78 clean: 79 rm -f *.o *.d *.img *.elf *~ *.a 80 81 distclean: 82 rm -f config-cc.mak