-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
44 lines (35 loc) · 1 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
VPATH = src
SRC_FILES = md5.c hash.c parse.c digest.c client.c server.c
OBJ_FILES = $(patsubst %.c, %.o, $(SRC_FILES))
CC = gcc
CFLAGS = -c -fPIC -g -Wall
LDFLAGS =-s -shared -fvisibility=hidden -Wl,--exclude-libs=ALL,--no-as-needed,-soname,libdigest.so -ldl -Wall -g
PREFIX ?= /usr
.PHONY: all
all: digest
.PHONY: digest
digest: $(SRC_FILES) $(OBJ_FILES)
@echo -ne "\e[33mBuilding libdigest.so...\e[0m\n"
$(CC) $(LDFLAGS) $(OBJ_FILES) -o libdigest.so
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
.PHONY: install
install: all
install --directory ${PREFIX}/lib
install --directory ${PREFIX}/include/digest
install libdigest.so ${PREFIX}/lib/
install ${VPATH}/digest.h ${PREFIX}/include/
install ${VPATH}/client.h ${PREFIX}/include/digest
ldconfig -n ${PREFIX}/lib
.PHONY: examples
examples: examples/client.c
$(CC) examples/client.c -ldigest -o client
.PHONY: check
check:
$(CC) tests/test_lib.c -ldigest -o test_lib && ./test_lib
.PHONY: clean
clean:
rm -f *.o
.PHONY: dist-clean
dist-clean: clean
rm -f libdigest.so