1 | # $Id: Makefile 405 2024-11-03 13:49:26Z nishi $
|
---|
2 |
|
---|
3 | PWD = `pwd`
|
---|
4 | PLATFORM = generic
|
---|
5 | PLATFORM_IDENT = NOT_WINDOWS
|
---|
6 | PREFIX = /usr/local
|
---|
7 | MODULE = ./Module
|
---|
8 | OBJ = o
|
---|
9 |
|
---|
10 | include Platform/$(PLATFORM).mk
|
---|
11 |
|
---|
12 | FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) PREFIX=$(PREFIX)
|
---|
13 |
|
---|
14 | .PHONY: all prepare-config format clean ./Server ./Common ./Module get-version src-archive
|
---|
15 |
|
---|
16 | all: ./Server $(MODULE)
|
---|
17 |
|
---|
18 | prepare-config:
|
---|
19 | if [ '!' -f config.h ]; then cp config.h.tmpl config.h ; fi
|
---|
20 |
|
---|
21 | src-archive: clean
|
---|
22 | @svn cleanup --remove-unversioned
|
---|
23 | cp -rf . /tmp/tewi-`grep "define TW_VERSION" Server/tw_version.h | grep -Eom 1 '"[^\]+' | sed 's/^"//g'`
|
---|
24 | cd /tmp && tar --exclude .github -czvf tewi-`grep "define TW_VERSION" tewi-*/Server/tw_version.h | grep -Eom 1 '"[^\]+' | sed 's/^"//g'`.tar.gz tewi-`grep "define TW_VERSION" tewi-*/Server/tw_version.h | grep -Eom 1 '"[^\]+' | sed 's/^"//g'`
|
---|
25 | mv /tmp/tewi-`grep "define TW_VERSION" Server/tw_version.h | grep -Eom 1 '"[^\]+' | sed 's/^"//g'`.tar.gz ./
|
---|
26 | rm -rf /tmp/tewi-*
|
---|
27 |
|
---|
28 | ./Tool/option: ./Tool/option.c config.h prepare-config
|
---|
29 | cc -o $@ ./Tool/option.c
|
---|
30 |
|
---|
31 | ./Tool/genconf: ./Tool/genconf.c config.h prepare-config
|
---|
32 | cc -o $@ ./Tool/genconf.c
|
---|
33 |
|
---|
34 | ./Tool/itworks: ./Tool/itworks.c config.h prepare-config
|
---|
35 | cc -o $@ ./Tool/itworks.c
|
---|
36 |
|
---|
37 | ./Server:: ./Common ./Tool/option ./Tool/genconf ./Tool/itworks prepare-config
|
---|
38 | $(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../ $(PLATFORM_IDENT) $(OBJ)`" EXTLIBS="`./Tool/option libs ../ $(PLATFORM_IDENT) $(OBJ)`" EXTCFLAGS="`./Tool/option cflags ../ $(PLATFORM_IDENT) $(OBJ)`" EXTLDFLAGS="`./Tool/option ldflags ../ $(PLATFORM_IDENT) $(OBJ)`"
|
---|
39 |
|
---|
40 | ./Module:: ./Common prepare-config
|
---|
41 | $(MAKE) -C $@ $(FLAGS)
|
---|
42 |
|
---|
43 | ./Common:: prepare-config
|
---|
44 | $(MAKE) -C $@ $(FLAGS)
|
---|
45 |
|
---|
46 | ./README: ./README.tmpl ./Server/tw_version.h
|
---|
47 | sed "s/@VERSION@/`grep "define TW_VERSION" Server/tw_version.h | grep -Eom 1 '"[^\]+' | sed 's/^"//g'`/g" ./README.tmpl > $@
|
---|
48 |
|
---|
49 | install: all ./Tool/genconf ./Tool/itworks
|
---|
50 | -mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib/tewi $(DESTDIR)$(PREFIX)/etc $(DESTDIR)$(PREFIX)/www
|
---|
51 | if [ '!' -f $(DESTDIR)$(PREFIX)/etc/tewi.conf ]; then ( ./Tool/genconf $(PREFIX) lib/tewi `echo $(LIBSUF) | sed 's/\.//g'` > $(DESTDIR)$(PREFIX)/etc/tewi.conf || ( rm $(DESTDIR)$(PREFIX)/etc/tewi.conf ; exit 1 ) ) ; fi
|
---|
52 | cp mime.types $(DESTDIR)$(PREFIX)/
|
---|
53 | if [ '!' -f $(DESTDIR)$(PREFIX)/www/index.html ]; then ( ./Tool/itworks > $(DESTDIR)$(PREFIX)/www/index.html || ( rm $(DESTDIR)$(PREFIX)/www/index.html ; exit 1 ) ) ; fi
|
---|
54 | if [ '!' -f $(DESTDIR)$(PREFIX)/www/pbtewi.gif ]; then ( cp Binary/pbtewi.gif $(DESTDIR)$(PREFIX)/www/ || ( rm $(DESTDIR)$(PREFIX)/www/pbtewi.gif ; exit 1 ) ) ; fi
|
---|
55 | -cp ./Server/tewi $(DESTDIR)$(PREFIX)/bin/
|
---|
56 | -cp ./Server/tewi.exe $(DESTDIR)$(PREFIX)/bin/
|
---|
57 | -cp ./Server/tewi.nlm $(DESTDIR)$(PREFIX)/bin/
|
---|
58 | -cp ./Module/*.so $(DESTDIR)$(PREFIX)/lib/tewi/
|
---|
59 | -cp ./Module/*.dll $(DESTDIR)$(PREFIX)/lib/tewi/
|
---|
60 | -cp ./Module/*.nlm $(DESTDIR)$(PREFIX)/lib/tewi/
|
---|
61 |
|
---|
62 | format:
|
---|
63 | clang-format --verbose -i `find ./Server ./Common ./Module ./Tool "(" -name "*.c" -or -name "*.h" ")" -and -not -name "strptime.*"` config.h
|
---|
64 |
|
---|
65 | get-version:
|
---|
66 | @grep "define TW_VERSION" Server/tw_version.h | grep -Eom 1 '"[^\]+' | sed 's/^"//g'
|
---|
67 |
|
---|
68 | clean:
|
---|
69 | $(MAKE) -C ./Server $(FLAGS) clean
|
---|
70 | $(MAKE) -C ./Module $(FLAGS) clean
|
---|
71 | $(MAKE) -C ./Common $(FLAGS) clean
|
---|
72 | rm -f ./Tool/option ./Tool/genconf ./Tool/itworks
|
---|