-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (38 loc) · 1.03 KB
/
Makefile
File metadata and controls
52 lines (38 loc) · 1.03 KB
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
CC := gcc
NAME := nutil
SNAME := lib$(NAME).a
DNAME := lib$(NAME).so
SRC := nutil.c
OBJ := $(SRC:%.c=%.o)
TESTSRC := test.c
TESTOBJ := $(TESTSRC:%.c=%.o)
EXMSRC := example.c
EXMOBJ := $(EXMSRC:%.c=%.o)
CFLAGS := -O2 -Wall -Wextra -pedantic -Werror-implicit-function-declaration
LIBS := -lm -lgmp
PREFIX = /usr/local
.PHONY: all static dynamic install uninstall clean fclean re
all: static dynamic
static: $(SNAME)
dynamic: $(DNAME)
$(SNAME): $(OBJ)
$(AR) $(ARFLAGS) $@ $^
$(DNAME): CFLAGS += -fPIC
$(DNAME): LDFLAGS += -shared
$(DNAME): $(OBJ)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
test: $(TESTOBJ) $(SNAME)
$(CC) $(LDFLAGS) $(LDLIBS) $^ -o $@ $(LIBS)
example: $(EXMOBJ) $(SNAME)
$(CC) $(LDFLAGS) $(LDLIBS) $^ -o $@ $(LIBS)
install: $(SNAME) $(DNAME)
mv $^ $(PREFIX)/lib
cp nutil.h $(PREFIX)/include
uninstall:
$(RM) $(PREFIX)/lib/$(SNAME) $(PREFIX)/lib/$(DNAME)
$(RM) $(PREFIX)/include/nutil.h
clean:
$(RM) $(OBJ) $(TESTOBJ) $(EXMOBJ)
fclean: clean
$(RM) $(SNAME) $(DNAME) test example
re: fclean all