-
Notifications
You must be signed in to change notification settings - Fork 112
/
makefile
188 lines (154 loc) · 4.9 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# powturbo (c) Copyright 2013-2023
# 1 - Download or clone TurboPFor:
# git clone git://github.com/powturbo/TurboPFor.git
# make
#
# 2 - include general purpose compression codecs
# git clone --recursive https://github.com/powturbo/TurboPFor-Integer-Compression.git
# make ICCODEC=1
# To benchmark external libraries:
# 1 - clone/download the external repository into the TurboPFor directoty
# 2 - activate the repository in the makefile lib/libext.mak
# 3 - make: "make CODEC1=1 ICCODEC=1"
# or "make CODEC1=1 CODEC2=1 ICCODEC=1"
# aarch64 cross compile
# export CC=aarch64-linux-gnu-gcc
#ICCODEC=1
#AVX2=1
SSE=1
#-------------------------------------------------
CC ?= gcc
CXX ?= g++
#CC=powerpc64le-linux-gnu-gcc
CL = $(CC)
#DEBUG=-DDEBUG -g
DEBUG=-DNDEBUG
JAVA_HOME ?= /usr/lib/jvm/java-8-openjdk-amd64
PREFIX ?= /usr/local
DIRBIN ?= $(PREFIX)/bin
DIRINC ?= $(PREFIX)/include
DIRLIB ?= $(PREFIX)/lib
SRC ?= lib/
OPT=-fstrict-aliasing -fPIC
#------- OS/ARCH -------------------
ifneq (,$(filter Windows%,$(OS)))
OS := Windows
CC=gcc
CXX=g++
# CC=clang
ARCH=x86_64
ifeq ($(ICCODEC),1)
LDFLAGS=-Wl,--stack,33554432
endif
else
OS := $(shell uname -s)
ARCH := $(shell uname -m)
ifneq (,$(findstring aarch64,$(CC)))
ARCH = aarch64
else ifneq (,$(findstring arm64,$(ARCH)))
ARCH = aarch64
else ifneq (,$(findstring iPhone,$(ARCH)))
ARCH = aarch64
CFLAGS=-DHAVE_MALLOC_MALLOC
else ifneq (,$(findstring powerpc64le,$(CC)))
ARCH = ppc64le
endif
endif
ifeq ($(ARCH),ppc64le)
_SSE=-D__SSSE3__
CFLAGS=-mcpu=power9 -mtune=power9 $(_SSE)
else ifeq ($(ARCH),aarch64)
CFLAGS=-march=armv8-a
ifneq (,$(findstring clang, $(CC)))
OPT+=-fomit-frame-pointer
#-fmacro-backtrace-limit=0
endif
_SSE=-march=armv8-a
else ifeq ($(ARCH),$(filter $(ARCH),x86_64))
# set minimum arch sandy bridge SSE4.1 + AVX
_SSE=-march=corei7-avx -mtune=corei7-avx
# _SSE+=-mno-avx -mno-aes
_AVX2=-march=haswell
endif
ifeq (,$(findstring clang, $(CC)))
OPT+=-falign-loops
endif
CFLAGS+=$(DEBUG) $(OPT)
#CFLAGS+=-Wno-macro-redefined -Wno-incompatible-pointer-types -Wno-tautological-constant-out-of-range-compare -Wno-discarded-qualifiers
CFLAGS+=-w -Wall -pedantic
CXXFLAGS+=-w
#-Wall -Wincompatible-pointer-types
ifeq ($(OS),$(filter $(OS),Linux GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT Haiku))
LDFLAGS+=-lrt -lm
endif
ifeq ($(STATIC),1)
CFLAGS+=-D_STATIC
LDFLAGS+=-static
endif
all: icapp
$(SRC)bitutil_avx2.o: $(SRC)bitutil.c
$(CC) -O3 -w $(_AVX2) $(OPT) -c $(SRC)bitutil.c -o $(SRC)bitutil_avx2.o
$(SRC)vp4c_avx2.o: $(SRC)vp4c.c
$(CC) -O3 -w $(_AVX2) $(OPT) -c $(SRC)vp4c.c -o $(SRC)vp4c_avx2.o
$(SRC)vp4d_avx2.o: $(SRC)vp4d.c
$(CC) -O3 -w $(_AVX2) $(OPT) -c $(SRC)vp4d.c -o $(SRC)vp4d_avx2.o
$(SRC)bitpack_avx2.o: $(SRC)bitpack.c
$(CC) -O3 -w $(_AVX2) $(OPT) -c $(SRC)bitpack.c -o $(SRC)bitpack_avx2.o
$(SRC)bitunpack_avx2.o: $(SRC)bitunpack.c
$(CC) -O3 -w $(_AVX2) $(OPT) -c $(SRC)bitunpack.c -o $(SRC)bitunpack_avx2.o
$(SRC)transpose_avx2.o: $(SRC)transpose.c
$(CC) -O3 -w $(_AVX2) $(OPT) -c $(SRC)transpose.c -o $(SRC)transpose_avx2.o
-include lib/libext.mak
LIB=$(SRC)bic.o $(SRC)bitunpack.o $(SRC)bitpack.o $(SRC)bitutil.o $(SRC)eliasfano.o $(SRC)fp.o $(SRC)transpose.o $(SRC)transpose_.o $(SRC)trlec.o $(SRC)trled.o $(SRC)vp4c.o $(SRC)vp4d.o $(SRC)v8.o $(SRC)v8pack.o $(SRC)vint.o $(SRC)vsimple.o $(SRC)vbit.o
ifeq ($(ARCH),x86_64)
LIB+=$(SRC)vp4c_avx2.o $(SRC)vp4d_avx2.o $(SRC)transpose_avx2.o $(SRC)bitpack_avx2.o $(SRC)bitunpack_avx2.o $(SRC)bitutil_avx2.o
else
CFLAGS+=-D_NAVX2
endif
ifeq ($(AVX2),1)
CFLAGS+=$(_AVX2)
else
ifeq ($(SSE),1)
CFLAGS+=$(_SSE)
endif
endif
ifeq ($(ICCODEC),1)
CFLAGS+=-D_ICCODEC
LIB+=$(SRC)iccodec.o
endif
libic.a: $(LIB)
ar cr $@ $+
libic.so : $(LIB)
$(CC) -shared $+ -o $@
JAVA_SUBDIR = java
jic.h: $(JAVA_SUBDIR)/jic.java
# cp jic.h ..
cd $(JAVA_SUBDIR) && javah -jni jic && cp jic.h ..
# $(JAVA_SUBDIR)/jic.class : $(JAVA_SUBDIR)/jic.java
# cd $(JAVA_SUBDIR) && javac jic.java
$(JAVA_SUBDIR)/libic.so : libic.a jic.h jic.c
$(CC) -shared $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux jic.c libic.a -o $(JAVA_SUBDIR)/libic.so
$(JAVA_SUBDIR)/jicbench : $(JAVA_SUBDIR)/jicbench.java $(JAVA_SUBDIR)/libic.so
cd $(JAVA_SUBDIR) && javac jicbench.java && java -Djava.library.path=. jicbench
icapp: $(SRC)icapp.o libic.a $(OB)
$(CL) $^ $(LDFLAGS) -o icapp
myapp: myapp.o libic.a
$(CC) $^ $(LDFLAGS) -o myapp
mycpp: mycpp.o libic.a
$(CXX) $^ $(LDFLAGS) -o mycpp
%.o: %.c
$(CC) -O3 $(CFLAGS) $< -c -o $@
.cc.o:
$(CXX) -O2 $(CXXFLAGS) $< -c -o $@
.cpp.o:
$(CXX) -O2 $(CXXFLAGS) $< -c -o $@
ifeq ($(OS),Windows)
clean:
rm lib/*.o
rm libic.a
rm icapp.exe
else
clean:
@find . -type f -name "*\.o" -delete -or -name "*\~" -delete -or -name "core" -delete -or -name "icbench" -delete -or -name "libic.a" -delete
@find . -type f -name "icbench" -delete -or -name "idxqry" -delete -or -name "idxseg" -delete -or -name "idxcr" -delete -or -name "icapp" -delete
endif