forked from urbanserj/entente
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (49 loc) · 1.59 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
64
TARGET=lightldapd
CC=cc
AR=ar
CFLAGS=-Wall -Wextra
LDFLAGS=-lev -lpam -lmbedtls -lmbedx509 -lmbedcrypto -lcrypt
SRCS=main.c ldap_server.c nss2ldap.c pam.c ssl.c ranges.c log.c
TESTS=dlist_test ranges_test buffer_test log_test
CHECKS=$(TESTS:_test=_check)
.PHONY: all debug clean install debian debclean tidy check
all: CFLAGS += -Wno-unused-parameter -DNDEBUG
all: $(TARGET)
$(TARGET): $(SRCS) asn1/LDAP.a
$(CC) $(CFLAGS) -Iasn1/ -o $(TARGET) $^ $(LDFLAGS)
asn1/LDAP.a: | asn1
cd asn1 && $(CC) -I. -D_DEFAULT_SOURCE $(CFLAGS) -c *.c
$(AR) rcs $@ asn1/*.o
asn1:
mkdir asn1 && ( cd asn1; asn1c -pdu=auto -fcompound-names ../ldap.asn1; rm converter-sample.c )
debug: CFLAGS += -DDEBUG
debug: ${TARGET}
clean:
rm -rf $(TARGET) $(TESTS) asn1/ *~
install:
if [ -z "$(DESTDIR)" ]; then exit 1; fi
mkdir -p $(DESTDIR)/usr/sbin
cp $(TARGET) $(DESTDIR)/usr/sbin
mkdir -p $(DESTDIR)/etc/init.d
cp $(TARGET).init.d $(DESTDIR)/etc/init.d/$(TARGET)
mkdir -p $(DESTDIR)/etc/default
cp $(TARGET).default $(DESTDIR)/etc/default/$(TARGET)
debian:
dpkg-buildpackage -rfakeroot -I.*
debclean:
debian/rules clean
tidy:
# Reformat all code and comments to preferred coding style."
tidyc -ppi0 -R -C -T '/(ev|mbedtls|ldap)_\w+/' -T 'ENTRY' *.[ch]
# Note we depend on TESTS to compile them all first.
check: $(TESTS) $(CHECKS)
# Generic rule for compiling tests.
%_test: CFLAGS += -DDEBUG
%_test: %_test.c
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Generic rule for running tests.
%_check: %_test
@./$< && echo "$<: Passed" >&2;
# Additional dependencies needed for particular tests.
ranges_test: ranges.c
log_test: log.c