-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (31 loc) · 1023 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
39
40
41
42
43
44
45
46
CC = gcc
CFLAGS = -Wall -Wextra
COBJS = linked-list.o _ll-internal.o ll-extra.o
ARCHIVES = liblinked-list-min.a liblinked-list.a
SHARED_OBJS = $(ARCHIVES:.a=.so)
default: all
$(COBJS): %.o: %.c
linked-list.o: linked-list.h _ll-internal.h
_internal.o: linked-list.h _ll-internal.h
ll-extra.o: ll-extra.h linked-list.h _ll-internal.h
all: all-objs all-archives all-shared
all-objs: $(COBJS)
all-archives: $(ARCHIVES)
all-shared: $(SHARED_OBJS)
liblinked-list-min.a: linked-list.o _ll-internal.o
$(AR) r $@ $^
liblinked-list.a: linked-list.o _ll-internal.o ll-extra.o
$(AR) r $@ $^
$(SHARED_OBJS): %.so: %.a
$(CC) -shared $(LDFLAGS) -o $@ -Wl,-whole-archive $^ -Wl,-no-whole-archive
clean-objs:
$(RM) $(COBJS)
clean-archives:
$(RM) $(ARCHIVES)
clean-shared:
$(RM) $(SHARED_OBJS)
clean: clean-objs clean-archives clean-shared
debug: CPPFLAGS += -DDEBUG
debug: CFLAGS += -g
debug: all-objs all-archives
.PHONY: all all-objs all-archives all-shared clean-objs clean-archives clean-shared clean default debug