-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
61 lines (41 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
61
include config.mk
# rebuild when makefile changes
-include dummy.rebuild
.PHONY: all clean
ASM_FLAGS ?= -DNASM_ENABLE_DEBUG=$(NASM_DEBUG) -w+all -l x86_methods.list
ifneq ($(CPU_ARCH),)
ARCH_FLAGS := -march=$(CPU_ARCH)
endif
O_LEVEL ?= -O2
COMMON_FLAGS := -MMD -Wall -Wextra -Wundef $(ARCH_FLAGS) -g $(O_LEVEL)
CPPFLAGS := $(COMMON_FLAGS)
CFLAGS := $(COMMON_FLAGS)
SRC_FILES := $(wildcard *.cpp) $(wildcard *.c)
OBJECTS := $(SRC_FILES:.cpp=.o) asm-methods.o
OBJECTS := $(OBJECTS:.c=.o)
DEPFILES = $(OBJECTS:.o=.d)
# $(info OBJECTS=$(OBJECTS))
VPATH = test
###########
# Targets #
###########
all: avx-turbo unit-test
-include $(DEPFILES) unit-test.d
clean:
rm -f *.d *.o avx-turbo
dist-clean: clean $(CLEAN_TARGETS)
unit-test: unit-test.o unit-test-main.o cpuid.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -std=c++11 $^ -o $@
avx-turbo: $(OBJECTS)
$(CXX) $(OBJECTS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -std=c++11 -lpthread -o $@
%.o : %.c
$(CC) $(CFLAGS) -c -std=c11 -o $@ $<
%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -std=c++11 -o $@ $<
%.o: %.asm nasm-utils-inc.asm
$(ASM) $(ASM_FLAGS) -f elf64 $<
LOCAL_MK = $(wildcard local.mk)
# https://stackoverflow.com/a/3892826/149138
dummy.rebuild: Makefile config.mk $(LOCAL_MK)
touch $@
$(MAKE) -s clean