This repository has been archived by the owner on Feb 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
84 lines (72 loc) · 3.01 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
#Don't Crush my Castle Makefile v0.7.7
#by demiurgosoft
#Just type make to compile project (currently compiling tests)
#make test: compile tests
#make clean: clean directories (removing binaries and objects)
#make astyle: astyle format to all .cpp and .h files (needs astyled installed)
#make print-%: shows % variable (if makefile crashes, for testing)
#FLAGS
CXX = g++
CPPFLAGS= -Wall -O1 -std=c++11#-g
ALLEGROFLAGS=-lallegro -lallegro_image -lallegro_main -lallegro_font -lallegro_ttf
#ALLEGROFLAGS2=-lallegro -lallegro_primitives -lallegro_font -lallegro_ttf -lallegro_image -lallegro_main -lallegro_acodec -lallegro_audio -lallegro_color -lallegro_dialog -lallegro_memfile -lallegro_physfs
IDIR=include
ODIR=obj
SDIR=src
BDIR=bin
UTILSDIR=$(IDIR)/utilities
MAPDIR=$(IDIR)/map
ENEMYDIR=$(IDIR)/enemy
TOWERDIR=$(IDIR)/tower
CONTROLLERDIR=$(IDIR)/controller
TESTDIR=$(SDIR)/test
MAINDIR=$(SDIR)/main
_INC=$(UTILSDIR) $(MAPDIR) $(ENEMYDIR) $(TOWERDIR) $(CONTROLLERDIR)
I_INC=$(patsubst %,-I %,$(_INC))
_AL_UTILS=al_anim.cpp al_utils.cpp debug_log.cpp input_handler.cpp game_object.cpp text_handler.cpp tinyxml2.cpp
AL_UTILS_O=$(patsubst %,$(ODIR)/%,$(_AL_UTILS:.cpp=.o))
_MAP=tile.cpp tileset.cpp tilemap.cpp
MAP_O=$(patsubst %,$(ODIR)/%,$(_MAP:.cpp=.o))
_ENEMY=enemy_attributes.cpp enemy.cpp enemy_set.cpp
ENEMY_O=$(patsubst %,$(ODIR)/%,$(_ENEMY:.cpp=.o))
_TOWER=tower_atk_attributes.cpp tower_atk.cpp tower_attributes.cpp tower.cpp tower_set.cpp
TOWER_O=$(patsubst %,$(ODIR)/%,$(_TOWER:.cpp=.o))
_CONTROLLER=game_objects.cpp player_controller.cpp game_master.cpp player.cpp
CONTROLLER_O=$(patsubst %,$(ODIR)/%,$(_CONTROLLER:.cpp=.o))
TEST_O=$(AL_UTILS_O) $(MAP_O) $(ENEMY_O) $(TOWER_O) $(CONTROLLER_O)
_TEST_H=test_utils.h test_anim.h test_map.h test_tower.h test_enemy.h test_controller.h test_xml.h
TEST_H=$(patsubst %,$(TESTDIR)/%,$(_TEST_H))
MAIN_O=$(AL_UTILS_O) $(MAP_O) $(ENEMY_O) $(TOWER_O) $(CONTROLLER_O) $(ODIR)/DCmC.o
.PHONY: all
all: main
bin/DCmC: $(MAIN_O)
$(CXX) -o $@ $^ $(CPPFLAGS) $(I_INC) -I $(TESTDIR) $(ALLEGROFLAGS)
#Compile tests
bin/main_test: $(TEST_O) $(LIBS) $(TESTDIR)/main_test.cpp
$(CXX) -o $@ $^ $(CPPFLAGS) $(I_INC) -I $(TESTDIR) $(ALLEGROFLAGS)
#compile a generic .o
obj/%.o: $(SDIR)/*/%.cpp $(IDIR)/*/%.h
$(CXX) -c -o $@ $< $(I_INC) $(CPPFLAGS)
obj/%.o: $(SDIR)/*/%.cpp
$(CXX) -c -o $@ $< $(I_INC) $(CPPFLAGS)
#Creates directories if dont exists
$(BDIR)/:
mkdir $(BDIR)
$(ODIR)/:
mkdir $(ODIR)
.PHONY: main
main: $(BDIR)/ $(ODIR)/ bin/DCmC
#compile tests binaries
.PHONY: test
test: $(BDIR)/ $(ODIR)/ $(TEST_H) bin/main_test
#astyle for all code (.cpp and .h)
.PHONY: astyle
astyle:
astyle --style=java --break-closing-brackets --align-pointer=name --delete-empty-lines --indent-col1-comments --unpad-paren -n -Q $(IDIR)/*/*.h $(SDIR)/*/*.cpp $(SDIR)/*/*.h
#print variable
.PHONY: print-%
print-% : ; @echo $* = $($*)
#clean obj and bin directories as well as *~ files
.PHONY: clean
clean:
rm -r -f $(BDIR) $(ODIR) *~ $(SDIR)/*/*~ $(IDIR)/*/*~