-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (61 loc) · 1.37 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
.SUFFIXES : .c .o
CC = gcc
CFLAGS = -Wall \
-Wextra \
-Wpointer-arith \
-Wcast-align \
-Wwrite-strings \
-Wswitch-default \
-Wunreachable-code \
-Winit-self \
-Wmissing-field-initializers \
-Wno-unknown-pragmas \
-Wundef \
-Wconversion \
-Werror \
-O3
LIBS = -lwiringPi
INCLUDES =
OBJS = nand-core.o \
nand-write.o \
nand-read.o \
nand-erase.o \
nand-utils.o \
nand-oob.o \
nand-hamming256.o \
main.o
TARGET = a.out
LIBRARY_TARGET = libnand.a
USE_DEBUG = 0
ifeq ($(USE_DEBUG), 1)
CFLAGS += -g -pg -DDEBUG
LIBS += -lasan \
-fsanitize=address \
-static-libasan
endif
USE_NANOSLEEP = 0
ifeq ($(USE_DEBUG), 1)
CFLAGS += -DENABLE_NANOSLEEP
endif
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
all: $(TARGET)
install: $(LIBRARY_TARGET)
install -d $(DESTDIR)$(PREFIX)/lib/
install -m 644 $(LIBRARY_TARGET) $(DESTDIR)$(PREFIX)/lib
install -d $(DESTDIR)$(PREFIX)/include/nand
install -m 644 *.h $(DESTDIR)$(PREFIX)/include/nand
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LIBS)
$(LIBRARY_TARGET): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
main.o: main.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $^
nand-%.o: nand-%.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
check:
cppcheck *.[ch]
clean:
rm -rf *.o
rm -rf $(TARGET) $(LIBRARY_TARGET)