-
Notifications
You must be signed in to change notification settings - Fork 165
/
Makefile
104 lines (87 loc) · 2.7 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
CFLAGS += -std=c99 -O3 -Wall -Wextra -pedantic
# Set OBJCOPY if not defined by environment:
OBJCOPY ?= objcopy
OBJS = \
lib/arch/avx2/codec.o \
lib/arch/generic/codec.o \
lib/arch/neon32/codec.o \
lib/arch/neon64/codec.o \
lib/arch/ssse3/codec.o \
lib/arch/sse41/codec.o \
lib/arch/sse42/codec.o \
lib/arch/avx/codec.o \
lib/lib.o \
lib/codec_choose.o
HAVE_AVX2 = 0
HAVE_NEON32 = 0
HAVE_NEON64 = 0
HAVE_SSSE3 = 0
HAVE_SSE41 = 0
HAVE_SSE42 = 0
HAVE_AVX = 0
HAVE_FAST_UNALIGNED_ACCESS = 0
# The user should supply compiler flags for the codecs they want to build.
# Check which codecs we're going to include:
ifdef AVX2_CFLAGS
HAVE_AVX2 = 1
HAVE_FAST_UNALIGNED_ACCESS = 1
endif
ifdef NEON32_CFLAGS
HAVE_NEON32 = 1
endif
ifdef NEON64_CFLAGS
HAVE_NEON64 = 1
endif
ifdef SSSE3_CFLAGS
HAVE_SSSE3 = 1
HAVE_FAST_UNALIGNED_ACCESS = 1
endif
ifdef SSE41_CFLAGS
HAVE_SSE41 = 1
HAVE_FAST_UNALIGNED_ACCESS = 1
endif
ifdef SSE42_CFLAGS
HAVE_SSE42 = 1
HAVE_FAST_UNALIGNED_ACCESS = 1
endif
ifdef AVX_CFLAGS
HAVE_AVX = 1
HAVE_FAST_UNALIGNED_ACCESS = 1
endif
ifdef OPENMP
CFLAGS += -fopenmp
endif
.PHONY: all analyze clean
all: bin/base64 lib/libbase64.o
bin/base64: bin/base64.o lib/libbase64.o
$(CC) $(CFLAGS) -o $@ $^
lib/libbase64.o: $(OBJS)
$(LD) -r -o $@ $^
$(OBJCOPY) --keep-global-symbols=lib/exports.txt $@
lib/config.h:
@echo "#define HAVE_AVX2 $(HAVE_AVX2)" > $@
@echo "#define HAVE_NEON32 $(HAVE_NEON32)" >> $@
@echo "#define HAVE_NEON64 $(HAVE_NEON64)" >> $@
@echo "#define HAVE_SSSE3 $(HAVE_SSSE3)" >> $@
@echo "#define HAVE_SSE41 $(HAVE_SSE41)" >> $@
@echo "#define HAVE_SSE42 $(HAVE_SSE42)" >> $@
@echo "#define HAVE_AVX $(HAVE_AVX)" >> $@
@echo "#define HAVE_FAST_UNALIGNED_ACCESS $(HAVE_FAST_UNALIGNED_ACCESS)" >> $@
lib/tables.h: lib/table_generator.c
$(CC) $(CFLAGS) -o lib/table_generator $^
./lib/table_generator > $@
$(OBJS): lib/config.h
lib/lib.o: lib/tables.h
lib/arch/avx2/codec.o: CFLAGS += $(AVX2_CFLAGS)
lib/arch/neon32/codec.o: CFLAGS += $(NEON32_CFLAGS)
lib/arch/neon64/codec.o: CFLAGS += $(NEON64_CFLAGS)
lib/arch/ssse3/codec.o: CFLAGS += $(SSSE3_CFLAGS)
lib/arch/sse41/codec.o: CFLAGS += $(SSE41_CFLAGS)
lib/arch/sse42/codec.o: CFLAGS += $(SSE42_CFLAGS)
lib/arch/avx/codec.o: CFLAGS += $(AVX_CFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
analyze: clean
scan-build --use-analyzer=`which clang` --status-bugs make
clean:
rm -f bin/base64 bin/base64.o lib/libbase64.o lib/table_generator.o lib/table_generator lib/config.h $(OBJS)