summaryrefslogtreecommitdiff
path: root/Makefile.win
blob: 5a2a73ab17c4042fe9ba4e9012ff179b12ddd7c6 (plain)
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
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#   http:\\www.apache.org\licenses\LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

include version.mk

SHELL=cmd.exe
REBAR?=$(shell where rebar.cmd)
IN_RELEASE = $(shell if not exist .git echo true)
ifeq ($(IN_RELEASE), true)
COUCHDB_VERSION_SUFFIX=
COUCHDB_VERSION = $(vsn_major).$(vsn_minor).$(vsn_patch)
else
COUCHDB_VERSION_SUFFIX = -$(shell git rev-parse --short --verify HEAD)
COUCHDB_VERSION = $(vsn_major).$(vsn_minor).$(vsn_patch)$(COUCHDB_VERSION_SUFFIX)
endif

DESTDIR=

# Rebar options
apps=
skip_deps=folsom,meck,mochiweb,triq,snappy
suites=
tests=

# no sed on Windows, hard code since apps\suites\tests are empty
EUNIT_OPTS=skip_deps=$(skip_deps)
DIALYZE_OPTS=skip_deps=$(skip_deps)

################################################################################
# Main commands
################################################################################


.PHONY: all
# target: all - Build everything
all: couch fauxton docs


################################################################################
# Building
################################################################################


.PHONY: couch
# target: couch - Build CouchDB core
couch: config.erl
	@set COUCHDB_VERSION=$(COUCHDB_VERSION) && $(REBAR) compile
	@copy src\couch\priv\couchjs.exe bin


.PHONY: docs
# target: docs - Build documentation
ifeq ($(IN_RELEASE), true)
docs: share\docs\html
else
docs: src\docs\build
endif

.PHONY: fauxton
# target: fauxton - Build Fauxton web UI
fauxton: share\www


################################################################################
# Testing
################################################################################


.PHONY: check
# target: check - Test everything
check: all
	@$(MAKE) -f Makefile.win eunit
	@$(MAKE) -f Makefile.win javascript


.PHONY: eunit
# target: eunit - Run EUnit tests, use EUNIT_OPTS to provide custom options
eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config")
eunit: export BUILDDIR = $(shell echo %cd%)
eunit:
	@$(REBAR) setup_eunit 2> nul
	@$(REBAR) -r eunit $(EUNIT_OPTS)


.PHONY: javascript
# target: javascript - Run JavaScript test suites or specific ones defined by suites option
javascript:
	-@mkdir share\www\script\test
ifeq ($(IN_RELEASE), true)
	@copy test\javascript\tests\lorem*.txt share\www\script\test
else
	-@mkdir src\fauxton\dist\release\test
	@copy test\javascript\tests\lorem*.txt src\fauxton\dist\release\test
endif
	-@rmdir /s/q dev\lib
	@python dev\run -n 1 -q --with-admin-party-please \
		--enable-erlang-views \
		-c startup_jitter=0 \
		python test\javascript\run $(suites)


.PHONY: check-qs
# target: check-qs - Run query server tests (ruby and rspec required!)
check-qs:
	@QS_LANG=js rspec test\view_server\query_server_spec.rb


################################################################################
# Developing
################################################################################


.PHONY: build-plt
# target: build-plt - Build project-specific PLT
build-plt:
	@$(REBAR) -r build-plt $(DIALYZE_OPTS)


.PHONY: check-plt
# target: check-plt - Check the PLT for consistency and rebuild it if it is not up-to-date
check-plt:
	@$(REBAR) -r check-plt $(DIALYZE_OPTS)


.PHONY: dialyze
# target: dialyze - Analyze the code for discrepancies
dialyze: .rebar
	@$(REBAR) -r dialyze $(DIALYZE_OPTS)


.PHONY: introspect
# target: introspect - Check for commits difference between rebar.config and repository
introspect:
	@$(REBAR) -r update-deps
	@escript build-aux\introspect


################################################################################
# Distributing
################################################################################


.PHONY: dist
# target: dist - Make release tarball
dist: all
	@.\build-aux\couchdb-build-release.sh $(COUCHDB_VERSION)

	@copy -r share\www apache-couchdb-$(COUCHDB_VERSION)\share
	@mkdir apache-couchdb-$(COUCHDB_VERSION)\share\docs\html
	@copy -r src\docs\build\html apache-couchdb-$(COUCHDB_VERSION)\share\docs

	@mkdir apache-couchdb-$(COUCHDB_VERSION)\share\docs\man
	@copy src\docs\build\man\apachecouchdb.1 apache-couchdb-$(COUCHDB_VERSION)\share\docs\man

	@tar czf apache-couchdb-$(COUCHDB_VERSION).tar.gz apache-couchdb-$(COUCHDB_VERSION)
	@echo "Done: apache-couchdb-$(COUCHDB_VERSION).tar.gz"


