-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
93 lines (75 loc) · 2.55 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
CROSS=xenon-
CC=$(CROSS)gcc
OBJCOPY=$(CROSS)objcopy
LD=$(CROSS)ld
AS=$(CROSS)as
STRIP=$(CROSS)strip
LV1_DIR=source/lv1
GITREV='$(shell git describe --tags)'
# Configuration
CFLAGS = -Wall -Os -I$(LV1_DIR) -ffunction-sections -fdata-sections \
-m64 -mno-toc -DBYTE_ORDER=BIG_ENDIAN -mno-altivec -D$(CURRENT_TARGET) $(CYGNOS_DEF)
AFLAGS = -Iinclude -m64
LDFLAGS = -nostdlib -n -m64 -Wl,--gc-sections
OBJS = $(LV1_DIR)/startup.o \
$(LV1_DIR)/main.o \
$(LV1_DIR)/cache.o \
$(LV1_DIR)/ctype.o \
$(LV1_DIR)/string.o \
$(LV1_DIR)/time.o \
$(LV1_DIR)/vsprintf.o \
$(LV1_DIR)/puff/puff.o
TARGETS = xell-1f xell-2f xell-gggggg xell-gggggg_cygnos_demon xell-1f_cygnos_demon xell-2f_cygnos_demon
# Build rules
all: $(foreach name,$(TARGETS),$(addprefix $(name).,build))
.PHONY: clean %.build
clean:
@echo Cleaning...
@$(MAKE) --no-print-directory -f Makefile_lv2.mk clean
@rm -rf $(OBJS) $(foreach name,$(TARGETS),$(addprefix $(name).,bin elf)) stage2.elf32.gz stage2.elf32.7z
dist: clean all
@rm -rf XeLL_Reloaded-2stages-*.tar.gz
@mkdir -p release/_DEBUG
@cp *.bin release/
@gunzip *.gz
@cp stage2.elf release/_DEBUG
@cp stage2.elf32 release/
@cp AUTHORS release/
@cp CHANGELOG release/
@cp README release/
@cd release; tar czvf XeLL_Reloaded-2stages-$(GITREV).tar.gz *; mv *.tar.gz ..
@rm -rf release
@$(MAKE) clean
%.build:
@echo Building $* ...
@$(MAKE) --no-print-directory $*.bin
.c.o:
@echo [$(notdir $<)]
@$(CC) $(CFLAGS) -c -o $@ $*.c
.S.o:
@echo [$(notdir $<)]
@$(CC) $(AFLAGS) -c -o $@ $*.S
xell-gggggg.elf: CURRENT_TARGET = HACK_GGGGGG
xell-1f.elf xell-2f.elf: CURRENT_TARGET = HACK_JTAG
xell-gggggg_cygnos_demon.elf: CURRENT_TARGET = HACK_GGGGGG
xell-gggggg_cygnos_demon.elf: CYGNOS_DEF = -DCYGNOS
xell-1f_cygnos_demon.elf xell-2f_cygnos_demon.elf: CURRENT_TARGET = HACK_JTAG
xell-1f_cygnos_demon.elf xell-2f_cygnos_demon.elf: CYGNOS_DEF = -DCYGNOS
%.elf: $(LV1_DIR)/%.lds $(OBJS)
@$(CC) -n -T $< $(LDFLAGS) -o $@ $(OBJS)
stage2.elf32.gz: FORCE
@rm -f $@
@rm -rf $(OBJS)
@$(MAKE) --no-print-directory -f Makefile_lv2.mk
@$(STRIP) stage2.elf32
@gzip -n9 stage2.elf32
%.bin: %.elf stage2.elf32.gz
# 256KB - 16KB of stage 2 - FOOTER bytes == 245744
@test `stat -L -c %s stage2.elf32.gz` -le 245744 || (echo "stage2.elf32.gz too large!"; exit 1)
@$(OBJCOPY) -O binary $< $@
# Ensure stage1 is small enough (<= 16KB)
@test `stat -L -c %s $@` -le 16384 || (echo "Too large"; exit 1)
@truncate --size=262128 $@ # 256k - footer size
@echo -n "xxxxxxxxxxxxxxxx" >> $@ # add footer
@dd if=stage2.elf32.gz of=$@ conv=notrunc bs=16384 seek=1 # inject stage2
FORCE: