-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
110 lines (86 loc) · 2.68 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
110
AS=arm-none-eabi-gcc
CC=arm-none-eabi-gcc
LD=arm-none-eabi-ld
OBJCOPY=arm-none-eabi-objcopy
ASFLAGS=-fPIC -march=armv6zk -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
HOSTCCFLAGS=-g
HOSTCC=gcc
IMAGE=kart.img
RAW=kart.bin
LINKERSCRIPT=linker.ld
SRCS = $(wildcard boot/*.S)
SRCS += $(subst util/macros.S,, $(wildcard util/*.S))
SRCS += $(wildcard drivers/*.S)
SRCS += $(wildcard graphics/*.S)
SRCS += $(wildcard sprites/*.S)
SRCS += $(wildcard maps/*.S)
SRCS += $(wildcard game/*.S)
SRCS += $(wildcard models/*.S)
OBJS = $(subst tools/lookup_tables.o,, $(SRCS:.S=.o))
OBJS += tools/lookup_tables.o
OBJS += gen/precalc.o
MODELS = $(wildcard models/*.ply)
MODELS_OBJS = $(subst .ply,.pply,$(MODELS))
SPRITES = $(wildcard sprites/*.bmp)
SPRITES_OBJS = $(subst .bmp,.pbmp,$(SPRITES))
MAPS = $(wildcard maps/*.map)
MAPS_OBJS = $(subst .map,.pmap,$(MAPS))
all: $(RAW)
clena: clean
clean:
-@rm -f $(OBJS) $(IMAGE) $(SPRITES_OBJS) bmpconv lookup_generator
-@rm -f precalculate
-@rm -f gen/*
-@rm -f map_loader
-@rm -f ply_converter
-@rm -f obj_converter
-@rm -f $(MODELS_OBJS)
-@rm -f $(MAPS_OBJS)
-@rm -f tools/lookup_tables.S
-@rm -f $(RAW)
-@rm -rf *.dSYM
%.o: %.S
@echo " AS $@"
@$(AS) $(ASFLAGS) -c $< -o $@
sprites/sprites.o: $(SPRITES_OBJS) sprites/sprites.S
maps/maps.o: $(MODELS_OBJS) $(MAPS_OBJS) maps/maps.S
bmpconv: tools/bmp_converter.c
@echo " HOSTCC $@"
@$(HOSTCC) $(HOSTCCFLAGS) tools/bmp_converter.c -o bmpconv
lookup_generator: tools/generate_lookup.c
@echo " HOSTCC $@"
@$(HOSTCC) -lm $(HOSTCCFLAGS) tools/generate_lookup.c -o lookup_generator
gen/precalc.S: precalculate
@echo " PRECALC $@"
@./precalculate
precalculate: tools/precalculate.c
@echo " HOSTCC $@"
@$(HOSTCC) -lm $(HOSTCCFLAGS) tools/precalculate.c -o precalculate
tools/lookup_tables.S: lookup_generator
@echo " GENLKUP $@"
@./lookup_generator
%.pbmp: %.bmp bmpconv
@echo " BMPCONV $@"
@./bmpconv $< $@
ply_converter: tools/ply_converter.c
@echo " HOSTCC $@"
@$(HOSTCC) $(HOSTCCFLAGS) tools/ply_converter.c -o ply_converter
%.pply: %.ply ply_converter
@echo " PLYCONV $@"
@./ply_converter $< $@
map_loader: tools/map_loader.c tools/obj_converter.c
@echo " HOSTCC $@"
@$(HOSTCC) $(HOSTCCFLAGS) tools/map_loader.c -o map_loader
%.pmap: %.map map_loader
@echo " MAPLDR $@"
@./map_loader $< $@
%_powerups.S: %.pmap
%_powerups.o: %_powerups.S
$(IMAGE): $(OBJS) $(SPRITES_OBJS) $(MODELS_OBJS) $(MAPS_OBJS)
@echo " LD $@"
@$(LD) $(OBJS) -o $(IMAGE) -T $(LINKERSCRIPT)
$(RAW): $(IMAGE)
@echo " OBJCOPY $@"
@$(OBJCOPY) $(IMAGE) -O binary $(RAW)
@echo ""
@echo "Sprites compiled in: $(subst sprites/,,$(SPRITES))"