blob: c4ff2eaba4a36050b08099a1ed92912a1abb658e (
plain)
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
64
65
66
67
68
69
70
71
72
73
|
WARNFLAGS = \
-W -Wformat -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wsign-compare \
-Wmissing-noreturn \
-Wextra -Wstrict-aliasing=2 \
-Wunsafe-loop-optimizations \
-Wuninitialized
# Compiler flags for generating dependencies
DEPFLAGS = -MMD -MP
CFLAGS ?= -O3
# CFLAGS ?= -O0 -g
# LDFLAGS ?= -g
ALLCFLAGS = -std=gnu99 -fPIC $(WARNFLAGS) $(DEPFLAGS) $(CFLAGS)
# declarations
RAINBOW_OBJS = nss-rainbow.o buf.o nat.o slist.o
UIDS_OBJS = uids.o
GIDS_OBJS = gids.o
TEST_SLIST_OBJS = test_slist.o slist.o
TEST_ENDGRENT_OBJS = test_endgrent.o
TEST_NAT_OBJS = test_nat.o nat.o
TEST_FORMAT_BUF_OBJS = test_format_buf.o buf.o
ALL_OBJS = $(RAINBOW_OBJS) $(UIDS_OBJS) $(GIDS_OBJS) $(TEST_SLIST_OBJS) $(TEST_NAT_OBJS)
BINARIES = libnss_rainbow.so.2 uids gids test_slist test_nat test_endgrent test_format_buf
# targets
all: $(BINARIES)
clean:
rm -f $(BINARIES) *.d *.o
install:
install -D -m 0755 libnss_rainbow.so.2 $(LIBDIR)/libnss_rainbow.so.2
# objects
%.o: %.c
$(CC) $(ALLCFLAGS) -c -o $@ $<
# linked binaries
test_endgrent: $(TEST_ENDGRENT_OBJS)
$(CC) $(ALLCFLAGS) -o $@ $^
test_slist: $(TEST_SLIST_OBJS)
$(CC) $(ALLCFLAGS) -o $@ $^
test_nat: $(TEST_NAT_OBJS)
$(CC) $(ALLCFLAGS) -o $@ $^
test_format_buf: $(TEST_FORMAT_BUF_OBJS)
$(CC) $(ALLCFLAGS) -o $@ $^
uids: $(UIDS_OBJS)
$(CC) $(ALLCFLAGS) -o $@ $^
gids: $(GIDS_OBJS)
$(CC) $(ALLCFLAGS) -o $@ $^
libnss_rainbow.so.2: $(RAINBOW_OBJS)
$(CC) -shared $(LDFLAGS) -o $@ -Wl,-soname,$@ $^
.PHONY: clean install
-include $(ALL_OBJS:%.o=%.d)
# vim: noet sts=4 ts=4 sw=4 :
|