forked from wireapp/cryptobox-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (57 loc) · 1.73 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
SHELL := /usr/bin/env bash
VERSION := "0.8.3"
ARCH := amd64
BUILD ?= 1
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
TARGET_LIB ?= /usr/local/lib
TARGET_INCLUDE ?= /usr/local/include
ifeq ($(OS), darwin)
LIB_TYPE := dylib
LIB_PATH := DYLD_LIBRARY_PATH
else
LIB_TYPE := so
LIB_PATH := LD_LIBRARY_PATH
endif
all: compile
clean:
cargo clean
rm -rf test/target
rm -f deb/usr/include/*.h
rm -f deb/usr/lib/*.so
compile:
cargo build
compile-release:
cargo build --release
test: compile test-compile
$(LIB_PATH)=test/target valgrind --leak-check=full --error-exitcode=1 --track-origins=yes test/target/main
test-compile:
mkdir -p test/target
cp target/debug/libcryptobox.$(LIB_TYPE) test/target/libcryptobox.$(LIB_TYPE)
rm -f test/target/main
$(CC) -std=c99 -Wall -Wextra -Werror -g test/main.c -o test/target/main -Isrc -Ltest/target -lcryptobox
bench: bench-compile
$(LIB_PATH)=test/target test/target/bench
bench-compile: compile-release
mkdir -p test/target
cp target/release/libcryptobox.$(LIB_TYPE) test/target/libcryptobox.$(LIB_TYPE)
rm -f test/target/bench
$(CC) -std=c99 -Wall -Wextra -Werror -g test/bench.c -o test/target/bench -Isrc -Ltest/target -lcryptobox
install: compile-release
cp src/cbox.h $(TARGET_INCLUDE)
cp target/release/libcryptobox.$(LIB_TYPE) $(TARGET_LIB)
uninstall:
rm -f $(TARGET_INCLUDE)/cbox.h
rm -f $(TARGET_LIB)/libcryptobox.$(LIB_TYPE)
dist: compile-release
mkdir -p deb/usr/include
mkdir -p deb/usr/lib
cp src/cbox.h deb/usr/include
cp target/release/libcryptobox.$(LIB_TYPE) deb/usr/lib
ifeq ($(OS), linux)
makedeb --name=cryptobox \
--version=$(VERSION) \
--debian-dir=deb \
--build=$(BUILD) \
--architecture=$(ARCH) \
--output-dir=target/release
endif