blob: 17600a1e895eb5e1a28d18fd2b36f4c11f4b01af (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
WARNFLAGS = \
-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
# if you invoke make as 'make V=1' it will verbosely report on what it
# is doing, otherwise it defaults to quiet/pretty mode, which makes
# errors _much_ easier to see
ifneq ($V, 1)
MAKEFLAGS = -s
endif
# 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
@echo " CC $@"
$(CC) $(ALLCFLAGS) -c -o $@ $<
# linked binaries
test_endgrent: $(TEST_ENDGRENT_OBJS)
@echo " LD $@"
$(CC) $(ALLCFLAGS) -o $@ $^
test_slist: $(TEST_SLIST_OBJS)
@echo " LD $@"
$(CC) $(ALLCFLAGS) -o $@ $^
test_nat: $(TEST_NAT_OBJS)
@echo " LD $@"
$(CC) $(ALLCFLAGS) -o $@ $^
test_format_buf: $(TEST_FORMAT_BUF_OBJS)
@echo " LD $@"
$(CC) $(ALLCFLAGS) -o $@ $^
uids: $(UIDS_OBJS)
@echo " LD $@"
$(CC) $(ALLCFLAGS) -o $@ $^
gids: $(GIDS_OBJS)
@echo " LD $@"
$(CC) $(ALLCFLAGS) -o $@ $^
libnss_rainbow.so.2: $(RAINBOW_OBJS)
@echo " LD $@"
$(CC) -shared $(LDFLAGS) -o $@ -Wl,-soname,$@ $^
.PHONY: clean install
-include $(ALL_OBJS:%.o=%.d)
# vim: noet sts=4 ts=4 sw=4 :
|