forked from naviserver-project/naviserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
332 lines (286 loc) · 11.8 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# The Initial Developer of the Original Code and related documentation
# is America Online, Inc. Portions created by AOL are Copyright (C) 1999
# America Online, Inc. All Rights Reserved.
#
#
#
#
MAN_CSS=man.css
HEADER_INC=header.inc
NSBUILD=1
include include/Makefile.global
dirs = nsthread nsd nssock nscgi nscp nslog nsperm nsdb nsdbtest nsssl
# Unix only modules
ifeq (,$(findstring MINGW,$(uname)))
dirs += nsproxy
endif
distfiles = $(dirs) doc tcl contrib include tests win win32 configure m4 \
Makefile autogen.sh install-sh missing aclocal.m4 configure.ac \
config.guess config.sub \
README NEWS sample-config.tcl.in simple-config.tcl openacs-config.tcl \
nsd-config.tcl index.adp license.terms naviserver.rdf naviserver.rdf.in \
version_include.man.in bitbucket-install.tcl
all:
@for i in $(dirs); do \
( cd $$i && $(MAKE) all ) || exit 1; \
done
help:
@echo 'Commonly used make targets:'
@echo ' all - build program and documentation'
@echo ' install - install program and man pages under $(NAVISERVER)'
@echo ' test - run all tests in the automatic test suite'
@echo ' gdbtest - run all tests, under the control of the debugger'
@echo ' runtest - start the server in interactive command mode'
@echo ' gdbruntest - start the server in command mode, under the debugger'
@echo ' memcheck - run all tests, under the valgrind memory checker'
@echo ' build-doc - build the html and nroff documentation'
@echo ' dist - create a source tarball naviserver-'$(NS_PATCH_LEVEL)'.tar.gz'
@echo ' clean - remove files created by other targets'
@echo
@echo 'Example for a system-wide installation under /usr/local/ns:'
@echo ' make all && su -c "make install"'
@echo
@echo 'Example for running selected test in the test suite, under the debugger:'
@echo ' make gdbtest TESTFLAGS="-verbose start -file cookies.test -match cookie-2.*"'
@echo
install: install-dirs install-include install-tcl install-modules \
install-config install-doc install-examples install-notice
HAVE_NSADMIN := $(shell id -u nsadmin 2> /dev/null)
install-notice:
@echo ""
@echo ""
@echo "Congratulations, you have installed NaviServer."
@echo ""
@if [ "`whoami`" = "root" ]; then \
if [ "x${HAVE_NSADMIN}" = "x" ] ; then \
echo " When running as root, the server needs an unprivileged user to be"; \
echo " specified (e.g. nsadmin). This user can be created on a Linux-like system with"; \
echo " the command"; \
echo ""; \
echo " useradd nsadmin"; \
echo ""; \
else \
if [ ! `sudo -u nsadmin test -w $(NAVISERVER)/logs && echo 1` ] ; then \
echo "The permissions for log directory have to be set up:"; \
echo ""; \
echo " chown -R nsadmin:nsadmin $(NAVISERVER)/logs"; \
echo ""; \
fi; \
fi; \
user="-u nsadmin"; \
fi; \
echo "You can now run NaviServer by typing the following command: "; \
echo ""; \
echo " $(NAVISERVER)/bin/nsd $$user -t $(NAVISERVER)/conf/nsd-config.tcl -f"; \
echo ""; \
echo "As a next step, you need to configure the server according to your needs."; \
echo "Consult the sample configuration files in $(NAVISERVER)/conf/ as a reference."; \
echo ""
install-dirs: all
@for i in bin lib logs include tcl pages conf modules modules/tcl cgi-bin; do \
$(MKDIR) $(DESTDIR)$(NAVISERVER)/$$i; \
done
install-config: all
@mkdir -p $(DESTDIR)$(NAVISERVER)/conf $(DESTDIR)$(NAVISERVER)/pages/
@for i in returnnotice.adp nsd-config.tcl sample-config.tcl simple-config.tcl openacs-config.tcl ; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(NAVISERVER)/conf/; \
done
@for i in index.adp bitbucket-install.tcl; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(NAVISERVER)/pages/; \
done
$(INSTALL_SH) install-sh $(DESTDIR)$(INSTBIN)/
install-modules: all
@for i in $(dirs); do \
(cd $$i && $(MAKE) install) || exit 1; \
done
install-tcl: all
@for i in tcl/*.tcl; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(NAVISERVER)/tcl/; \
done
install-include: all
@for i in include/*.h include/Makefile.global include/Makefile.module; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(INSTHDR)/; \
done
install-tests:
$(CP) tests $(INSTSRVPAG)
install-doc:
@if [ -d doc/html ]; then \
$(MKDIR) $(DESTDIR)$(NAVISERVER)/pages/doc ; \
$(MKDIR) $(DESTDIR)$(NAVISERVER)/pages/doc/naviserver ; \
$(CP) doc/html/* $(DESTDIR)$(NAVISERVER)/pages/doc ; \
$(CP) contrib/banners/*.png $(DESTDIR)$(NAVISERVER)/pages/doc ; \
$(CP) doc/src/$(MAN_CSS) $(DESTDIR)$(NAVISERVER)/pages/doc/naviserver/ ; \
echo "\nThe documentation is installed under: $(DESTDIR)$(NAVISERVER)/pages/doc" ; \
else \
echo "\nNo documentation is installed locally; either generate the documentation with" ; \
echo " make build-doc"; \
echo "(which requires tcllib to be installed, such that dtplite can be used for the generation)" ; \
echo "or use the online documentation from https://naviserver.sourceforge.io/n/toc.html" ; \
fi;
install-examples:
@$(MKDIR) $(DESTDIR)$(NAVISERVER)/pages/examples
@for i in contrib/examples/*.adp contrib/examples/*.tcl; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(NAVISERVER)/pages/examples/; \
done
# On some systems you may need a special shell script to control the
# PATH seen by dtplite, as that influences which versions of tclsh and
# Tcllib dtplite uses. I personally found it necessary to use a
# one-line script like this for the DTPLITE command:
# env PATH=/usr/sbin:/usr/bin:/sbin:/bin dtplite "$@"
# [email protected], 2014/08/27 10:52 EDT
ifeq ($(DTPLITE),)
DTPLITE=dtplite
else
# Do nothing, use the environment variable as is.
endif
build-doc:
$(RM) doc/html doc/man doc/tmp
$(MKDIR) doc/html doc/man doc/tmp
@for srcdir in nscgi \
nslog \
nsdb \
nsproxy \
nscp \
nsperm \
nssock \
nsssl \
doc/src/manual \
doc/src/naviserver \
modules/nsexpat \
modules/nsconfigrw \
modules/nsdbi \
modules/nsloopctl \
modules/nsvfs; do \
if [ -d $$srcdir ]; then \
echo $$srcdir; \
$(MKDIR) doc/tmp/`basename $$srcdir`; \
find $$srcdir -name '*.man' -exec $(CP) "{}" doc/tmp/`basename $$srcdir` ";"; \
fi; \
done
$(CP) doc/images/manual/*.png doc/tmp/manual/
@cd doc/tmp; \
for srcdir in `ls`; do \
echo $$srcdir; \
if [ -f $$srcdir/version_include.man ]; then \
$(CP) $$srcdir/version_include.man .; \
else \
$(CP) ../../version_include.man .; \
fi; \
echo $(DTPLITE) -merge -style ../src/$(MAN_CSS) \
-header ../src/$(HEADER_INC) \
-footer ../src/footer.inc \
-o ../html/ html $$srcdir; \
$(DTPLITE) -merge -style ../src/$(MAN_CSS) \
-header ../src/$(HEADER_INC) \
-footer ../src/footer.inc \
-o ../html/ html $$srcdir; \
$(DTPLITE) -merge -o ../man/ nroff $$srcdir; \
done
$(RM) doc/tmp
#
# Testing:
#
NS_TEST_CFG = -u root -c -d -t $(srcdir)/tests/test.nscfg
NS_TEST_ALL = $(srcdir)/tests/all.tcl $(TESTFLAGS)
NS_LD_LIBRARY_PATH = \
LD_LIBRARY_PATH="$(srcdir)/nsd:$(srcdir)/nsthread:$(srcdir)/nsdb:$(srcdir)/nsproxy:$$LD_LIBRARY_PATH" \
DYLD_LIBRARY_PATH="$(srcdir)/nsd:$(srcdir)/nsthread:$(srcdir)/nsdb:$(srcdir)/nsproxy:$$DYLD_LIBRARY_PATH"
EXTRA_TEST_DIRS =
ifneq ($(OPENSSL_LIBS),)
#EXTRA_TEST_DIRS += nsssl
PEM_FILE = tests/testserver/etc/server.pem
PEM_PRIVATE = tests/testserver/etc/myprivate.pem
PEM_PUBLIC = tests/testserver/etc/mypublic.pem
SSLCONFIG = tests/testserver/etc/openssl.cnf
EXTRA_TEST_REQ = $(PEM_FILE)
endif
$(PEM_FILE): $(PEM_PRIVATE)
openssl genrsa 2048 > host.key
openssl req -new -config $(SSLCONFIG) -x509 -nodes -sha1 -days 365 -key host.key > host.cert
cat host.cert host.key > server.pem
rm -rf host.cert host.key
openssl dhparam 1024 >> server.pem
mv server.pem $(PEM_FILE)
$(PEM_PRIVATE):
openssl genrsa -out $(PEM_PRIVATE) 512
openssl rsa -in $(PEM_PRIVATE) -pubout > $(PEM_PUBLIC)
check: test
test: all $(EXTRA_TEST_REQ)
$(NS_LD_LIBRARY_PATH) ./nsd/nsd $(NS_TEST_CFG) $(NS_TEST_ALL)
@for i in $(EXTRA_TEST_DIRS); do \
( cd $$i && $(MAKE) test ) || exit 1; \
done
runtest: all
$(NS_LD_LIBRARY_PATH) ./nsd/nsd $(NS_TEST_CFG)
gdbtest: all
@echo set args $(NS_TEST_CFG) $(NS_TEST_ALL) > gdb.run
$(NS_LD_LIBRARY_PATH) gdb -x gdb.run ./nsd/nsd
rm gdb.run
lldbtest: all
$(NS_LD_LIBRARY_PATH) lldb -- ./nsd/nsd $(NS_TEST_CFG) $(NS_TEST_ALL)
lldb-sample: all
lldb -o run -- $(DESTDIR)$(NAVISERVER)/bin/nsd -f -u nsadmin -t $(DESTDIR)$(NAVISERVER)/conf/nsd-config.tcl
gdbruntest: all
@echo set args $(NS_TEST_CFG) > gdb.run
$(NS_LD_LIBRARY_PATH) gdb -x gdb.run ./nsd/nsd
rm gdb.run
memcheck: all
$(NS_LD_LIBRARY_PATH) valgrind --tool=memcheck ./nsd/nsd $(NS_TEST_CFG) $(NS_TEST_ALL)
helgrind: all
$(NS_LD_LIBRARY_PATH) valgrind --tool=helgrind ./nsd/nsd $(NS_TEST_CFG) $(NS_TEST_ALL)
CPPCHECK_SYS_INCLUDES=-I/usr/include
#CPPCHECK_SYS_INCLUDES=-I`xcrun --show-sdk-path`/usr/include
cppcheck:
$(CPPCHECK) --verbose --inconclusive -j4 --enable=all nscp/*.c nscgi/*.c nsd/*.c nsdb/*.c nsproxy/*.c nssock/*.c nsperm/*.c nsssl/*.c \
-I./include $(CPPCHECK_SYS_INCLUDES) -D__x86_64__ -DNDEBUG $(DEFS)
CLANG_TIDY_CHECKS=
#CLANG_TIDY_CHECKS=-checks=-*,performance-*,portability-*,cert-*,modernize-*
#CLANG_TIDY_CHECKS=-checks=-*,modernize-*,performance-*,portability-*,cert-*
#CLANG_TIDY_CHECKS=-checks=-*,bugprone-*
clang-tidy:
clang-tidy-mp-14 nscp/*.c nscgi/*.c nsd/*.c nsdb/*.c nsproxy/*.c nssock/*.c nsperm/*.c \
$(CLANG_TIDY_CHECKS) -- \
-I./include -I/usr/include $(DEFS)
checkexports: all
@for i in $(dirs); do \
nm -p $$i/*${LIBEXT} | awk '$$2 ~ /[TDB]/ { print $$3 }' | sort -n | uniq | grep -v '^[Nn]s\|^TclX\|^_'; \
done
clean:
@for i in $(dirs); do \
(cd $$i && $(MAKE) clean) || exit 1; \
done
clean-bak: clean
@find . -name '*~' -exec rm "{}" ";"
distclean: clean
$(RM) config.status config.log config.cache autom4te.cache aclocal.m4 configure \
include/{Makefile.global,Makefile.module,config.h,config.h.in,stamp-h1} \
naviserver-$(NS_PATCH_LEVEL).tar.gz sample-config.tcl
config.guess:
wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
config.sub:
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
dist: config.guess config.sub clean
$(RM) naviserver-$(NS_PATCH_LEVEL)
$(MKDIR) naviserver-$(NS_PATCH_LEVEL)
$(CP) $(distfiles) naviserver-$(NS_PATCH_LEVEL)
$(RM) naviserver-$(NS_PATCH_LEVEL)/include/{config.h,Makefile.global,Makefile.module,stamp-h1}
$(RM) naviserver-$(NS_PATCH_LEVEL)/*/*-{debug,gn}
$(RM) naviserver-$(NS_PATCH_LEVEL)/tests/testserver/access.log
git log --date-order --name-status --date=short >naviserver-$(NS_PATCH_LEVEL)/ChangeLog
if [ -f $(HOME)/scripts/fix-typos.tcl ]; then \
(cd naviserver-$(NS_PATCH_LEVEL)/; tclsh $(HOME)/scripts/fix-typos.tcl -name Change\*) \
fi;
find naviserver-$(NS_PATCH_LEVEL) -type f -name '.[a-zA-Z_]*' -exec rm \{} \;
find naviserver-$(NS_PATCH_LEVEL) -name '*-original' -exec rm \{} \;
find naviserver-$(NS_PATCH_LEVEL) -name '[a-z]*.pem' -exec rm \{} \;
find naviserver-$(NS_PATCH_LEVEL) -name '*.c-*' -exec rm \{} \;
find naviserver-$(NS_PATCH_LEVEL) -name '*.h-*' -exec rm \{} \;
find naviserver-$(NS_PATCH_LEVEL) -name '*~' -exec rm \{} \;
tar czf naviserver-$(NS_PATCH_LEVEL).tar.gz --no-xattrs --disable-copyfile --exclude="._*" naviserver-$(NS_PATCH_LEVEL)
$(RM) naviserver-$(NS_PATCH_LEVEL)
.PHONY: all install install-binaries install-doc install-tests clean distclean