-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
89 lines (69 loc) · 2.13 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
85
86
87
88
89
# Copyright (C) 2015 Itay Grudev <[email protected]>
#
# This file is part of the USB Firewall.
# USB Firewall is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3 as published
# by the Free Software Foundation.
#
# USB Firewall is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 3 for more details.
#
# You should have received a copy of the GNU General Public License along
# with the software. If not, see <http://www.gnu.org/licenses/>.
EXECNAME = usbfw
BINDIR = bin/
OBJDIR = $(BINDIR)obj/
# List the source input directories
SRCDIRS = .
# The source file types (headers excluded).
# .c indicates C source files, and others C++ ones.
SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
OBJECTS = $(addprefix $(OBJDIR), $(SOURCES:.cpp=.o))
# Compiler command
CC = g++
# Initial flags (are added to the compile command first)
# You might need CCFLAGS -I /usr/local/include/
CCFLAGS = -Wall -pedantic -std=c++11
LDFLAGS =
EXECUTABLE = $(BINDIR)$(EXECNAME)
# Check for debug or not
ifeq ($(BUILD),debug)
CCFLAGS += -g
else
CCFLAGS += -O2
endif
# Check if we need to make a seperate bin folder
ifneq ($(BINDIR), )
BINDIRCOMMAND = mkdir -p $(BINDIR)
else
BINDIRCOMMAND =
endif
# Check if we need to make a seperate obj folder and its subfolder structure
ifneq ($(OBJDIR), )
OBJDIRCOMMAND = mkdir -p $(OBJDIR)
OBJDIRCOMMAND += $(foreach d,$(SRCDIRS), $(OBJDIR)$(d))
else
OBJDIRCOMMAND =
endif
# Building recipies
all: $(SOURCES) $(EXECUTABLE)
run:
$(EXECUTABLE)
$(EXECUTABLE): bindir objdir $(OBJECTS)
$(CC) $(CCFLAGS) $(OBJECTS) -o $@ $(LDFLAGS)
bindir:
$(BINDIRCOMMAND)
objdir:
$(OBJDIRCOMMAND)
$(OBJECTS) : $(OBJDIR)%.o : $(SRCDIR)%.cpp
$(CC) $(CCFLAGS) $(LDFLAGS) -c -o $@ $<
# Cleaning recipies
clean: clean-bin clean-obj
clean-bin:
rm -rf $(BINDIR)
clean-obj:
rm -rf $(OBJDIR)
.PHONY: all run clean clean-bin clean-obj bindir objdir