-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (47 loc) · 1.27 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
CXXFLAGS = -Wall -Wextra -std=c++20
ifeq ($(OS),Windows_NT)
CXX = clang++
OUT = lst.exe
LDFLAGS = -lAdvapi32 -lOle32
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g -gcodeview
LDFLAGS += -O0 -g -gcodeview
endif
else
CXX = g++
OUT = lst
CXXFLAGS += -Wexpansion-to-defined
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g
LDFLAGS += -O0 -g
endif
endif
ifndef $(DEBUG)
CXXFLAGS += -O3 -march=native -mtune=native
endif
SRC = natural_sort.cc match.cc columns.cc unicode.cc args.cc lst.cc main.cc
OBJ = $(patsubst %.cc,build/%.o,$(SRC))
OBJ += build/arena_alloc.o
DEP = $(wildcard source/*.hh)
all: build source/stdafx.hh.gch $(OUT)
build:
mkdir -p build
source/stdafx.hh.gch: source/stdafx.hh
@echo ' CXX $@'
@$(CXX) $(CXXFLAGS) -o $@ $<
build/%.o: source/%.cc $(DEP)
@echo ' CXX $@'
@$(CXX) $(CXXFLAGS) -c -o $@ $<
build/arena_alloc.o: source/arena_alloc/arena_alloc.cc source/arena_alloc/arena_alloc.hh
@echo ' CXX $@'
@$(CXX) $(CXXFLAGS) -c -o $@ $<
$(OUT): $(OBJ)
@echo ' LINK $@'
@$(CXX) $(LDFLAGS) -o $@ $^
callgrind: $(OUT)
valgrind --tool=callgrind --dump-instr=yes --trace-jump=yes ./$(OUT) -l
cachegrind: $(OUT)
valgrind --tool=cachegrind --branch-sim=yes ./$(OUT) -l
clean:
rm -f $(OBJ) $(OUT) source/stdafx.hh.gch lst.ilk lst.pdb
.PHONY: all callgrind cachegrind clean