1all: build-all 2# Dummy command so that make thinks it has done something 3 @true 4 5include config-host.mak 6CFLAGS = -O2 -g 7MAKEFLAGS += -rR 8 9NULL := 10SPACE := $(NULL) # 11TARGET_PREFIX := $(patsubst %/,%:$(SPACE),$(TARGET_DIR)) 12 13quiet-@ = $(if $(V),,@$(if $1,printf "%s\n" "$(TARGET_PREFIX)$1" && )) 14quiet-command = $(call quiet-@,$2 $@)$1 15 16VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in 17set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) 18$(call set-vpath, $(SRC_PATH)) 19 20# Flags for dependency generation 21QEMU_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 33OBJECTS = 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 36EXTRA_CFLAGS += -Wall 37EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE 38EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables 39EXTRA_CFLAGS += -msoft-float 40EXTRA_CFLAGS += -std=gnu99 41LDFLAGS += -Wl,-pie -nostdlib 42 43cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null 44cc-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 48config-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 56LDFLAGS += -Wl,-pie -nostdlib 57 58build-all: s390-ccw.img s390-netboot.img 59 60s390-ccw.elf: $(OBJECTS) 61 $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),Linking) 62 63s390-ccw.img: s390-ccw.elf 64 $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,Stripping $< into) 65 66$(OBJECTS): Makefile 67 68ifneq ($(wildcard $(SRC_PATH)/../../roms/SLOF/lib/libnet),) 69include $(SRC_PATH)/netboot.mak 70else 71s390-netboot.img: 72 @echo "s390-netboot.img not built since roms/SLOF/ is not available." 73endif 74 75ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS)) 76-include $(ALL_OBJS:%.o=%.d) 77 78clean: 79 rm -f *.o *.d *.img *.elf *~ *.a 80 81distclean: 82 rm -f config-cc.mak 83