forked from ledgersmb/LedgerSMB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
502 lines (447 loc) · 18.1 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
DIST_VER=$(shell utils/install/build-id)
DIST_DIR=/tmp
ifeq ($(DIST_VER),travis)
DIST_DEPS=cached_dojo
else
DIST_DEPS=dojo
endif
.DEFAULT_GOAL := help
DEB_essential := cpanminus postgresql make gcc libdbd-pg-perl
DEB_essential += starman
DEB_perlmodules := libcgi-emulate-psgi-perl libcgi-simple-perl libconfig-inifiles-perl
DEB_perlmodules += libdbd-pg-perl libdbi-perl libdatetime-perl
DEB_perlmodules += libdatetime-format-strptime-perl libdigest-md5-perl
DEB_perlmodules += libfile-mimeinfo-perl libjson-xs-perl libjson-perl
DEB_perlmodules += liblocale-maketext-perl liblocale-maketext-lexicon-perl
DEB_perlmodules += liblog-log4perl-perl libmime-base64-perl libmime-lite-perl
DEB_perlmodules += libmath-bigint-gmp-perl libmoose-perl libnumber-format-perl
DEB_perlmodules += libpgobject-perl libpgobject-simple-perl libpgobject-simple-role-perl
DEB_perlmodules += libpgobject-util-dbmethod-perl libplack-perl libtemplate-perl
DEB_perlmodules += libnamespace-autoclean-perl libmoosex-nonmoose-perl
DEB_perlmodules += libxml-simple-perl
DEB_feature_PDF := libtemplate-plugin-latex-perl libtex-encode-perl
DEB_feature_PDF := texlive-latex-recommended
DEB_feature_PDF_utf8 := texlive-xetex
DEB_feature_OpenOffice := libopenoffice-oodoc-perl
DEB_feature_PGTAP := pgtap
DEB_feature_XLS :=
# Core packages provided by Fedora 24
RHEL_essential := perl-devel perl-CPAN perl-App-cpanminus
RHEL_essential += postgresql make gcc perl-DBD-Pg
RHEL_essential += perl-Starman
RHEL_perlmodules := perl-CGI-Emulate-PSGI perl-CGI-Simple perl-Config-IniFiles
RHEL_perlmodules += perl-DBD-Pg perl-DBI perl-DateTime perl-DateTime-Format-Strptime
RHEL_perlmodules += perl-Digest-MD5 perl-File-MimeInfo perl-JSON-XS
RHEL_perlmodules += perl-Locale-Maketext perl-Locale-Maketext-Lexicon
RHEL_perlmodules += perl-Log-Log4perl perl-MIME-Base64 perl-MIME-Lite perl-Math-BigInt-GMP
RHEL_perlmodules += perl-Moose perl-Number-Format perl-Plack perl-Template-Toolkit
RHEL_perlmodules += perl-namespace-autoclean perl-MooseX-NonMoose
RHEL_perlmodules += perl-XML-Simple
RHEL_perlmodules += perl-YAML perl-FCGI-ProcManager
RHEL_feature_PDF := perl-TeX-Encode texlive
RHEL_feature_PDF_utf8 :=
RHEL_feature_OpenOffice :=
RHEL_feature_XLS :=
FBSD_essential :=
FBSD_perlmodules :=
FBSD_feature_PDF :=
FBSD_feature_OpenOffice :=
FBSD_feature_XLS :=
APT_GET = sudo apt-get install
YUM = sudo yum install
# Lets try and work out what OS and DISTRO we are running on
# some usefull info here http://linuxmafia.com/faq/Admin/release-files.html
ifeq ($(OS),Windows_NT)
OS := WIN32
OSTYPE := WINDOWS
$(error We currently don't support Windows via this makefile.)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS := LINUX
endif
ifeq ($(UNAME_S),FreeBSD)
OS := FREEBSD
OSTYPE := FREEBSD
endif
ifeq ($(UNAME_S),Darwin)
OS := OSX
OSTYPE := OSX
OSDISTRO := DARWIN
endif
OSDISTRO := $(shell lsb_release -si | tr '[:lower:]' '[:upper:]')
ifndef OSDISTRO
UNAME_V := $(shell uname -v | tr '[:lower:]' '[:upper:]')
ifneq (,$(findstring DEBIAN,$(UNAME_V)))
OSDISTRO := DEBIAN
endif
ifneq (,$(findstring UBUNTU,$(UNAME_V)))
OSDISTRO := UBUNTU
endif
ifneq (,$(findstring LINUXMINT,$(UNAME_V)))
OSDISTRO := LINUXMINT
endif
ifneq (,$(findstring AMZN,$(UNAME_V)))
OSDISTRO := AMAZONLINUX
endif
REDHAT_RELEASE_FILE := $(shell test -r /etc/redhat-release && cat /etc/redhat-release | tr '[:lower:]' '[:upper:]')
ifneq (,$(findstring CENTOS,$(REDHAT_RELEASE_FILE)))
OSDISTRO := CENTOS
endif
ifneq (,$(findstring FEDORA,$(REDHAT_RELEASE_FILE)))
OSDISTRO := FEDORA
endif
# the following are speculative, we need to confirm what is expected.
ifneq (,$(findstring RHEL,$(REDHAT_RELEASE_FILE)))
OSDISTRO := RHEL
endif
ifneq (,$(findstring REDHAT,$(REDHAT_RELEASE_FILE)))
OSDISTRO := REDHAT
endif
SUSE_RELEASE_FILE := $(shell test -r /etc/suse-release && cat /etc/suse-release | tr '[:lower:]' '[:upper:]')
ifneq (,$(findstring SUSE,$(SUSE_RELEASE_FILE)))
OSDISTRO := SUSE
endif
MANDRAKE_RELEASE_FILE := $(shell test -r /etc/mandrake-release && cat /etc/mandrake-release | tr '[:lower:]' '[:upper:]')
ifneq (,$(findstring MANDRAKE,$(MANDRAKE_RELEASE_FILE)))
OSDISTRO := MANDRAKE
endif
OS_RELEASE_FILE := $(shell test -r /etc/os-release && cat /etc/os-release | tr '[:lower:]' '[:upper:]')
ifneq (,$(findstring DEBIAN,$(OS_RELEASE_FILE)))
OSDISTRO := DEBIAN
endif
ifneq (,$(findstring SUSE,$(OS_RELEASE_FILE)))
OSDISTRO := SUSE
endif
endif
ifneq (,$(filter DEBIAN UBUNTU LINUXMINT, $(OSDISTRO)))
OSTYPE := DEBIAN
endif
ifneq (,$(filter SUSE, $(OSDISTRO)))
OSTYPE := SUSE
endif
ifneq (,$(filter MANDRAKE, $(OSDISTRO)))
OSTYPE := MANDRAKE
endif
ifneq (,$(filter GENTOO, $(OSDISTRO)))
OSTYPE := GENTOO
endif
# this filter is speculative, we need to confirm what is expected.
ifneq (,$(filter REDHAT RHEL FEDORA CENTOS AMAZONLINUX, $(OSDISTRO)))
OSTYPE := REDHAT
endif
endif
ifndef OSDISTRO
$(warning We don't know what distro you are running so can't do anything special for it)
endif
ifndef OSTYPE
$(warning We don't know what OSTYPE (eg: debian or redhat) you are running)
$(warning Please report this on the mailing lists or IRC)
$(warning http://ledgersmb.org/topics/support)
$(warning OSTYPE = $(OSTYPE))
$(warning OSDISTRO = $(OSDISTRO))
$(warning UNAME_V = $(UNAME_V))
$(warning REDHAT_RELEASE_FILE = $(REDHAT_RELEASE_FILE))
$(warning SUSE_RELEASE_FILE = $(SUSE_RELEASE_FILE))
$(warning MANDRAKE_RELEASE_FILE = $(MANDRAKE_RELEASE_FILE))
$(warning OS_RELEASE_FILE = $(OS_RELEASE_FILE))
$(error exit)
endif
ifeq ($(OSTYPE),DEBIAN)
OS_feature_PDF := deb_feature_PDF
OS_feature_PDF_utf8 := deb_feature_PDF_utf8
OS_feature_OpenOffice := deb_feature_OpenOffice
OS_feature_XLS := deb_feature_XLS
OS_feature_PGTAP := deb_feature_PGTAP
endif
ifeq ($(OSTYPE),REDHAT)
OS_feature_PDF := rhel_feature_PDF
OS_feature_PDF_utf8 := rhel_feature_PDF_utf8
OS_feature_OpenOffice := rhel_feature_OpenOffice
OS_feature_XLS := rhel_feature_XLS
endif
ifeq ($(OSTYPE),FREEBSD)
OS_feature_PDF := fbsd_feature_PDF
OS_feature_PDF_utf8 := fbsd_feature_PDF_utf8
OS_feature_OpenOffice := fbsd_feature_OpenOffice
OS_feature_XLS := fbsd_feature_XLS
endif
# make help
# Simple Help on installing LedgerSMB and use of this Makefile
# This should always remain the first target
# The first target is the default when make is run with no arguments
define HELP
Help on installing LedgerSMB can be found in
- README.md
- http://ledgersmb.org/topic/installing-ledgersmb-15
The easiest way to use this makefile to install LedgerSMB is simply to run
make all_dependencies
make feature_PDF_utf8 # this is optional and is a large additional download
# see discussion about XeLaTeX and UTF8 at
# http://ledgersmb.org
Help on using this Makefile
The following make targets are available
- help : This help text
- dojo : Builds the minified dojo blob we serve to clients
- cached_dojo : Uses the cached minified dojo, or builds one
- dojo_archive : Builds a cached minified dojo archive
- blacklist : Builds sql blacklist (required after adding functions)
- submodules : Initialises and updates our git submodules
- test : Runs tests
- devtest : Runs all tests including development/author tests
- dist : builds the release distribution archive
- dependencies : Installs all dependencies including cpan ones. (except features)
Preferring system perl modules over cpan ones
It attempts to detect OS type if OSTYPE is not set
Valid OS types are
- debian
- redhat
- freebsd
- debian : installs all apt dependencies for a debian based system except deb_feature_*
- redhat : installs all apt dependencies for an rpm (redhat) based system except rhel_feature_*
- freebsd : installs some known dependencies for a FreeBSD system
- all_dependencies : same as dependencies but adds all features except feature_PDF_utf8
- cpan : installs any remaining perl dependancies using cpanm
- feature_PDF : Install system and cpan packages for generating PDF/Postscript output
- feature_PDF_utf8 : Install system and cpan packages for UTF8 ouput in PDF/Postscript output
- feature_XLS : Install system and cpan packages for generating XLS output
- feature_OpenOffice : Install system and cpan packages for generating OpenOffice output
#############################################################
The following targets would not normally be used manually
#############################################################
- all_debian : same as debian but adds all features except deb_feature_PDF_utf8
- all_redhat : same as redhat but adds all features except rhel_feature_PDF_utf8
- all_freebsd : same as freebsd but adds all features except fbsd_feature_PDF_utf8
- deb_essential : installs just the "can't do without these" dependencies
- deb_perlmodules : installs all known deb packaged perl modules we depend on
- deb_feature_PDF : installs deb packages for generating PDF/Postscript output
- deb_feature_PDF_utf8 : Installs texlive-xetex to allow UTF8 ouput in PDF/Postscript output
- deb_feature_OpenOffice : Installs deb package for generating OpenOffice output
- deb_feature_XLS : Installs deb package for generating XLS output
- rhel_essential : installs just the "can't do without these" dependencies
- rhel_perlmodules : installs all known rpm packaged perl modules we depend on
- rhel_feature_PDF : installs rpm packages for generating PDF/Postscript output
- rhel_feature_PDF_utf8 : Installs texlive-xetex (if available) to allow UTF8 ouput in PDF/Postscript output
- rhel_feature_OpenOffice : Installs rpm package for generating OpenOffice output
- rhel_feature_XLS : Installs deb package for generating XLS output
endef
export HELP
help:
@echo "$$HELP"
$(warning OSTYPE = $(OSTYPE))
$(warning OSDISTRO = $(OSDISTRO))
$(warning REDHAT_RELEASE_FILE = $(REDHAT_RELEASE_FILE))
# make dojo
# builds dojo for production/release
SHELL := /bin/bash
HOMEDIR := ~/dojo_archive
SHA := $(shell find UI/js-src/lsmb UI/js-src/dojo UI/js-src/dijit -exec sha1sum {} + 2>&1 | sort | sha1sum | cut -d' ' -f 1)
ARCHIVE := $(HOMEDIR)/UI_js_$(SHA).tar
TEMP := $(HOMEDIR)/_UI_js_$(SHA).tar
FLAG := $(HOMEDIR)/building_UI_js_$(SHA)
dojo:
rm -rf UI/js/;
cd UI/js-src/lsmb/ \
&& ../util/buildscripts/build.sh --profile lsmb.profile.js \
| egrep -v 'warn\(224\).*A plugin dependency was encountered but there was no build-time plugin resolver. module: (dojo/request;|dojo/request/node;|dojo/request/registry;|dijit/Fieldset;|dijit/RadioMenuItem;|dijit/Tree;|dijit/form/_RadioButtonMixin;)';
cd ../../..
dojo_archive: dojo
#TODO: Protect for concurrent invocations
mkdir -p $(HOMEDIR)
touch $(FLAG)
tar cf $(TEMP) UI/js
mv $(TEMP) $(ARCHIVE)
rm $(FLAG)
cached_dojo:
ifeq ($(wildcard $(ARCHIVE)),)
$(MAKE) dojo_archive
endif
tar xf $(ARCHIVE)
# make blacklist
blacklist:
perl tools/makeblacklist.pl --regenerate
# make pod
#make submodules
# Initialises and updates our git submodules
submodules:
git submodule update --init --recursive
# make dist
# builds release distribution archive
dist: $(DIST_DEPS)
test -d $(DIST_DIR) || mkdir -p $(DIST_DIR)
find . | grep -vE '^.$$|^\./\.|^\./UI/js-src/(dojo|dijit|util)/|\.uncompressed\.js$$|.js.map$$' | tar czf $(DIST_DIR)/ledgersmb-$(DIST_VER).tar.gz --transform 's,^./,ledgersmb/,' --no-recursion --files-from -
clean:
rm -rf inc META.yml MYMETA.yml MYMETA.json blib pm_to_blib
clean-libs:
rm -rf $(shell utils/install/clean-libs)
# Genarate displayable documentation
pod:
rm -rf UI/pod
mkdir UI/pod
utils/pod2projdocs.pl 2>&1 pod2projdocs.log
# make critic
# Little toy for code critique
# Make sure that aspell is installed for your locale (apt install aspell-fr, for example)
# Open UI/pod/critic_html/index.html with prefered browser
critic:
test -d UI/pod || mkdir -p UI/pod
./tools/critic_html/critichtml
# make dependencies
# Installs all dependencies.
# Preferring system perl modules over cpan ones
# It attempts to detect OS type if OSTYPE is not set
# Valid OS types are
# - debian
# - redhat
# - freebsd
ifeq ($(OSTYPE),DEBIAN)
dependencies: debian
all_dependencies: all_debian
endif
ifeq ($(OSTYPE),REDHAT)
dependencies: redhat
all_dependencies: all_redhat
endif
ifeq ($(OSTYPE),FREEBSD)
dependencies: freebsd
all_dependencies: all_freebsd
endif
#OSDISTRO
# make debian
# installs all apt dependencies for a debian system
debian: deb_essential deb_perlmodules
# make debian_all
# installs all apt dependencies for a debian system Including all features except deb_feature_PDF_utf8
all_debian: debian deb_feature_PDF deb_feature_OpenOffice deb_feature_XLS
# make deb_essential
# installs just the "can't do without these" dependencies
deb_essential:
$(APT_GET) $(DEB_essential)
# make deb_perlmodules
# installs all known deb packaged perl modules we depend on
deb_perlmodules:
$(APT_GET) $(DEB_perlmodules)
# make deb_feature_PDF
# installs deb packages for generating PDF/Postscript output
deb_feature_PDF:
$(APT_GET) $(DEB_feature_PDF)
# make deb_feature_PDF_utf8
# Installs texlive-xetex to allow UTF8 ouput in PDF/Postscript output
deb_feature_PDF_utf8: deb_feature_PDF
$(APT_GET) $(DEB_feature_PDF_utf8)
# make deb_feature_OpenOffice
# Installs deb package for generating XLS output
deb_feature_XLS:
$(APT_GET) $(DEB_feature_XLS)
# make deb_feature_XLS
# Installs deb package for generating OpenOffice output
deb_feature_OpenOffice:
$(APT_GET) $(DEB_feature_OpenOffice)
# make deb_feature_pgtab
# Installs deb package for generating pgTap
deb_feature_PGTAP:
$(APT_GET) $(DEB_feature_PGTAP)
# make redhat
# installs all apt dependencies for a RHEL, Fedora, CentOS system
redhat: rhel_essential rhel_perlmodules
# make redhat_all
# installs all apt dependencies for a RHEL, Fedora, CentOS system Including all features except rhel_feature_PDF_utf8
all_redhat: redhat rhel_feature_PDF rhel_feature_OpenOffice
# make rhel_essential
# installs just the "can't do without these" dependencies
rhel_essential:
$(YUM) $(RHEL_essential)
# make rhel_perlmodules
# installs all known rpm packaged perl modules we depend on
rhel_perlmodules:
$(YUM) $(RHEL_perlmodules)
# make rhel_feature_PDF
# installs rpm packages for generating PDF/Postscript output
rhel_feature_PDF:
$(YUM) $(RHEL_feature_PDF)
# make rhel_feature_PDF_utf8
# Installs texlive-xetex to allow UTF8 ouput in PDF/Postscript output
rhel_feature_PDF_utf8: rhel_feature_PDF
# $(YUM) $(RHEL_feature_PDF_utf8)
# make rhel_feature_XLS
# Installs rpm package for generating XLS output
rhel_feature_XLS:
# $(YUM) $(RHEL_feature_XLS)
# make rhel_feature_OpenOffice
# Installs rpm package for generating OpenOffice output
rhel_feature_OpenOffice:
# $(YUM) $(RHEL_feature_OpenOffice)
# make freebsd
# installs some known dependencies for a FreeBSD system
freebsd:
@echo "We currently don't do anything special on a freebsd system"
# make freebsd_all
# installs some known dependencies for a FreeBSD system
all_freebsd: freebsd
fbsd_feature_PDF:
fbsd_feature_PDF_utf8:
fbsd_feature_OpenOffice:
fbsd_feature_XLS:
# make cpan
# installs any remaining perl dependancies using cpanm
cpan:
ifeq (, $(shell which make))
$(error "No make in $(PATH), please install make")
endif
ifeq (, $(shell which gcc))
$(error "No gcc in $(PATH), please install gcc")
endif
cpanm --quiet --notest --with-feature=starman --installdeps .
# make feature_PDF
# Install system and cpan packages for generating PDF/Postscript output
feature_PDF: $(OS_feature_PDF)
cpanm --quiet --notest --with-feature=latex-pdf-ps --with-feature=latex-pdf-images --installdeps .
# make feature_PDF_utf8
# Install system and cpan packages for UTF8 ouput in PDF/Postscript output
feature_PDF_utf8: $(OS_feature_PDF_utf8) feature_PDF
# make feature_OpenOffice
# Install system and cpan packages for generating OpenOffice output
feature_OpenOffice: $(OS_feature_OpenOffice)
cpanm --quiet --notest --with-feature=openoffice --installdeps .
# make feature_XLS
# Install system and cpan packages for generating XLS output
feature_XLS: $(OS_feature_XLS)
cpanm --quiet --notest --with-feature=XLS --installdeps .
postgres_user:
sudo createuser -S -d -r -l -P lsmb_dbadmin
test:
prove -Ilib t/*.t
devtest:
prove -Ilib t/*.t
prove -Ilib xt/*.t
########
# todo list
########
# The next targets to add are likely
########
# - postgres_user
# - postgres_access
# - postgres_verify
# - postgres (depends on postgres_*)
#
# - starman (adds system user and systemd script)
#
# - letsencrypt
#
# - nginx
#
# - apache
# - httpd (defaults to nginx)
# Oh, and the first to add would be
# - configure (asks a couple of questions and generates ledgersmb.conf)
########
# I think the list of things to test would be something like....
########
# These tests should be run for each distro in a clean VM either on demand or as part of "release testing"
# - run DB tests
# - create an invoice
# - Run a test that verifies Dojo has loaded and is able to modify the DOM
# - generate PDF of invoice
# - generate XLS Doc of invoice
# - generate OpenOffice Doc of invoice
# - Use Mountebank to send an email of the invoice