summaryrefslogtreecommitdiff
path: root/Makefile
blob: beb18b123602a2456d99f51eddf8104c5d2e510a (plain) (blame)
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
.POSIX:
DATE         = 1970-01-01
VERSION      = 0.1.0
NAME         = papo
NAME_UC      = $(NAME)
URL          = papo.im
LIST         = list@$(URL)
TRANSLATIONS =
## Installation prefix.  Defaults to "/usr".
PREFIX       = /usr
BINDIR       = $(PREFIX)/bin
LIBDIR       = $(PREFIX)/lib
JSLIBDIR     = $(LIBDIR)/node_modules/$(NAME)
SHAREDIR     = $(PREFIX)/share
LOCALEDIR    = $(SHAREDIR)/locale
MANDIR       = $(SHAREDIR)/man
## Where to store the installation.  Empty by default.
DESTDIR      =
JSIMPL       = node



.SUFFIXES:
.SUFFIXES: .in

.in:
	sed \
		-e 's:@VERSION@:$(VERSION):g' \
		-e 's:@DATE@:$(DATE):g'       \
		-e 's:@NAME@:$(NAME):g'       \
		-e 's:@LIST@:$(LIST):g'       \
		-e 's:@URL@:$(URL):g'         \
		< $< > $@
	if [ -x $< ]; then chmod +x $@; fi



manpages.en.in = \
	doc/$(NAME).README.en.7.in    \
	doc/$(NAME).CHANGELOG.en.7.in \
	doc/$(NAME).TODOs.en.7.in     \
	doc/$(NAME).en.1.in           \
	doc/$(NAME).tutorial.en.7.in  \
	doc/$(NAME).recipes.en.7.in   \
	doc/$(NAME).why.en.7.in
manpages.in = $(manpages.en.in)
manpages = $(manpages.in:.in=)

sources.js = \
	src/compat.js     \
	src/utils.js      \
	src/server/web.js \
	src/client.js     \

tests.js = \
	tests/js/compat.js     \
	tests/js/utils.js      \
	tests/js/server/web.js \


sources = \
	$(sources.js) \


derived-assets = \
	$(manpages) \



## Default target.  Builds all artifacts required for testing
## and installation.
all: $(derived-assets)


$(manpages): Makefile



.SUFFIXES: .js .js-t
tests.js-t = $(tests.js:.js=.js-t)
$(tests.js-t):
	$(JSIMPL) tests/runner.js $*.js

check-t: $(tests.js-t)



## Run all tests.  Each test suite is isolated, so that a parallel
## build can run tests at the same time.  The required artifacts
## are created if required.
check: check-t


## Remove *all* derived artifacts produced during the build.
## A dedicated test asserts that this is always true.
clean:
	rm -rf $(derived-assets)


## Installs into $(DESTDIR)$(PREFIX).  Its dependency target
## ensures that all installable artifacts are crafted beforehand.
install: all
	mkdir -p \
		'$(DESTDIR)$(BINDIR)' \
		'$(DESTDIR)$(JSLIBDIR)'/src
	cp package.json '$(DESTDIR)$(JSLIBDIR)'
	cp src/*.js     '$(DESTDIR)$(JSLIBDIR)'/src
	ln -frs '$(DESTDIR)$(JSLIBDIR)'/src/cli.js '$(DESTDIR)$(BINDIR)'/$(NAME)
	sh tools/manpages.sh -ip '$(DESTDIR)$(MANDIR)' $(manpages)

## Uninstalls from $(DESTDIR)$(PREFIX).  This is a perfect mirror
## of the "install" target, and removes *all* that was installed.
## A dedicated test asserts that this is always true.
uninstall:
	rm -f \
		'$(DESTDIR)$(BINDIR)'/$(NAME)
	rm -rf '$(DESTDIR)$(JSLIBDIR)'
	sh tools/manpages.sh -up '$(DESTDIR)$(MANDIR)' $(manpages)


run-ircd:
	$(JSIMPL) src/server/web.js server -l http://localhost:3000

run-web:
	$(JSIMPL) src/server/web.js server -l http://localhost:3003

## Run the web and IRC server locally
run:
	$(MAKE) run-ircd & $(MAKE) run-web & wait


MAKEFILE = Makefile
## Show this help.
help:
	cat $(MAKEFILE) | sh tools/makehelp.sh


ALWAYS: