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