xref: /openbmc/qemu/pc-bios/s390-ccw/Makefile (revision de799beb)
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
9quiet-command = $(if $(V),$1,$(if $(2),@printf "  %-7s %s\n" $2 $3 && $1, @$1))
10cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
11			 >/dev/null 2>&1 && echo OK),$2,$3)
12
13VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in
14set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
15$(call set-vpath, $(SRC_PATH))
16
17# Flags for dependency generation
18QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d
19
20%.o: %.c
21	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
22	       -c -o $@ $<,"CC","$(TARGET_DIR)$@")
23
24%.o: %.S
25	$(call quiet-command,$(CCAS) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
26	       -c -o $@ $<,"CCAS","$(TARGET_DIR)$@")
27
28.PHONY : all clean build-all
29
30OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
31	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
32
33QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS))
34QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow)
35QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
36QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
37QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
38QEMU_CFLAGS += -msoft-float
39QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),-march=z900,-march=z10)
40QEMU_CFLAGS += -std=gnu99
41LDFLAGS += -Wl,-pie -nostdlib
42
43build-all: s390-ccw.img s390-netboot.img
44
45s390-ccw.elf: $(OBJECTS)
46	$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"BUILD","$(TARGET_DIR)$@")
47
48s390-ccw.img: s390-ccw.elf
49	$(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,"STRIP","$(TARGET_DIR)$@")
50
51$(OBJECTS): Makefile
52
53ifneq ($(wildcard $(SRC_PATH)/../../roms/SLOF/lib/libnet),)
54include $(SRC_PATH)/netboot.mak
55else
56s390-netboot.img:
57	@echo "s390-netboot.img not built since roms/SLOF/ is not available."
58endif
59
60ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS))
61-include $(ALL_OBJS:%.o=%.d)
62
63clean:
64	rm -f *.o *.d *.img *.elf *~ *.a
65