.PHONY: release
# target: release - Create an Erlang release including CouchDB!
-include install.mk
release: all
	@echo Installing CouchDB into rel\couchdb\ ...
	-@rmdir /s/q rel\couchdb
	@$(REBAR) generate
	@copy src\couch\priv\couchjs.exe rel\couchdb\bin

ifeq ($(with_fauxton), 1)
	-@mkdir rel\couchdb\share
	-@xcopy share\www rel\couchdb\share\www /E/I
endif

ifeq ($(with_docs), 1)
	-@mkdir rel\couchdb\share\www\docs
	-@mkdir rel\couchdb\share\docs
ifeq ($(IN_RELEASE), true)
	@xcopy share\docs\html rel\couchdb\share\www\docs /E /I
	@copy share\docs\man\apachecouchdb.1 rel\couchdb\share\docs\couchdb.1
else
	@xcopy src\docs\build\html rel\couchdb\share\www\docs /E /I
	@copy src\docs\build\man\apachecouchdb.1 rel\couchdb\share\docs\couchdb.1
endif
endif

	@echo ... done
	@echo .
	@echo     You can now copy the rel\couchdb directory anywhere on your system.
	@echo     Start CouchDB with .\bin\couchdb.cmd from within that directory.
	@echo .

.PHONY: install
# target: install- install CouchDB :)
install:
	@echo .
	@echo Notice: There is no 'make install' command for CouchDB 2.0 yet.
	@echo .
	@echo     To install CouchDB into your system, copy the rel\couchdb
	@echo     to your desired installation location. For example:
	@echo     xcopy /E rel\couchdb \usr\local\lib
	@echo .

################################################################################
# Cleaning
################################################################################


.PHONY: clean
# target: clean - Remove build artifacts
clean:
	@$(REBAR) -r clean
	-@rmdir /s/q .rebar
	-@del /f/q bin\couchjs.exe
	-@rmdir /s/q src\*\ebin
	-@rmdir /s/q src\*\.rebar
	-@del /f/q/s src\*.dll
	-@del /f/q src\couch\priv\*.exe
	-@del /f/q share\server\main.js share\server\main-coffee.js
	-@rmdir /s/q tmp 
	-@rmdir /s/q dev\data
	-@rmdir /s/q dev\lib
	-@rmdir /s/q dev\logs
	-@del /f/q src\couch\priv\couch_js\config.h
	-@del /f/q dev\boot_node.beam dev\pbkdf2.pyc log\crash.log


.PHONY: distclean
# target: distclean - Remove build and release artifacts
distclean: clean
	-@del install.mk
	-@del config.erl
	-@del rel\couchdb.config
ifneq ($(IN_RELEASE), true)
# when we are in a release, don’t delete the
# copied sources, generated docs, or fauxton
	-@rmdir /s/q rel\couchdb
	-@rmdir /s/q share\www
	-@rmdir /s/q src\docs
endif


.PHONY: devclean
# target: devclean - Remove dev cluster artifacts
devclean:
	-@rmdir /s/q dev\lib\node1\data
	-@rmdir /s/q dev\lib\node2\data
	-@rmdir /s/q dev\lib\node3\data


.PHONY: uninstall
# target: uninstall - Uninstall CouchDB :-(
uninstall:
	-@rmdir /s/q $(DESTDIR)\$(install_dir)
	-@del $(DESTDIR)\$(bin_dir)\couchdb
	-@rmdir /s/q $(DESTDIR)\$(libexec_dir)
	-@rmdir /s/q $(DESTDIR)\$(sysconf_dir)
	-@rmdir /s/q $(DESTDIR)\$(data_dir)
	-@rmdir /s/q $(DESTDIR)\$(doc_dir)
	-@rmdir /s/q $(DESTDIR)\$(html_dir)
	-@rmdir /s/q $(DESTDIR)\$(man_dir)


################################################################################
# Misc
################################################################################


.rebar: build-plt

config.erl:
	@echo Apache CouchDB has not been configured.
	@echo Try "powershell -ExecutionPolicy Bypass .\configure.ps1 -?" for help.
	@echo You probably want "powershell -ExecutionPolicy Bypass .\configure.ps1 -WithCurl".
	@echo.
	@false


src\docs\build:
	@echo Building docs...
ifeq ($(with_docs), 1)
	@cd src\docs && make.bat html && make.bat man
endif


share\www:
ifeq ($(with_fauxton), 1)
	@echo "Building Fauxton"
	@cd src\fauxton && npm install --production && .\node_modules\.bin\grunt couchdb
endif