forked from ibm-s390-linux/s390-tools
/
Makefile
109 lines (95 loc) · 3.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Common definitions
include ../../common.mak
CFLAGS_BOOT = $(NO_PIE_CFLAGS) -Os -g -I../include -D__ASSEMBLY__ \
-DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
-fno-delete-null-pointer-checks \
-fexec-charset=IBM1047 -m64 -mpacked-stack \
-mstack-size=8192 -mstack-guard=128 -msoft-float \
-W -Wall -Wformat-security
FILES = fba0.bin fba1b.bin fba2.bin \
eckd0_ldl.bin eckd0_cdl.bin \
eckd1.bin eckd1b.bin eckd2.bin \
tape0.bin \
eckd2dump_sv.bin tape2dump.bin fba2dump.bin eckd2dump_mv.bin
all: data.o data.h tape0.bin stage3.bin
# Prevent make from using some default rules...
%: %.S
%.o: %.S
$(CC) $(CFLAGS_BOOT) -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS_BOOT) -c -o $@ $<
eckd2dump_sv.exec: \
head.o stage2dump.o cio.o eckd2dump.o eckd2dump_sv.o \
libc.o sclp.o entry.o
eckd2dump_mv.exec: \
head.o stage2dump.o cio.o eckd2dump.o eckd2dump_mv.o \
libc.o sclp.o entry.o
fba2dump.exec: \
head.o stage2dump.o cio.o fba2dump.o \
libc.o sclp.o entry.o
tape2dump.exec: \
head.o stage2dump.o cio.o tape2dump.o \
libc.o sclp.o entry.o
eckd2.exec: head.o stage2.o cio.o eckd2.o libc.o menu.o sclp.o \
kdump2.o kdump.o entry.o
fba2.exec: head.o stage2.o cio.o fba2.o libc.o menu.o sclp.o \
kdump2.o kdump.o entry.o
stage3.exec: head.o stage3.o kdump3.o libc.o sclp.o sclp_stage3.o \
kdump.o entry.o stage3.lds
%.exec: %.o
@STAGE=$$( \
echo $@ | awk ' \
match($$0,/[0-9]+b*/){ \
print substr($$0,RSTART,RLENGTH) \
}' \
); \
case $$STAGE in \
0) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-Ttext,0";; \
1) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-Ttext,0x18";; \
1b) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-Ttext,0xE000";; \
2) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage2.lds";; \
3) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage3.lds";; \
esac; \
$(LINK) $$SFLAGS -m64 $^ -o $@
%.bin: %.exec
$(OBJCOPY) -O binary \
--only-section=.stage2.head \
--only-section=.text.dummy \
--only-section=.text.start \
--only-section=.text \
--only-section=.ex_table \
--only-section=.data \
--only-section=.rodata.str1.2 \
--only-section=.rodata.cst8 \
--only-section=.rodata \
--only-section=.stage2dump.tail \
--only-section=.eckd2dump_mv.tail \
--only-section=.fixup \
$< $@
stage3.bin: stage3.exec
$(OBJCOPY) -O binary \
--only-section=.stage2.head \
--only-section=.text.dummy \
--only-section=.text.start \
--only-section=.text \
--only-section=.ex_table \
--only-section=.data \
--only-section=.rodata.str1.2 \
--only-section=.rodata.cst8 \
--only-section=.rodata \
--only-section=.stage2dump.tail \
--only-section=.eckd2dump_mv.tail \
--only-section=.fixup \
--pad-to=0xf000 \
$< $@
data.o: $(FILES)
$(LD) $(NO_PIE_LDFLAGS) -r -b binary -o data.o $(FILES)
data.h: data.o
rm -f data.h
$(NM) data.o | while read ADDR TYPE SYMBOL ; do \
echo "extern char $$SYMBOL;" >>data.h; done
clean:
rm -f *.o *.exec *.bin $(FILES) data.o data.h tape0.bin *.xxx *.yyy \
stage3.bin
.PHONY: all clean