-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (42 loc) · 1.09 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
CC := gcc
CFLAGS := -fPIC -Iinclude -std=c99
SRC := ./src
INC := ./include
BIN := ./bin
INCLOC := /usr/include
LIBLOC := /usr/lib
default: all
RSADEPS := $(SRC)/rsa.c
RSATARG := $(BIN)/rsa.o
$(RSATARG): $(RSADEPS)
$(CC) -c $< -o $@ $(CFLAGS)
STATICLIB := librsa.a
$(STATICLIB): $(RSATARG)
ar rcs $@ $<
DYNAMICLIB := librsa.so
$(DYNAMICLIB): $(RSATARG)
gcc -shared -o $@ $<
.PHONY: install
install:
@cp $(STATICLIB) $(LIBLOC)
@cp $(DYNAMICLIB) $(LIBLOC)
@cp $(INC)/* $(INCLOC)
@echo "Installed successfully."
.PHONY: uninstall
uninstall:
@if [ -f $(INCLOC)/rsa.h ]; then rm -rf $(INCLOC)/rsa.h; fi;
@if [ -f $(LIBLOC)/$(STATICLIB) ]; then rm $(LIBLOC)/$(STATICLIB); fi;
@if [ -f $(LIBLOC)/$(DYNAMICLIB) ]; then rm $(LIBLOC)/$(DYNAMICLIB); fi;
.PHONY: clean
clean:
@if [ -f $(RSATARG) ]; then rm $(RSATARG); fi;
@if [ -f $(STATICLIB) ]; then rm $(STATICLIB); fi;
@if [ -f $(DYNAMICLIB) ]; then rm $(DYNAMICLIB); fi;
.PHONY: all
all:
@echo "building static library..."
$(MAKE) $(STATICLIB)
@echo "done."
@echo "building dynamic library..."
$(MAKE) $(DYNAMICLIB)
@echo "done."