-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
74 lines (52 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
# project name (generate executable with this name)
TARGETS = univ-arenaaa #univ-arenaaa_test
CC = gcc
# compiling flags here
CFLAGS = -std=c99 -Wall -I. -g
LINKER = gcc
# linking flags here
LFLAGS = -Wall -I. -lm
#file directories
SRCDIR = src
OBJDIR = obj
BINDIR = bin
HEADERDIR = header
TRGS := $(TARGETS:%=$(BINDIR)/%)
DIRS = $(OBJDIR) $(BINDIR)
#SDL---------------------------------------------------------------------
SDL_DIR=${HOME}/SDL2
SDLLIB_DIR=${SDL_DIR}/lib
SDLINC_DIR=${SDL_DIR}/include
LIBS=-L${SDLLIB_DIR} -lSDL2 -lSDL2_ttf -lSDL2_image -lpthread
INCLUDES_SDL=-I${SDLINC_DIR}
.PHONY: DIRS
all: $(DIRS) $(TRGS)
doxygen: #creation du doxygen
doxygen ./doc/ProjetL2ConfigDoxygen
firefox doc/html/index.html
$(OBJDIR):
mkdir -p $(OBJDIR)
$(BINDIR):
mkdir -p $(BINDIR)
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(HEADERDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
# Liste des fichiers .o sans ceux contenant un main
OBJS := $(filter-out $(MAINS),$(OBJECTS))
rm = rm -f
$(BINDIR)/$(TARGET): $(OBJECTS)
$(TRGS): $(OBJECTS)
@$(LINKER) $(OBJS) $(LFLAGS) -o $@ ${LIBS} ${INCLUDES_SDL}
@echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o: $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -c $< -o $@ ${LIBS} ${INCLUDES_SDL}
@echo "Compiled "$<" successfully!"
.PHONY: clean
clean:
@$(rm) $(BINDIR)/*
@$(rm) $(OBJECTS)
@echo "Cleanup complete!"
.PHONY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGETS)
@echo "Executable removed!"