forked from mind04/mod-ruid2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (100 loc) · 2.31 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/make -f <
#
# Copyright (C) 2013 Bertrand Jacquin <[email protected]>
NAME = mod_ruid2
VERSION = $(shell git describe --tags --dirty=-dev 2> /dev/null)
SRC = \
mod_ruid2.c
DOC_FILES = \
README \
ruid2.conf
EXTRA_FILES = \
LICENSE \
Makefile
PKG_CONFIG ?= pkg-config
APR_CFLAGS = \
$(shell $(PKG_CONFIG) --cflags apr-1)
APR_LDFLAGS = \
$(shell $(PKG_CONFIG) --libs apr-1)
HTTPD_CFLAGS = \
-I/usr/include/apache2
CAP_LDFLAGS = \
-lcap
CFLAGS ?= \
-W -Wall
SPEC_CFLAGS = \
-DMODULE_NAME='"$(NAME)"' \
-DMODULE_VERSION='"$(VERSION)"' \
-fPIC \
$(HTTPD_CFLAGS) \
$(APR_CFLAGS) \
$(CAP_CFLAGS)
SPEC_LDFLAGS = \
$(HTTPD_LDFLAGS) \
$(APR_LDFLAGS) \
$(CAP_LDFLAGS)
ifdef DEBUG
SPEC_CFLAGS +=\
-DDEBUG \
-g -ggdb
endif # DEBUG
CC ?= cc
STRIP ?= strip
STRIP_FLAGS ?= --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.build-id
INSTALL ?= install
RM ?= rm -f
TAR = tar
XZ = xz
DESTDIR ?=
PREFIX ?= /usr/local
MODDIR ?= $(PREFIX)/lib/apache2/modules
DOCDIR ?= $(PREFIX)/share/doc/$(NAME)
ifeq ($(V),)
Q = @
quiet_cmd = @printf " %-6s %s\n" "$(1)" "$(2)";
endif # $(V)
all: shared
shared: $(NAME).so
dist: $(NAME)-$(VERSION).txz
# Build rules
%.o: %.c
$(call quiet_cmd,CC,$@)
$(Q)$(CC) -c $(SPEC_CFLAGS) $(CFLAGS) -o $@ $<
$(NAME).so: $(SRC:c=o)
$(call quiet_cmd,CC,$@)
$(Q)$(CC) -shared -o $@ $^ $(SPEC_LDFLAGS) $(LDFLAGS)
strip: $(NAME).so
$(call quiet_cmd,STRIP,$<)
$(Q)$(STRIP) $(STRIP_FLAGS) $<
# Archiving rules
$(NAME)-$(VERSION).tar: $(SRC) $(EXTRA_FILES) $(DOC_FILES)
$(call quiet_cmd,TAR,$@)
$(Q)$(TAR) cf $@ \
--transform "s,^,$(NAME)-$(VERSION)/," \
--force-local --numeric-owner \
$^
%.txz: %.tar
$(call quiet_cmd,XZ,$@)
$(Q)$(XZ) -c > $@ < $<
# Install rules
install: \
$(DESTDIR)$(MODDIR)/$(NAME).so \
$(addprefix $(DESTDIR)$(DOCDIR)/,$(DOC_FILES))
$(DESTDIR)$(MODDIR)/$(NAME).so: $(NAME).so
$(call quiet_cmd,INSTALL,$@)
$(Q)$(INSTALL) -D -m 444 $< $@
$(DESTDIR)$(DOCDIR)/%: %
$(call quiet_cmd,INSTALL,$@)
$(Q)$(INSTALL) -D -m 444 $< $@
# Cleanup rules
clean:
$(call quiet_cmd,RM,$(SRC:c=o))
$(Q)$(RM) $(SRC:c=o)
$(call quiet_cmd,RM,$(NAME).so)
$(Q)$(RM) $(NAME).so
distclean: clean
$(call quiet_cmd,RM,$(NAME)-$(VERSION).tar)
$(Q)$(RM) $(NAME)-$(VERSION).tar
$(call quiet_cmd,RM,$(NAME)-$(VERSION).txz)
$(Q)$(RM) $(NAME)-$(VERSION).txz
.PHONY: strip