-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (37 loc) · 877 Bytes
/
Copy pathMakefile
File metadata and controls
49 lines (37 loc) · 877 Bytes
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
# gtest makefile by Ákos Becsey
CFLAGS = -Wall -std=c++11 -ggdb
LIBS = -lgtest_main -lgtest -lpthread
CC = g++
LD = $(CC)
SRC_DIR = src
BUILD_DIR = build
BIN_DIR = bin
TARGET = tests
default : $(TARGET)
all : default
cross : default
#find sources
SOURCES = $(shell find $(SRC_DIR) -name "*.cpp")
OBJECTS = $(subst $(SRC_DIR),$(BUILD_DIR),$(SOURCES))
OBJECTS := $(OBJECTS:.cpp=.o)
OBJECTS := $(OBJECTS) $(BUILD_DIR)/tests.o
$(BUILD_DIR)/tests.o : tests.cpp
mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@ -Wall
# compile
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@ -Wall
# link
$(TARGET) : $(OBJECTS)
mkdir -p $(BIN_DIR)
$(LD) $(OBJECTS) $(LIBS) -o $(BIN_DIR)/$@
RM = rm -f
clean:
$(RM) -r $(BUILD_DIR)/*
$(RM) $(BIN_DIR)/$(TARGET)
$(RM) -r $(BUILD_DIR)
$(RM) -r $(BIN_DIR)
run:
./bin/tests
print-% : ; @echo $* = $($*)