-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (48 loc) · 1.25 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
# Makefile for the Binary Tree project
# Author:
# + Felipe Ramos
# Makefile conventions
SHELL = /bin/sh
# Directories
INCDIR = ./include
SRCDIR = ./src
OBJDIR = ./obj
BINDIR = ./bin
DOCDIR = ./Documentation
# Macros
CC = g++ # for compatibility, but preferable clang++
CFLAGS = -Wall -g -ggdb -std=c++14 -I. -I$(INCDIR)
# ^^^
RM = -rm
PROJ_NAME = huf
HEADERS := $(wildcard $(INCDIR)/*)
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
all: project # documentation
project: $(OBJECTS) $(HEADERS) | $(BINDIR)
$(CC) $(OBJECTS) $(CFLAGS) -o $(BINDIR)/$(PROJ_NAME)
@ln -sfv $(BINDIR)/$(PROJ_NAME) $(PROJ_NAME)
documentation:
@mkdir -p $(DOCDIR)
@doxygen config
@ln -sfv $(DOCDIR)/html/index.html $(DOC_NAME)
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp $(HEADERS) | $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(BINDIR):
@mkdir -p $(BINDIR)
# Clean PHONY targets
.PRONY: clean clean_proj
clean: clean_proj
clean_proj:
@echo "Removing OBJDIR..."
@$(RM) -r $(OBJDIR)
@echo "Removing BINDIR..."
@$(RM) -r $(BINDIR)
@echo "Removing documentation files..."
@$(RM) -r Documentation/
@echo "Removing symlink..."
@$(RM) -f $(PROJ_NAME)
@$(RM) -f $(DOC_NAME)
@echo "Clean-up completed!"