-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
91 lines (69 loc) · 1.48 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
#
# VARIABLES AND SETTINGS
#
LIBNAME = SDL_Universe
# compiler
CC := g++
# compilation flags
CFLAGS := -O -Wall -std=c++11 $(EXTRAFLAGS)
LFLAGS :=
# source files
SRCDIR := src
SRCEXT := cpp
SRCS := $(wildcard $(SRCDIR)/*.$(SRCEXT)) $(wildcard $(SRCDIR)/$(LIBNAME)/*.$(SRCEXT))
# building
BUILDDIR := build
OBJS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SRCS:.$(SRCEXT)=.o))
SDLVERSION := SDL
# output
OUTPUTDIR := bin
TARGET := $(LIBNAME)
#
# SDL1 version
#
sdl1: SDLVERSION += 1
sdl1: CFLAGS += `sdl-config --cflags` -DUSING_SDL1
sdl1: LFLAGS += `sdl-config --libs` -lSDL_ttf
sdl1: run
#
# SDL2 version
#
sdl2: SDLVERSION += 2
sdl2: CFLAGS += `sdl2-config --cflags` -DUSING_SDL2
sdl2: LFLAGS += `sdl2-config --libs` -lSDL2_ttf
sdl2: clean
sdl2: run
#
# RULES
#
run: $(OUTPUTDIR)/$(TARGET)
@echo ""
@echo "### RUNNING VERSION" $(SDLVERSION)
@echo -n " "
./$(OUTPUTDIR)/$(TARGET)
# linking rule
$(OUTPUTDIR)/$(TARGET): $(OBJS)
@echo ""
@echo "### LINKING" $@ "WITH" $(SDLVERSION)
@echo -n " "
$(CC) $^ $(LFLAGS) -o $(OUTPUTDIR)/$(TARGET)
# compilation rule
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@echo ""
@echo "### COMPILING" $@ "FOR" $(SDLVERSION)
@echo -n " "
$(CC) $(CFLAGS) -I include -c -o $@ $<
# cleanup
clean:
@echo ""
@echo "### CLEANING"
@echo -n " "
$(RM) -r $(BUILDDIR)/*.o
@echo -n " "
$(RM) -r $(BUILDDIR)/$(LIBNAME)/*.o
@echo -n " "
$(RM) -r $(OUTPUTDIR)/$(TARGET)
# variable print for debug purposes
debug-%:
@echo $* = $($*)
.PHONY: clean