forked from Free60Project/xell-reloaded
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
73 lines (56 loc) · 1.89 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
CROSS=xenon-
CC=$(CROSS)gcc
OBJCOPY=$(CROSS)objcopy
LD=$(CROSS)ld
AS=$(CROSS)as
STRIP=$(CROSS)strip
LV1_DIR=source/lv1
# 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
%.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 $@
@$(MAKE) --no-print-directory -f Makefile_lv2.mk
@$(STRIP) stage2.elf32
@gzip -n9 stage2.elf32
%.bin: %.elf stage2.elf32.gz
@$(OBJCOPY) -O binary $< $@
@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: