xref: /openbmc/qemu/pc-bios/s390-ccw/Makefile (revision 41bfb670)
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 -z noexecstack
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
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
68include $(SRC_PATH)/netboot.mak
69
70ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS))
71-include $(ALL_OBJS:%.o=%.d)
72
73clean:
74	rm -f *.o *.d *.img *.elf *~ *.a
75
76distclean:
77	rm -f config-cc.mak
78
79.PHONY: git-submodule-update
80$(SRC_PATH)/../../.git-submodule-status: git-submodule-update config-host.mak
81Makefile: $(SRC_PATH)/../../.git-submodule-status
82
83git-submodule-update:
84ifneq ($(GIT_SUBMODULES_ACTION),ignore)
85	$(quiet-@)GIT=git "$(SRC_PATH)/../../scripts/git-submodule.sh" $(GIT_SUBMODULES_ACTION) $(GIT_SUBMODULES)
86endif
87