-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
56 lines (40 loc) · 1.23 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
CC=gcc
CFLAGS=-g -Wall `sdl-config --cflags`
LDFLAGS=`sdl-config --libs`
CFLAGS2=-g -Wall `sdl2-config --cflags`
LDFLAGS2=`sdl2-config --libs`
XBM=./bmp2xbm
FONT_FILE=fonts/qbfat8x8.bmp
all: sdl1 sdl2
sdl1: example1 example2
sdl2: sdl2-example1 sdl2-example2
bmp2xbm:
gcc -Wall -pedantic bmp2xbm.c -o $@
inline_font.h: bmp2xbm
$(XBM) $(FONT_FILE) $@
font.c: inline_font.h
@echo "#include <SDL.h>" > $@-tmp1
@cat inline_font.h >> $@-tmp1
@cat inprint.c > $@-tmp2
@sed '/#include/d' $@-tmp2 >> $@-tmp1
@rm $@-tmp2
@mv $@-tmp1 $@
@echo "[~cat] inline_font.h inprint.c > font.c"
font2.c: inline_font.h
@echo "#include <SDL.h>" > $@-tmp1
@cat inline_font.h >> $@-tmp1
@cat inprint2.c > $@-tmp2
@sed '/#include/d' $@-tmp2 >> $@-tmp1
@rm $@-tmp2
@mv $@-tmp1 $@
@echo "[~cat] inline_font.h inprint2.c > font2.c"
example1: font.c
gcc $(CFLAGS) font.c example.c -o $@ $(LDFLAGS)
example2: inline_font.h
gcc $(CFLAGS) inprint.c example.c -o $@ $(LDFLAGS)
sdl2-example1: font2.c example2.c
gcc $(CFLAGS2) font2.c example2.c -o $@ $(LDFLAGS2)
sdl2-example2: inline_font.h example2.c
gcc $(CFLAGS2) inprint2.c example2.c -o $@ $(LDFLAGS2)
clean:
rm -rf *.o *.a example1 example2 sdl2-example1 sdl2-example2 font.c font2.c inline_font.h