-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
193 lines (155 loc) · 5.44 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
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
.POSIX:
.SUFFIXES:
FC = gfortran
SDL_CFLAGS = `sdl2-config --cflags`
SDL_LDLIBS = `sdl2-config --libs`
FFLAGS = -march=native -Wall -std=f2008 -fmax-errors=1 $(SDL_CFLAGS) # -O2
LDLIBS = $(SDL_LDLIBS)
LIBGL = -lGL # -lopengl32
LIBGLU = -lGLU # -lglu32
SDL_SRC = src/c_util.f90 \
src/sdl2/sdl2_stdinc.f90 \
src/sdl2/sdl2_audio.f90 \
src/sdl2/sdl2_blendmode.f90 \
src/sdl2/sdl2_cpuinfo.f90 \
src/sdl2/sdl2_gamecontroller.f90 \
src/sdl2/sdl2_error.f90 \
src/sdl2/sdl2_events.f90 \
src/sdl2/sdl2_filesystem.f90 \
src/sdl2/sdl2_hints.f90 \
src/sdl2/sdl2_joystick.f90 \
src/sdl2/sdl2_keyboard.f90 \
src/sdl2/sdl2_log.f90 \
src/sdl2/sdl2_messagebox.f90 \
src/sdl2/sdl2_rect.f90 \
src/sdl2/sdl2_pixels.f90 \
src/sdl2/sdl2_platform.f90 \
src/sdl2/sdl2_scancode.f90 \
src/sdl2/sdl2_surface.f90 \
src/sdl2/sdl2_render.f90 \
src/sdl2/sdl2_keycode.f90 \
src/sdl2/sdl2_mouse.f90 \
src/sdl2/sdl2_rwops.f90 \
src/sdl2/sdl2_thread.f90 \
src/sdl2/sdl2_timer.f90 \
src/sdl2/sdl2_version.f90 \
src/sdl2/sdl2_video.f90 \
src/sdl2/sdl2_opengl.f90 \
src/sdl2.f90
IMG_SRC = src/sdl2_image.f90
MIX_SRC = src/c_util.f90 \
src/sdl2_mixer.f90
TTF_SRC = src/sdl2_ttf.f90
GLU_SRC = src/glu.f90
SDL_LIB = libsdl2.a
IMG_LIB = libsdl2_image.a
MIX_LIB = libsdl2_mixer.a
TTF_LIB = libsdl2_ttf.a
GLU_LIB = libglu.a
LIBRARY = libfortran-sdl2.a
.PHONY: all clean doc examples \
sdl2 sdl2_image sdl2_mixer sdl2_ttf glu
all: $(LIBRARY) $(GLU_LIB)
examples: alpha cyclic draw dvd events fire forest gl gl3d glsphere info \
log logo image msgbox opera pixel scaling text vertex voxel window
# Build targets of SDL 2.0 interfaces.
sdl2: $(SDL_LIB)
sdl2_image: $(IMG_LIB)
sdl2_mixer: $(MIX_LIB)
sdl2_ttf: $(TTF_LIB)
# Build targets for additional OpenGL interfaces.
glu: $(GLU_LIB)
# OpenGL.
$(GLU_LIB):
$(FC) $(FFLAGS) -fPIC -c $(GLU_SRC)
ar rcs $(GLU_LIB) glu.o
# SDL 2.0.
$(SDL_LIB):
$(FC) $(FFLAGS) -fPIC -c $(SDL_SRC)
ar rcs $(SDL_LIB) sdl2.o
$(IMG_LIB):
$(FC) $(FFLAGS) -fPIC -c $(IMG_SRC)
ar rcs $(IMG_LIB) sdl2_image.o
$(MIX_LIB):
$(FC) $(FFLAGS) -fPIC -c $(MIX_SRC)
ar rcs $(MIX_LIB) sdl2_mixer.o
$(TTF_LIB):
$(FC) $(FFLAGS) -fPIC -c $(TTF_SRC)
ar rcs $(TTF_LIB) sdl2_ttf.o
$(LIBRARY): $(SDL_LIB) $(IMG_LIB) $(MIX_LIB) $(TTF_LIB) $(GLU_LIB)
ar rcs $(LIBRARY) sdl2.o sdl2_image.o sdl2_mixer.o sdl2_ttf.o glu.o
# Examples.
alpha: examples/alpha.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
cyclic: examples/cyclic.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
draw: examples/draw.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
dvd: examples/dvd.f90 $(SDL_LIB) $(IMG_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) -lSDL2_image
events: examples/events.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
fire: examples/fire.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
forest: examples/forest.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
gl: examples/gl.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) $(LIBGL)
gl3d: examples/gl3d.f90 $(SDL_LIB) $(IMG_LIB) $(GLU_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) -lSDL2_image $(LIBGL) $(LIBGLU)
glsphere: examples/glsphere.f90 $(SDL_LIB) $(GLU_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) $(LIBGL) $(LIBGLU)
image: examples/image.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
info: examples/info.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
log: examples/log.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
logo: examples/logo.f90 $(SDL_LIB) $(IMG_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) -lSDL2_image
msgbox: examples/msgbox.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
opera: examples/opera.f90 $(SDL_LIB) $(MIX_LIB) $(TTF_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) -lSDL2_mixer -lSDL2_ttf
pixel: examples/pixel.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
scaling: examples/scaling.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
text: examples/text.f90 $(SDL_LIB) $(TTF_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS) -lSDL2_ttf
vertex: examples/vertex.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
voxel: examples/voxel.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
window: examples/window.f90 $(SDL_LIB)
$(FC) $(FFLAGS) -o $@ $? $(LDLIBS)
# Make documentation.
doc:
ford project.md -d ./src
# Delete *.mod, *.a, *.o, and all compiled examples.
clean:
if [ `ls -1 *.mod 2>/dev/null | wc -l` -gt 0 ]; then rm *.mod; fi
if [ `ls -1 *.a 2>/dev/null | wc -l` -gt 0 ]; then rm *.a; fi
if [ `ls -1 *.o 2>/dev/null | wc -l` -gt 0 ]; then rm *.o; fi
if [ -e alpha ]; then rm alpha; fi
if [ -e cyclic ]; then rm cyclic; fi
if [ -e draw ]; then rm draw; fi
if [ -e dvd ]; then rm dvd; fi
if [ -e events ]; then rm events; fi
if [ -e fire ]; then rm fire; fi
if [ -e forest ]; then rm forest; fi
if [ -e gl ]; then rm gl; fi
if [ -e gl3d ]; then rm gl3d; fi
if [ -e glsphere ]; then rm glsphere; fi
if [ -e image ]; then rm image; fi
if [ -e info ]; then rm info; fi
if [ -e log ]; then rm log; fi
if [ -e logo ]; then rm logo; fi
if [ -e msgbox ]; then rm msgbox; fi
if [ -e opera ]; then rm opera; fi
if [ -e pixel ]; then rm pixel; fi
if [ -e scaling ]; then rm scaling; fi
if [ -e text ]; then rm text; fi
if [ -e vertex ]; then rm vertex; fi
if [ -e voxel ]; then rm voxel; fi
if [ -e window ]; then rm window; fi