-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (60 loc) · 1.93 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
#
# This file is part of libmaid
#
# Libmaid is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# Libmaid is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with libmaid; if not, see <https://www.gnu.org/licenses/>.
#
CFLAGS += --std=c99 -Iinclude -Wall -Wextra
.PHONY: all debug clean install uninstall
TARGETS = build/libmaid.a build/libmaid.so
all: CFLAGS += -O2 -DNDEBUG=1
all: $(TARGETS)
debug: CFLAGS += -Og -pg -ggdb3
debug: $(TARGETS) test
gdb build/tests
clean:
rm -rf build
DESTDIR ?= /usr/local
install: build/libmaid.a build/libmaid.so
mkdir -p "$(DESTDIR)/lib"
mkdir -p "$(DESTDIR)/include"
cp build/libmaid.a "$(DESTDIR)/lib/"
cp build/libmaid.so "$(DESTDIR)/lib/"
cp -r include/maid "$(DESTDIR)/include/"
uninstall:
rm -rf "$(DESTDIR)/include/maid/"
rm -rf "$(DESTDIR)/lib/libmaid.a"
rm -rf "$(DESTDIR)/lib/libmaid.so"
test:
$(CC) $(CFLAGS) -static tests.c -o build/tests -Lbuild -lmaid
build/tests
FOLDERS = build build/crypto
$(FOLDERS):
mkdir -p $@
OBJS = crypto/aes.o crypto/chacha.o \
crypto/poly1305.o crypto/gcm.o crypto/hmac.o \
crypto/drbg.o crypto/sha2.o \
crypto/rsa.o crypto/pkcs1.o crypto/dh.o \
mem.o mp.o \
block.o stream.o mac.o aead.o \
rng.o hash.o \
pub.o sign.o kex.o \
serial.o keygen.o
OBJS := $(addprefix build/, $(OBJS))
build/%.o: src/%.c | $(FOLDERS)
$(CC) $(CFLAGS) -fPIC -c $< -o $@
build/libmaid.a: $(OBJS) | build
ar ruv $@ $^
ranlib $@
build/libmaid.so: $(OBJS) | build
$(CC) -shared -o $@ $^