-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
91 lines (77 loc) · 2.09 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
CC = gcc
CXX = g++
LD = g++
CFLAGS = -Isrc -W -Wall -ggdb -std=c99
ifndef NAME
NAME = tetris
endif
ifdef STATICLINK
LIBS =
else
LIBS =
endif
ifndef WINDOWS
ifdef MINGDIR
WINDOWS = 1
endif
endif
ifdef WINDOWS
ifdef ALLEGRO_INCLUDE
CFLAGS += -I$(ALLEGRO_INCLUDE)
endif
RM = del /q
CFLAGS += -D__GTHREAD_HIDE_WIN32API
LFLAGS = -Wl,--subsystem,windows
ifdef ALLEGRO_LIB
LFLAGS += -L$(ALLEGRO_LIB)
endif
ifdef STATICLINK
CFLAGS += -DALLEGRO_STATICLINK
LFLAGS += -static-libgcc
LIBS += -lallegro-5.0.8-monolith-static-mt-debug -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound -lopengl32 -lpsapi
OBJDIR = obj/static
BIN = $(NAME)_static.exe
else
LIBS += -lallegro-5.0.8-monolith-mt-debug
OBJDIR = obj
BIN = $(NAME).exe
endif
else
RM = rm -f
ifdef STATICLINK
LIBS += `pkg-config --libs --static allegro-5.0 allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0`
OBJDIR = obj/static
BIN = $(NAME)_static
else
LIBS += `pkg-config --libs allegro-5.0 allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0`
OBJDIR = obj
BIN = $(NAME)
endif
endif
OBJ_CPP := $(addprefix $(OBJDIR)/, $(subst src/,,$(patsubst %.cpp,%.o,$(wildcard src/*.cpp) $(wildcard src/**/*.cpp))))
OBJ_C := $(addprefix $(OBJDIR)/, $(subst src/,,$(patsubst %.c,%.o,$(wildcard src/*.c) $(wildcard src/**/*.c))))
all: game
$(OBJDIR)/%.o: src/%.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJDIR)/%.o: src/%.cpp
$(CXX) $(CFLAGS) -o $@ -c $<
game: $(OBJ_C) $(OBJ_CPP)
$(LD) -o $(BIN) $(OBJ_C) $(OBJ_CPP) $(LIBS) $(LFLAGS)
clean:
ifdef WINDOWS
ifneq ($(OBJ_C),)
-$(RM) $(subst /,\,$(OBJ_C))
endif
ifneq ($(OBJ_CPP),)
-$(RM) $(subst /,\,$(OBJ_CPP))
endif
else
ifneq ($(OBJ_C),)
-$(RM) $(OBJ_C)
endif
ifneq ($(OBJ_CPP),)
-$(RM) $(OBJ_CPP)
endif
endif
veryclean: clean
-$(RM) $(BIN)