-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathMakefile
38 lines (30 loc) · 938 Bytes
/
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
CC = gcc
CFLAGS = -std=c99 -Wall -Wextra -Werror -O2 -Wl,-rpath=./
LDLAGS = -lcunit
PREFIX = /usr/local/
CUNIT_VER = $(shell cat /usr/include/CUnit/CUnit.h | awk '$$0~/^\#define CU_VERSION/{print $$NF}')
.PHONY: all test sample
all: aes
aes: aes.c
$(CC) $(CFLAGS) -c -o aes.o $<
$(CC) $(CFLAGS) -shared -fPIC -o libaes.so aes.o
$(AR) rcs libaes.a aes.o
test: aes test_case.c
ifeq ($(CUNIT_VER), "2.1-2")
$(CC) $(CFLAGS) -o test_case test_case.c $(LDLAGS) -DCUNIT_VER=2
else
$(CC) $(CFLAGS) -o test_case test_case.c $(LDLAGS) -DCUNIT_VER=1
endif
./test_case
sample: aes sample.c
$(CC) $(CFLAGS) -o sample sample.c -L./ -laes
./sample
.PHONY: install uninstall clean
install: aes
install libaes.so $(PREFIX)/lib/
ln -sf $(PREFIX)/lib/libaes.so /usr/lib/libaes.so
install aes.h /usr/include/aes.h
uninstall:
rm -f $(PREFIX)/lib/libaes.so /usr/lib/libaes.so /usr/include/aes.h
clean:
rm -f *.o *.so *.a test_case sample