forked from 0NG/Format-Preserving-Encryption
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
60 lines (44 loc) · 1.28 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
CFLAGS := $(shell printenv CFLAGS) -O2 -Wall -fPIC -Wno-deprecated-declarations
SO_LINKS = $(shell printenv LDFLAGS) -lm -lcrypto
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
LIB = libfpe.a libfpe.dylib
else
LIB = libfpe.a libfpe.so
endif
EXAMPLE_SRC = example.c
EXAMPLE_EXE = example
OBJS = src/ff1.o src/ff3.o src/fpe_locl.o
all: $(LIB) $(EXAMPLE_EXE)
libfpe.a: $(OBJS)
ar rcs $@ $(OBJS)
ifeq ($(UNAME),Darwin)
libfpe.dylib: $(OBJS)
gcc -shared -fPIC -Wl,-install_name,libfpe.dylib $(OBJS) $(SO_LINKS) -o $@
else
libfpe.so: $(OBJS)
gcc -shared -fPIC -Wl,-soname,libfpe.so $(OBJS) $(SO_LINKS) -o $@
endif
.PHONY = all clean install
src/ff1.o: src/ff1.c
gcc $(CFLAGS) -c src/ff1.c -o $@
src/ff3.o: src/ff3.c
gcc $(CFLAGS) -c src/ff3.c -o $@
src/fpe_locl.o: src/fpe_locl.c
gcc $(CFLAGS) -c src/fpe_locl.c -o $@
$(EXAMPLE_EXE): $(EXAMPLE_SRC) $(LIB)
ifeq ($(UNAME),Darwin)
gcc $(CFLAGS) -Wl, $(EXAMPLE_SRC) -L. -lfpe $(SO_LINKS) -Isrc -o $@
else
gcc $(CFLAGS) -Wl,-rpath=\$$ORIGIN $(EXAMPLE_SRC) -L. -lfpe $(SO_LINKS) -Isrc -o $@
endif
test:
python test.py
# MacOS
leaks:
leaks -atExit -- ./example EF4359D8D580AA4F7F036D6F04FC6A94 D8E7920AFA330A73 10 890121234567890000
clean:
rm $(OBJS) $(EXAMPLE_EXE) $(LIB)
install:
cp libfpe.so /usr/local/lib
cp src/*.h /usr/local/include