-
Notifications
You must be signed in to change notification settings - Fork 4
/
makefile
67 lines (55 loc) · 1.31 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
#################################################
## Filename: makefile
## Author: Daniel Guenther
## Sources: Dr. J's makefile, but also partly inspired
## by the makefile used in the JJAMBA lab
## Date: 2016-02-24
## Class: CSCI 331
## Project: Kitty Pirateer
##
## Purpose:
## compile the project
###################################################
# compiler and flags
CC = g++
CFLAGS =-std=c++11
LDLIBS =-lSOIL -lglut -lGLU -lGL -lX11 -lm `sdl-config --cflags --libs` -lSDL_mixer
# get list of source files
SRCDIR=src
OBJDIR=obj
CPP_FILES := $(wildcard $(SRCDIR)/*.cpp)
# generate object files from source files
OBJ_FILES := $(addprefix $(OBJDIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
# Executeable targets
EXE=bin/game
#logs all errors in compilelog
#make the target
all: bin $(OBJDIR) $(SRC) $(EXE)
log:
make all 2> compilelog
#set up directories needed
bin:
mkdir $@
obj:
mkdir $@
#executeables
$(EXE): $(OBJ_FILES)
$(CC) $^ $(LDLIBS) -o $@
#object files
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
#removes the objects and executeables
clean:
rm -rf bin $(OBJDIR)
#remake everything from scratch
redo:
make clean
reset
make all
#use debug functions
debug: CFLAGS=-std=c++11 -g
debug: clean
debug: all
#open gdb immediately
sdebug: debug
gdb bin/game