-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
60 lines (45 loc) · 1.65 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
CC = gcc # compiler
LD = gcc # linker
LDFLAGS = -g # linker flags
# use regular Netlib BLAS
# have header include path at the start, before -Wall, or else debug symbols don't get created
CFLAGS = -I/usr/local/include -I/opt/homebrew/opt/openblas/include -Iutil -I -Wall -g -c # compiler flags
LIBS = -lblas -lm
# use AMD Ryzen BLAS, statically link
# CFLAGS = -Wall -I/usr/local/include -I/home/liyongda/Downloads/amd-blis/include/LP64 -Iutil -I -g -c # compiler flags
# LIBS = /home/liyongda/Downloads/amd-blis/lib/LP64/libblis.a -lm -lpthread
# CFLAGS = -Wall -I/home/liyongda/Downloads/amd-libflame/include/LP64 -I/usr/local/include -Iutil -I -g -c # compiler flags
# LIBS = -L/home/liyongda/Downloads/amd-libflame/lib/LP64/libflame.a -lm -lpthread
SOURCES := \
main.c \
mymatrix.c \
logger.c \
HEADERS := $(SOURCES:.c=.h)
OBJECTS := $(SOURCES:.c=.o)
DEPENDENCIES := $(SOURCES:.c=.d)
$(info $$SOURCES is [${SOURCES}])
$(info $$HEADERS is [${HEADERS}])
$(info $$OBJECTS is [${OBJECTS}])
$(info $$DEPENDENCIES is [${DEPENDENCIES}])
all: main.out
# link all objects together into single executable
main.out: $(OBJECTS)
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
# for every item in objects list, it depends on the *.o -> *.c version of the code
$(OBJECTS): %.o:%.c
# produce a .d makefile syntax file that contains the header file dependencies
$(CC) -MT $@ -MM $(CFLAGS) $< > $(<:%.c=%.d)
# for every .c file, compile a produce a .o file
$(CC) $(CFLAGS) $< -o $@
# pull in dependency information for existing .o files
-include $(OBJECTS:.o=.d)
.PHONY: clean
clean:
rm -f $(OBJECTS)
rm -f $(DEPENDENCIES)
run: main.out
./$<
debug: main.out
gdb $<
test: test.out
./$<