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