-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile-cpp
More file actions
74 lines (57 loc) · 1.94 KB
/
Makefile-cpp
File metadata and controls
74 lines (57 loc) · 1.94 KB
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
CC := g++ -std=c++11
#The Target Binary Program
TARGET := mygame
#The Directories, Source, Includes, Objects, Binary and Resources
BUILDDIR := obj
TARGETDIR := bin
RESDIR := res
SRCEXT := cpp
HEADEREXT := h
DEPEXT := d
OBJEXT := o
STATUSFILE := status.log
#Flags, Libraries and Includes
CFLAGS := -lncurses -Wall -g
LIB := -lncurses
#------------------------------------------------------------
#Do not touch anything below this line
#------------------------------------------------------------
SOURCES := $(shell find . -type f -name "*.$(SRCEXT)")
HEADERS := $(shell find . -type f -name "*.$(HEADEREXT)")
vpath %$(SRCEXT) := $(dir $(SOURCES))
OBJECTS := $(addprefix $(BUILDDIR)/, $(notdir $(SOURCES:.$(SRCEXT)=.$(OBJEXT))))
#Defauilt Make
all: resources $(TARGET)
status:
$(shell echo "number of code lines:" > $(STATUSFILE))
$(shell echo -n " .$(SRCEXT) files: " >> $(STATUSFILE))
$(shell cat $(SOURCES) | wc -l >> $(STATUSFILE))
$(shell echo -n " .$(HEADEREXT) files: " >> $(STATUSFILE))
$(shell cat $(HEADERS) | wc -l >> $(STATUSFILE))
$(shell echo -n " total: " >> $(STATUSFILE))
$(shell cat $(SOURCES) $(HEADERS) | wc -l >> $(STATUSFILE))
run:
$(TARGETDIR)/$(TARGET)
#Remake
remake: cleaner all
#Copy Resources from Resources Directory to Target Directory
resources: directories
$(shell cp $(RESDIR)/* $(TARGETDIR)/)
#Make the Directories
directories:
$(shell mkdir -p $(TARGETDIR))
$(shell mkdir -p $(BUILDDIR))
#Clean only Objecst
clean:
$(shell rm -rf $(BUILDDIR))
#Full Clean, Objects and Binaries
cleaner: clean
$(shell rm -rf $(TARGETDIR))
#Pull in dependency info for *existing* .o files
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
-include $(subst .c,.d,$(SOURCES))
#Link
$(TARGET): $(OBJECTS)
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
$(BUILDDIR)/%.$(OBJEXT): %.$(SRCEXT)
$(CC) -c $(CFLAGS) -o $@ $<