aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: e2775801d5465c913b2049a45857cbee45ed698e (plain) (blame)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
ifndef config
  config=debug_gnu64
endif

.PHONY: all clean

compiler = gcc
tool_compiler = gcc
linker = gcc
includes = -I./
cflags = $(includes) $(conf_cflags) \
  -Wall -Wextra -pedantic -std=c90
lflags = $(libs) $(conf_lflags)
target = hftrss
int_dir = intermediate
data_dir = data
convimg = convimg
convanim = convanim
packassets = packassets
pack = pack.h

ifeq ($(config), debug_gnu64)
  compiler = gcc
  tool_compiler = gcc
  linker = gcc
  conf_cflags = -DDEBUG -Dplat_x11 -Dplat_x86 \
    -Dplat_posix -Dallocation_default_alignment=8 \
    -Dplat_pulse \
    -g
  libs = -lX11 -lXi -lpulse -lpulse-simple -lpthread -lm
endif

ifeq ($(config), release_gnu64)
  compiler = gcc
  tool_compiler = gcc
  linker = gcc
  conf_cflags = -DNDEBUG -Dplat_x11 -Dplat_x86 \
    -Dplat_posix -Dallocation_default_alignment=8 \
    -Dplat_pulse \
    -s -O3 -m64
  conf_lflags = -m64 -s
  libs = -lX11 -lXi -lpulse -lpulse-simple -lpthread -lm
endif

ifeq ($(config), debug_sdl2)
  compiler = gcc
  tool_compiler = gcc
  linker = gcc
  conf_cflags = -DDEBUG -Dplat_sdl2 -Dplat_x86 \
    -Dallocation_default_alignment=8 \
    -g
  libs = -lSDL2 -lm
endif

ifeq ($(config), release_ems)
  compiler = emcc
  tool_compiler = gcc
  target = ems/hftrss.html
  linker = emcc
  conf_cflags = -DNDEBUG -Dplat_ems -Dplat_sdl2 \
    -Dplat_ems \
    -Dallocation_default_alignment=8 \
    -O3
  conf_lflags = -m64 -s --shell-file ems/template.html \
		--post-js ems/post_run.js -sUSE_SDL=2
  libs = -lm
endif

ifeq ($(config), release_psv)
  compiler = arm-vita-eabi-gcc
  tool_compiler = gcc
  linker = arm-vita-eabi-gcc
  conf_cflags = -DNDEBUG -Dplat_psv \
    -Dallocation_default_alignment=4 \
    -O3 -s
  conf_lflags = -Wl,-q -O3
  libs = -lSceDisplay_stub -lSceCtrl_stub -lSceAudio_stub -lSceLibDbg_stub -lm
  postbuild = psv_postbuild
endif

sources = \
	animation.c \
	asset.c \
	deathzone.c \
	effect.c \
	enemy.c \
	game.c \
	hftrss.c \
	hud.c \
	map.c \
	maths.c \
	memory.c \
	particle.c \
	physics.c \
	plat.c \
	player.c \
	projectile.c \
	random.c \
	rect.c \
	render.c \
	str.c \
	world.c \

image_sources = \
	$(int_dir)/arms.bmp \
	$(int_dir)/guy.bmp \
	$(int_dir)/hud.bmp \
	$(int_dir)/map.bmp \
	$(int_dir)/mask.bmp \
	$(int_dir)/npc.bmp \
	$(int_dir)/rooms.bmp \

anim_sources = \
	$(int_dir)/arrow.anm \
	$(int_dir)/demon_fly_left.anm \
	$(int_dir)/demon_fly_right.anm \
	$(int_dir)/demon_idle_left.anm \
	$(int_dir)/demon_idle_right.anm \
	$(int_dir)/demon_jump_left.anm \
	$(int_dir)/demon_jump_right.anm \
	$(int_dir)/demon_walk_left.anm \
	$(int_dir)/demon_walk_right.anm \
	$(int_dir)/fade_in.anm \
	$(int_dir)/fade_out.anm \
	$(int_dir)/fly_left.anm \
	$(int_dir)/fly_right.anm \
	$(int_dir)/guy_fall_left.anm \
	$(int_dir)/guy_fall_right.anm \
	$(int_dir)/guy_idle_left.anm \
	$(int_dir)/guy_idle_right.anm \
	$(int_dir)/guy_jump_left.anm \
	$(int_dir)/guy_jump_right.anm \
	$(int_dir)/guy_run_left.anm \
	$(int_dir)/guy_run_right.anm \
	$(int_dir)/guy_slash_left.anm \
	$(int_dir)/guy_slash_right.anm \
	$(int_dir)/slash_left.anm \
	$(int_dir)/slash_right.anm \
	$(int_dir)/smol_slash_left.anm \
	$(int_dir)/smol_slash_right.anm \

objects    = $(sources:%.c=%.o)
images     = $(image_sources:$(int_dir)/%.bmp=$(data_dir)/%.img)
animations = $(anim_sources:$(int_dir)/%.anm=$(data_dir)/%.anm)

all: $(target) $(pack) $(postbuild)

$(objects): %.o : %.c | $(pack)
	$(compiler) -MMD -MF $(basename $@).d $(cflags) -o $@ -c $<

$(images): $(data_dir)/%.img : $(int_dir)/%.bmp | $(convimg) $(data_dir)
	./$(convimg) $< $@

$(animations): $(data_dir)/%.anm : $(int_dir)/%.anm | $(convanim) $(data_dir)
	./$(convanim) $< $@

$(pack): $(packassets) $(images) $(animations)
	./$(packassets) \
		$(pack) \
		$(data_dir) \
		$(notdir $(animations)) \
		$(notdir $(images))

$(convimg): convimg.c
	$(tool_compiler) convimg.c $(cflags) -o $@

$(convanim): convanim.c
	$(tool_compiler) convanim.c $(cflags) -o $@

$(packassets): packassets.c
	$(tool_compiler) packassets.c $(cflags) -o $@

$(target): $(objects)
	$(linker) $(objects) -o $@ $(lflags)

$(data_dir):
	mkdir -p $(data_dir)

psv_postbuild: $(target)
	vita-elf-create $(target) $(target).velf
	vita-make-fself -s $(target).velf eboot.bin
	vita-mksfoex -s TITLE_ID="HFTRSS001" "HFtrsS" param.sfo
	vita-pack-vpk -s param.sfo -b eboot.bin $(target).vpk \
		-a media/icon.png=sce_sys/icon0.png

vitasend: $(target) $(psv_postbuild)
	curl -T $(target).vpk ftp://${VITAIP}:1337/ux0:/

clean:
	rm *.d
	rm *.o
	rm $(pack)
	rm -r $(data_dir)
	rm $(target)
	rm $(convimg)
	rm $(convanim)

-include $(sources:%.c=%.d)