forked from simonmichael/hledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1563 lines (1273 loc) · 57.9 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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# One of two project scripts files (Makefile, Shake.hs).
# This one is usually the simplest to use.
# It requires GNU Make (https://www.gnu.org/software/make/).
# Also, some rules require:
# - stack (http://haskell-lang.org/get-started, installs libs and runs ghc)
# - shelltestrunner (hackage, runs functional tests)
# - quickbench (hackage/stackage, runs benchmarks)
# - hasktags (hackage, generates tag files for code navigation)
# - profiteur (hackage/stackage, renders profiles as html)
# - hpack (hackage/stackage, generates cabal files from package.yaml files)
# - site/hakyll-std/hakyll-std (generic site-building hakyll script)
# - perl
# This was a reboot of Makefile.old. The old rules were commented out below,
# to be removed or updated over the next while.
#
# Target users: hledger developers, contributors, probably not end-users.
#
# Kinds of hledger builds:
#
# - stack build: built with stack
# (hledger/.stack-work/dist/ARCH/CABAL/build/hledger/hledger,
# .stack-work/install/ARCH/SNAPSHOT/GHC/bin/hledger, installs to ~/.local/bin)
# - cabal build: built with cabal (and maybe a sandbox)
# (hledger/dist/build/hledger/hledger, installs to ~/.cabal/bin)
# - ghc build: built quickly with ghc only, unoptimised, with DEVELOPMENT flag
# (bin/hledgerdev)
#
# This makefile mostly uses stack to get things done (slow but robust).
# Secondarily it uses ghc directly to do some developer tasks (faster).
# # Also if needed it uses cabal directly for a few tasks.
# XXX do we need this ?
#SHELL=/bin/bash
#.SHELLFLAGS="-O extglob -c" # example
# help system
# Every user-relevant rule in this makefile should use def-help to define
# a help string. Use "make help" to see the available rules.
# def-help* functions for documenting make rules. See the file for usage.
-include help-system.mk
$(call def-help-heading,Main make rules in the hledger project.)
$(call def-help-heading,(not always entirely up to date))
$(call def-help-heading,---------------------------------------)
$(call def-help-heading, )
add-to-help-1: $(call def-help,[help], list documented rules in this makefile )
help-%: $(call def-help,help-SECTION, list documented rules in the given section )
make help 2>&1 | sed -n '/$*/,/: $$/p'
%-help: $(call def-help,SECTION-help, same but easier to type (can append "-help" to any "make RULE") )
@make help 2>&1 | sed -n '/$*/,/: $$/p'
add-to-help-2: $(call def-help,RULE -n, show what RULE would do )
###############################################################################
# VARS
# GHC-compiled executables require a locale (and not just C) or they
# will die on encountering non-ascii data. Set LANG to something if not already set.
export LANG?=en_US.UTF-8
# command to run during profiling (time and heap)
PROFCMD=stack exec -- hledgerprof balance -f examples/10000x1000x10.journal >/dev/null
#PROFRTSFLAGS=-p
PROFRTSFLAGS=-P
# # command to run during "make coverage"
# COVCMD=test
# COVCMD=-f test-wf.csv print
# misc. system tools
BROWSE=open
# VIEWHTML=$(BROWSE)
VIEWPS=$(BROWSE)
# VIEWPDF=$(BROWSE)
# PRINT=lpr
GHC=ghc
GHCI=ghci #-package ghc-datasize #-package ghc-heap-view
# GHCPKG=ghc-pkg
# HADDOCK=haddock
# CABAL=cabal
# CABALINSTALL=cabal install -w $(GHC)
STACK=stack
# if using an unreleased stack with a newer hpack than the one mentioned in */*.cabal,
# it will give warnings. To silence these, put the old hpack-X.Y in $PATH and uncomment:
#STACK=stack --with-hpack=hpack-0.20
# -j16 sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" but seems harmless
SHELLTESTOPTS=--execdir -j16 --hide-successes
# make sure shelltest is a released version of shelltestrunner
# run shell tests using the executable specified in tests
# SHELLTEST=COLUMNS=80 PATH=~/.local/bin:/usr/bin:/bin shelltest $(SHELLTESTOPTS)
# run shell tests using the stack build of hledger
#SHELLTESTSTK=shelltest -w `stack exec which hledger` $(SHELLTESTOPTS)
SHELLTESTSTK=COLUMNS=80 $(STACK) exec -- shelltest $(SHELLTESTOPTS)
# # used for make auto, http://joyful.com/repos/searchpath
# SP=sp
PACKAGES=\
hledger-lib \
hledger \
hledger-ui \
hledger-web \
hledger-api \
INCLUDEPATHS=\
-ihledger-lib \
-ihledger-lib/other/ledger-parse \
-ihledger \
-ihledger-ui \
-ihledger-web \
-ihledger-web/app \
-ihledger-api \
MAIN=hledger/app/hledger-cli.hs
# all source files in the project (plus a few strays like Setup.hs & hlint.hs)
SOURCEFILES:= \
dev.hs \
hledger/*hs \
hledger/bench/*hs \
hledger/Hledger/*hs \
hledger/Hledger/*/*hs \
hledger/Hledger/*/*/*hs \
hledger-*/*hs \
hledger-*/Hledger/*hs \
hledger-*/Hledger/*/*hs \
hledger-lib/other/ledger-parse/Ledger/Parser/*hs \
hledger-web/**/*.hs \
HPACKFILES:= \
hledger/*package.yaml \
hledger-*/*package.yaml \
CABALFILES:= \
hledger/hledger.cabal \
hledger-*/*.cabal \
MANUALSOURCEFILES:= \
doc/lib.m4 \
*/*.m4.md \
MANUALGENFILES:= \
hledger*/hledger*.{1,5,info,txt} \
# site/*.md includes website source files and generated web manual files
# WEBDOCFILES:= \
# site/*.md \
WEBCODEFILES:= \
hledger-web/templates/* \
hledger-web/static/*.js \
hledger-web/static/*.css \
DOCSOURCEFILES:= \
README.md \
$(MANUALSOURCEFILES) \
# files which should be updated when the version changes
VERSIONSENSITIVEFILES=\
$(HPACKFILES) \
hledger-api/hledger-api.hs \
doc/lib.m4 \
# # file(s) which require recompilation for a build to have an up-to-date version string
# VERSIONSOURCEFILE=hledger/Hledger/Cli/Version.hs
# master file defining the current release/build version
VERSIONFILE=.version
# two or three-part version string, whatever's in VERSION
VERSION=$(shell cat $(VERSIONFILE))
# the number of commits since the last tag
PATCHLEVEL=$(shell git describe --tags --match 'hledger-[0-9]*' --long | awk -F- '{print $$3}')
#PATCHLEVEL:=$(shell git describe --tags --match 'hledger-web-[0-9]*' --long | awk -F- '{print $$4}')
# the number of commits since the last_release tag
#PATCHLEVEL:=$(shell git rev-list last_release..HEAD | wc -l)
# flags for ghc builds
WARNINGS:=\
-Wall \
-fno-warn-unused-do-bind \
-fno-warn-name-shadowing \
-fno-warn-missing-signatures \
-fno-warn-orphans \
-fno-warn-type-defaults \
# # For ghc-only dev builds of hledger-web: enable the language
# # extensions specified in hledger-web.cabal, except for some which are
# # not compatible with hledger-lib and hledger, or little-used; those
# # are enabled with source file pragmas instead. Note: compilation
# # warnings and errors might differ between ghc-only and cabal builds.
# WEBLANGEXTS:=\
# -XCPP \
# -XMultiParamTypeClasses \
# -XQuasiQuotes \
# -XRecordWildCards \
# -XTemplateHaskell \
# # -XOverloadedStrings \
# # -XNoImplicitPrelude \
# # -XTypeFamilies \
# # -XGADTs \
# # -XGeneralizedNewtypeDeriving \
# # -XFlexibleContexts \
# # -XEmptyDataDecls \
# # -XNoMonomorphismRestriction
# PREFERMACUSRLIBFLAGS=-L/usr/lib
# GHCMEMFLAGS= #+RTS -M200m -RTS
# ghc builds need the macro definitions generated by cabal
# from cabal's dist or dist-sandbox dir, hopefully there's just one
#CABALMACROSFLAGS=-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h
# from stack's dist dir, hopefully there's just one. If not (after cabal upgrade), will get warnings. Maybe obsolete ?
#CABALMACROSFLAGS=-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h
BUILDFLAGS1=-rtsopts $(WARNINGS) $(INCLUDEPATHS) $(PREFERMACUSRLIBFLAGS) $(GHCMEMFLAGS) $(CABALMACROSFLAGS) -DPATCHLEVEL=$(PATCHLEVEL) -DDEVELOPMENT
BUILDFLAGS=$(BUILDFLAGS1) -DVERSION='"$(VERSION)"'
# PROFBUILDFLAGS:=-prof -fprof-auto -osuf hs_p
# # sp needs different quoting:
# AUTOBUILDFLAGS:=$(BUILDFLAGS1) -DVERSION='\"$(VERSION)dev\"' # $(PROFBUILDFLAGS)
# LINUXRELEASEBUILDFLAGS:=-DMAKE $(WARNINGS) $(INCLUDEPATHS) -O2 -static -optl-static -optl-pthread
# MACRELEASEBUILDFLAGS:=-DMAKE $(WARNINGS) $(INCLUDEPATHS) $(PREFERMACUSRLIBFLAGS) -O2 # -optl-L/usr/lib
# #WINDOWSRELEASEBUILDFLAGS:=-DMAKE $(WARNINGS) $(INCLUDEPATHS)
# AUTOBUILD=$(SP) --no-exts --no-default-map $(GHC) -O0 $(GHCMEMFLAGS)
# # get an accurate binary filename for the current source and platform, slow but reliable. Avoid := here.
# BINARYFILENAME=$(shell touch $(VERSIONSOURCEFILE); runhaskell -ihledger -ihledger-lib $(MAIN) --binary-filename)
# # some other thing for linux binary filenames
# RELEASEBINARYSUFFIX=$(shell echo "-$(VERSION)-`uname`-`arch`" | tr '[:upper:]' '[:lower:]')
TIME=$(shell date +"%Y%m%d%H%M")
MONTHYEAR=$(shell date +'%B %Y')
###############################################################################
$(call def-help-subheading,INSTALLING:)
install: \
$(call def-help,install, download dependencies and install hledger executables to ~/.local/bin or equivalent (with stack))
$(STACK) install
# cabal-install: \
# $(call def-help,cabal-install,\
# cabal install the main hledger packages and all their dependencies\
# in the sandbox if any; otherwise in the users package db\
# )
# $(CABALINSTALL) $(patsubst %,./%,$(PACKAGES)) $(EXTRAINSTALLARGS) --enable-tests
# cabal-install-deps: \
# $(call def-help,cabal-install-deps,\
# cabal install the dependencies for the main hledger packages, but not the hledger packages \
# )
# $(CABALINSTALL) $(patsubst %,./%,$(PACKAGES)) $(EXTRAINSTALLARGS) --enable-tests --only-dependencies
# # uninstall: \
# # $(call def-help,uninstall,\
# # unregister all packages, assuming they are defined lowest-dependency first\
# # avoids some reinstall noise when repeatedly doing make install\
# # )
# # -for p in $(call reverse,$(PACKAGES)); do $(GHCPKG) unregister $$p; done
###############################################################################
$(call def-help-subheading,BUILDING:)
# EXTRAINSTALLARGS=
build: \
$(call def-help,build, download dependencies and build hledger executables (with stack))
$(STACK) build
# check-setup: \
# $(call def-help,check-setup,\
# run some tests to validate the development environment\
# )
# @echo sanity-checking developer environment:
# @($(SHELLTEST) checks \
# && echo $@ PASSED) || echo $@ FAILED
# auto: auto---version \
# $(call def-help,auto,\
# auto-recompile and run (something, eg --help or unit tests) whenever a module changes\
# )
# auto-%: sp \
# $(call def-help,auto-%,\
# \
# )
# $(AUTOBUILD) $(MAIN) -o bin/hledgerdev $(AUTOBUILDFLAGS) --run $*
# autoweb: sp link-web-dirs \
# $(call def-help,autoweb,\
# \
# )
# $(AUTOBUILD) hledger-web/app/main.hs -o bin/hledger-webdev $(AUTOBUILDFLAGS) $(WEBLANGEXTS) --run -B --port 5001 --base-url http://localhost:5001 -f webtest.j
link-web-dirs: config messages static templates \
$(call def-help,link-web-dirs,\
\
)
config: \
$(call def-help,config,\
\
)
ln -sf hledger-web/$@
messages: \
$(call def-help,messages,\
\
)
ln -sf hledger-web/$@
static: \
$(call def-help,static,\
\
)
ln -sf hledger-web/$@
templates: \
$(call def-help,templates,\
\
)
ln -sf hledger-web/$@
# sp: \
# $(call def-help,sp,\
# check for sp and explain how to get it if not found.\
# )
# @/usr/bin/env which sp >/dev/null || \
# (echo '"sp" is required for auto-compilation. darcs get http://joyful.com/darcsden/simon/searchpath, make it (cabal install-ing any needed packages) and add it to your PATH'; exit 1)
# force a compile even if binary exists, since we don't specify dependencies for these
.PHONY: bin/hledgerdev bin/hledgerprof # bin/hledger-webdev
# NB requires cabal macros generated by cabal build in hledger/
bin/hledgerdev hledgerdev: \
$(call def-help,hledgerdev, build an unoptimised "bin/hledgerdev" executable quickly (with ghc) )
$(GHC) $(MAIN) -o bin/hledgerdev $(BUILDFLAGS)
# bin/hledgerdev.ghc-%: $(SOURCEFILES) \
# $(call def-help,bin/hledgerdev.ghc-%,\
# build a GHC-version-specific hledger binary without disturbing with other GHC version builds\
# )
# ghc-$* $(MAIN) -o $@ $(BUILDFLAGS) -outputdir .ghc-$*
# bin/hledgerdev.ghcall: \
# bin/hledgerdev.ghc-7.6.1 \
# bin/hledgerdev.ghc-7.4.1 \
# bin/hledgerdev.ghc-7.2.2 \
# bin/hledgerdev.ghc-7.0.4 \
# $(call def-help,bin/hledgerdev.ghcall,\
# build hledger with the main supported GHC versions\
# )
hledgerprof: \
$(call def-help,hledgerprof, build "hledgerprof" for profiling (with stack) )
$(STACK) build hledger-lib hledger --library-profiling --executable-profiling --ghc-options=-fprof-auto
cp `$(STACK) exec which hledger`{,prof}
@echo to profile, use $(STACK) exec -- hledgerprof ...
# bin/hledgerprof: \
# $(call def-help,bin/hledgerprof,\
# build the "production" cabal build with profiling enabled.\
# )
# rm -f bin/hledgerprof
# cabal install --enable-profiling --ghc-options=-fprof-auto ./hledger-lib ./hledger \
# && mv $(CABALINSTALLDIR)/bin/hledger bin/hledgerprof
# # build the dev build with profiling enabled.
# # not working with cabal sandbox
# # bin/hledgerdev-prof:
# # $(GHC) $(BUILDFLAGS) $(PROFBUILDFLAGS) $(MAIN) -o $@
hledgercov: \
$(call def-help,hledgercov, build "bin/hledgercov" for coverage reports (with ghc) )
$(GHC) $(MAIN) -fhpc -o bin/hledgercov -outputdir .hledgercovobjs $(BUILDFLAGS)
# hledger-lib/Hledger/Read/TimeclockReaderPP.hs
dev: dev.hs $(SOURCEFILES) \
$(call def-help,dev, build the dev.hs script for quick experiments (with ghc) )
$(STACK) ghc -- $(CABALMACROSFLAGS) -ihledger-lib dev.hs \
# dev0: dev.hs $(SOURCEFILES) \
# $(call def-help,dev, build the dev.hs script for quick experiments (with ghc -O0) )
# $(STACK) ghc -- -O0 $(CABALMACROSFLAGS) -ihledger-lib dev.hs -o dev0 \
# dev2: dev.hs $(SOURCEFILES) \
# $(call def-help,dev, build the dev.hs script for quick experiments (with ghc -O2) )
# $(STACK) ghc -- -O2 $(CABALMACROSFLAGS) -ihledger-lib dev.hs -o dev2 \
# to get profiling deps installed, first do something like:
# stack build --library-profiling hledger-lib timeit criterion
devprof: dev.hs $(SOURCEFILES) \
$(call def-help,devprof, build the dev.hs script with profiling support )
$(STACK) ghc -- $(CABALMACROSFLAGS) -ihledger-lib dev.hs -rtsopts -prof -fprof-auto -osuf p_o -o devprof
dev-profile: devprof \
$(call def-help,dev-profile, get a time & space profile of the dev.hs script )
time ./devprof +RTS -P \
&& cp devprof.prof devprof.prof.$(TIME) \
&& profiteur devprof.prof
dev-heap: devprof \
$(call def-help,dev-heap, get heap profiles of the dev.hs script )
time ./devprof +RTS -hc -L1000 && cp devprof.hp devprof-hc.hp && hp2ps devprof-hc.hp
time ./devprof +RTS -hr -L1000 && cp devprof.hp devprof-hr.hp && hp2ps devprof-hr.hp
dev-heap-upload:
curl -F "file=@devprof-hc.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload
curl -F "file=@devprof-hr.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload
# # build other executables quickly
# bin/hledger-webdev: link-web-dirs \
# $(call def-help,bin/hledger-webdev,\
# \
# )
# $(GHC) -o $@ $(BUILDFLAGS) $(WEBLANGEXTS) hledger-web/app/main.hs
# bin/hledger-web-production: \
# $(call def-help,bin/hledger-web-production,\
# \
# )
# $(GHC) -o $@ $(BUILDFLAGS) $(WEBLANGEXTS) hledger-web/app/main.hs
# linuxbinaries: linuxbinary-hledger \
# linuxbinary-hledger-web \
# $(call def-help,linuxbinaries,\
# build portable releaseable binaries for gnu/linux\
# )
# @echo 'Please check the binaries look portable, then make compressbinaries:'
# -file bin/*`arch`
# linuxbinary-hledger: \
# $(call def-help,linuxbinary-hledger,\
# work around for inconsistently-named (why ?) hledger/app/hledger-cli.hs\
# )
# $(GHC) hledger/app/hledger-cli.hs -o bin/$*$(RELEASEBINARYSUFFIX) $(LINUXRELEASEBUILDFLAGS)
# linuxbinary-%: \
# $(call def-help,linuxbinary-%,\
# \
# )
# $(GHC) $*/$*.hs -o bin/$*$(RELEASEBINARYSUFFIX) $(LINUXRELEASEBUILDFLAGS)
# macbinaries: macbinary-hledger \
# macbinary-hledger-web \
# $(call def-help,macbinaries,\
# \
# )
# @echo 'Please check the binaries are portable, then make compressbinaries'
# otool -L bin/*`arch`
# macbinary-%: \
# $(call def-help,macbinary-%,\
# build a deployable mac binary for the specified hledger package, munging\
# the link command to use only standard osx libs. Specifically we link\
# without the non-standard GMP framework, which causes no apparent harm.\
# Clunky, does the link twice.\
# )
# BINARY=`echo $(BINARYFILENAME) | sed -e 's/hledger/$*/'` ; \
# LINKCMD=`$(GHC) -v $*/$*.hs $(MACRELEASEBUILDFLAGS) -o bin/$$BINARY 2>&1 | egrep "bin/gcc.*bin/$$BINARY"` ; \
# PORTABLELINKCMD=`echo $$LINKCMD | sed -e 's/ -framework GMP//'` ; \
# echo $$PORTABLELINKCMD; $$PORTABLELINKCMD
# windowsbinaries: install \
# $(call def-help,windowsbinaries,\
# Run this on a windows machine or in a wine session, and probably in a\
# separate copy of the repo (hledger-win).\
# Builds and gather deployable binaries for windows, if cygwin tools are\
# present and all packages are buildable. Otherwise, cabal install each\
# package and gather the binaries by hand.\
# )
# cp ~/.cabal/bin/hledger.exe bin/`echo $(BINARYFILENAME) | dos2unix`
# -cp ~/.cabal/bin/hledger-web.exe bin/`echo $(BINARYFILENAME) | sed -e 's/hledger/hledger-web/' | dos2unix`
# @echo 'Please check the binaries are portable, then make compressbinaries'
# ls -l bin/*`arch`
# wine-cmd: \
# $(call def-help,wine-cmd,\
# various ways of getting a wine shell\
# command-line windows command prompt. Works eg in an emacs shell buffer.\
# )
# wine cmd
# wine-cmd2: \
# $(call def-help,wine-cmd2,\
# as above but try to cd somewhere useful (doesnt work), also ctrl-d exits quickly\
# )
# (echo c:; echo cd \\mingw\\msys\\1.0; cat) | wine cmd
# wine-cmd-window: \
# $(call def-help,wine-cmd-window,\
# windows command prompt in a new window\
# )
# wineconsole cmd &
# wine-mintty: \
# $(call def-help,wine-mintty,\
# msys bash shell in a mintty window\
# )
# wine c:/mingw/msys/1.0/bin/mintty - &
# compressbinaries: \
# $(call def-help,compressbinaries,\
# \
# )
# cd bin; for f in *-windows-*.exe ; do echo zipping $$f; rm -f $$f.zip; zip $$f.zip $$f; done
# # for f in bin/*-{linux,mac-}* ; do echo gzipping $$f; gzip -q $$f >$$f.gz; done
# # gzip bin/*`arch`
# tools/unittest: tools/unittest.hs \
# $(call def-help,tools/unittest,\
# build the standalone unit test runner. Requires test-framework, which\
# may not work on windows.\
# )
# $(GHC) -threaded -O2 tools/unittest.hs
# tools/doctest: tools/doctest.hs \
# $(call def-help,tools/doctest,\
# build the doctest runner\
# )
# $(GHC) tools/doctest.hs
# tools/criterionbench: tools/criterionbench.hs \
# $(call def-help,tools/criterionbench,\
# build the criterion-based benchmark runner. Requires criterion.\
# )
# $(GHC) tools/criterionbench.hs
# tools/progressionbench: tools/progressionbench.hs \
# $(call def-help,tools/progressionbench,\
# build the progression-based benchmark runner. Requires progression.\
# )
# $(GHC) tools/progressionbench.hs
tools/generatejournal: tools/generatejournal.hs \
$(call def-help,tools/generatejournal, build the generatejournal tool )
$(GHC) tools/generatejournal.hs
ghcid: $(call def-help,ghcid, start ghcid autobuilder on hledger-lib + hledger)
ghcid -c 'make ghci'
ghcid-ui: $(call def-help,ghcid-ui, start ghcid autobuilder on hledger-lib + hledger + hledger-ui)
ghcid -c 'make ghci-ui'
ghcid-web: $(call def-help,ghcid-web, start ghcid autobuilder on hledger-lib + hledger + hledger-web)
ghcid -c 'make ghci-web'
ghcid-api: $(call def-help,ghcid-api, start ghcid autobuilder on hledger-lib + hledger + hledger-api)
ghcid -c 'make ghci-api'
ghcid-test: $(call def-help,ghcid-test, start ghcid autobuilding and running the test command)
ghcid -c 'make ghci' --test ':main test'
ghcid-doctest: $(call def-help,ghcid-doctest, start ghcid autobuilding and running hledger-lib doctests)
ghcid -c 'cd hledger-lib; $(STACK) ghci hledger-lib:test:doctests' --test ':main' --reload hledger-lib
ghcid-shake: $(call def-help,ghcid-shake, start ghcid autobuilder on Shake.hs)
stack exec \
--package base-prelude \
--package directory \
--package extra \
--package safe \
--package shake \
--package time \
-- ghcid Shake.hs
# same packages as in Shake.hs
# multi-package GHCI prompts
ghci: $(call def-help,ghci, start ghci REPL on hledger-lib + hledger)
$(STACK) exec -- $(GHCI) $(BUILDFLAGS) hledger/Hledger/Cli/Main.hs
ghci-prof: $(call def-help,ghci-prof, start ghci REPL on hledger-lib + hledger with profiling information)
stack build --profile hledger --only-dependencies
$(STACK) exec -- $(GHCI) $(BUILDFLAGS) -fexternal-interpreter -prof -fprof-auto hledger/Hledger/Cli/Main.hs
ghci-dev: $(call def-help,ghci-dev, start ghci REPL on hledger-lib + hledger + dev.hs script)
$(STACK) exec -- $(GHCI) $(BUILDFLAGS) -fno-warn-unused-imports -fno-warn-unused-binds dev.hs
ghci-ui: $(call def-help,ghci-ui, start ghci REPL on hledger-lib + hledger + hledger-ui)
$(STACK) exec -- $(GHCI) $(BUILDFLAGS) hledger-ui/Hledger/UI/Main.hs
ghci-web: link-web-dirs $(call def-help,ghci-web, start ghci REPL on hledger-lib + hledger + hledger-web)
$(STACK) exec -- $(GHCI) $(BUILDFLAGS) hledger-web/app/main.hs
ghci-api: (call def-help,ghci-api, start ghci REPL on hledger-lib + hledger + hledger-api)
$(STACK) exec -- $(GHCI) $(BUILDFLAGS) hledger-api/hledger-api.hs
# ghci-all: $(call def-help,ghci-all, start ghci REPL on all the hledger)
# $(STACK) exec -- $(GHCI) $(BUILDFLAGS) \
# hledger-ui/Hledger/UI/Main.hs \
# hledger-web/app/main.hs \
# hledger-api/hledger-api.hs \
ghci-doctest: $(call def-help,ghci-lib-doctest, start ghci REPL on hledger-lib doctests)
cd hledger-lib; $(STACK) ghci hledger-lib:test:doctests
###############################################################################
$(call def-help-subheading,TESTING:)
test: pkgtest functest \
$(call def-help,test, run default tests: package tests plus functional tests)
# For quieter tests add --silent. It may hide troubleshooting info.
# For very verbose tests add --verbosity=debug. It seems hard to get something in between.
STACKTEST=$(STACK) test
buildtest: $(call def-help,buildtest, force-rebuild all hledger packages/modules quickly ensuring no warnings with default snapshot) \
buildtest-stack.yaml
buildtest-all: $(call def-help,buildtest-all, force-rebuild all hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot )
for F in stack-*.yaml stack.yaml; do make --no-print-directory buildtest-$$F; done
buildtest-%: $(call def-help,buildtest-STACKFILE, force-rebuild all hledger packages/modules quickly ensuring no warnings with the given stack yaml file; eg make buildtest-stack-ghc8.2.yaml )
$(STACK) build --test --bench --fast --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --stack-yaml=$*
incr-buildtest: $(call def-help,incr-buildtest, build any outdated hledger packages/modules quickly ensuring no warnings with default snapshot. Wont detect warnings in up-to-date modules.) \
incr-buildtest-stack.yaml
incr-buildtest-all: $(call def-help,incr-buildtest-all, build any outdated hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot. Wont detect warnings in up-to-date modules. )
for F in stack-*.yaml stack.yaml; do make --no-print-directory incr-buildtest-$$F; done
incr-buildtest-%: $(call def-help,incr-buildtest-STACKFILE, build any outdated hledger packages/modules quickly ensuring no warnings with the stack yaml file; eg make buildtest-stack-ghc8.2.yaml. Wont detect warnings in up-to-date modules. )
$(STACK) build --test --bench --fast --ghc-options=-Werror --stack-yaml=$*
buildplantest: $(call def-help,buildplantest, stack build --dry-run all hledger packages ensuring an install plan with default snapshot) \
buildplantest-stack.yaml
buildplantest-all: $(call def-help,buildplantest-all, stack build --dry-run all hledger packages ensuring an install plan with each ghc version/stackage snapshot )
for F in stack-*.yaml stack.yaml; do make --no-print-directory buildplantest-$$F; done
buildplantest-%: $(call def-help,buildplantest-STACKFILE, stack build --dry-run all hledger packages ensuring an install plan with the given stack yaml file; eg make buildplantest-stack-ghc8.2.yaml )
$(STACK) build --dry-run --test --bench --stack-yaml=$*
pkgtest: $(call def-help,pkgtest, run the test suites in each package )
@($(STACKTEST) && echo $@ PASSED) || (echo $@ FAILED; false)
hunittest: $(call def-help,hunittest, run just the hunit tests in hledger-lib )
@($(STACKTEST) hledger-lib:test:hunittests && echo $@ PASSED) || (echo $@ FAILED; false)
# doctests don't run with ghc 8.4 on mac, see package.yaml
doctest: $(call def-help,doctest, run just the doctest tests in hledger-lib )
@($(STACKTEST) --stack-yaml stack-ghc8.2.yaml hledger-lib:test:doctests && echo $@ PASSED) || (echo $@ FAILED; false)
easytest: $(call def-help,easytest, run just the easytest tests in hledger-lib )
@($(STACKTEST) hledger-lib:test:easytests && echo $@ PASSED) || (echo $@ FAILED; false)
# NB ensure an up to date hledger executable is built (eg make hunittest).
# I think we don't do it automatically to minimise unnecessary rebuilding.
builtintest: $(call def-help,builtintest, run hledgers built in test command)
@($(STACK) exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false)
# assumes hledger is built and uses whatever build is there, avoiding excessive rebuilding
#functest: addons tests/addons/hledger-addon
functest: tests/addons/hledger-addon \
$(call def-help,functest, run the functional tests for hledger )
@($(SHELLTESTSTK) tests \
&& echo $@ PASSED) || (echo $@ FAILED; false)
ADDONEXTS=pl py rb sh hs lhs rkt exe com bat
tests/addons/hledger-addon: \
$(call def-help,tests/addons/hledger-addon,\
generate dummy add-ons for testing (hledger-addon the rest)\
)
rm -rf tests/addons/hledger-*
printf '#!/bin/sh\necho add-on: $$0\necho args: $$*\n' >tests/addons/hledger-addon
for E in '' $(ADDONEXTS); do \
cp tests/addons/hledger-addon tests/addons/hledger-addon.$$E; done
for F in addon. addon2 addon2.hs addon3.exe addon3.lhs addon4.exe add reg; do \
cp tests/addons/hledger-addon tests/addons/hledger-$$F; done
mkdir tests/addons/hledger-addondir
chmod +x tests/addons/hledger-*
# hlinttest hlint: $(call def-help,hlinttest (or hlint),generate a hlint report)
# hlint --hint=hlint --report=hlint.html $(SOURCEFILES)
haddocktest: $(call def-help,haddocktest, run haddock and make sure it succeeds )
@(make --quiet haddock && echo $@ PASSED) || (echo $@ FAILED; false)
cabalfiletest: $(call def-help,cabalfiletest, run cabal check to test cabal file syntax )
@(make --no-print-directory cabalcheck && echo $@ PASSED) || (echo $@ FAILED; false)
allghcstest: $(call def-help,allghcstest, build/test/benchmark with all supported GHC versions/stackage snapshots and warning-free) \
test-stack-ghc7.10.yaml \
test-stack-ghc8.0.yaml \
test-stack-ghc8.2.yaml \
test-stack.yaml \
test-stack%yaml:
$(STACK) --stack-yaml stack$*yaml clean
$(STACK) --stack-yaml stack$*yaml build --ghc-options="$(WARNINGS) -Werror" --test --bench --haddock --no-haddock-deps
travistest: $(call def-help,travistest, run tests similar to our travis CI tests)
$(STACK) clean
$(STACK) build --ghc-options=-Werror --test --haddock --no-haddock-deps hledger-lib
$(STACK) build --ghc-options=-Werror --test --haddock --no-haddock-deps hledger
$(STACK) build --ghc-options=-Werror --test --haddock --no-haddock-deps hledger-ui
$(STACK) build --ghc-options=-Werror --test --haddock --no-haddock-deps hledger-web
$(STACK) build --ghc-options=-Werror --test --haddock --no-haddock-deps hledger-api
make functest
# committest: hlinttest unittest doctest functest haddocktest buildtest quickcabaltest \
# $(call def-help,committest,more thorough pre-commit/pre-push tests)
# releasetest: Clean unittest functest fullcabaltest haddocktest #buildtest doctest \
# $(call def-help,releasetest,pre-release tests)
HLEDGERINSTALLSH=$(PWD)/hledger-install/hledger-install.sh
installtest: $(call def-help,installtest, run hledger-install.sh from another directory)
(cd; $(HLEDGERINSTALLSH))
###############################################################################
$(call def-help-subheading,BENCHMARKING:)
samplejournals: $(call def-help,samplejournals, regenerate standard sample journals in examples/) \
examples/sample.journal \
examples/100x100x10.journal \
examples/1000x1000x10.journal \
examples/1000x10000x10.journal \
examples/10000x1000x10.journal \
examples/10000x10000x10.journal \
examples/100000x1000x10.journal \
examples/1000000x1000x10.journal \
examples/ascii.journal \
examples/chinese.journal \
examples/mixed.journal \
examples/sample.journal:
true # XXX should probably regenerate this
examples/100x100x10.journal: tools/generatejournal
tools/generatejournal 100 100 10 >$@
examples/1000x1000x10.journal: tools/generatejournal
tools/generatejournal 1000 1000 10 >$@
examples/1000x10000x10.journal: tools/generatejournal
tools/generatejournal 1000 10000 10 >$@
examples/10000x1000x10.journal: tools/generatejournal
tools/generatejournal 10000 1000 10 >$@
examples/10000x10000x10.journal: tools/generatejournal
tools/generatejournal 10000 10000 10 >$@
examples/100000x1000x10.journal: tools/generatejournal
tools/generatejournal 100000 1000 10 >$@
examples/1000000x1000x10.journal: tools/generatejournal
tools/generatejournal 1000000 1000 10 >$@
examples/ascii.journal: tools/generatejournal
tools/generatejournal 3 5 5 >$@
examples/chinese.journal: tools/generatejournal
tools/generatejournal 3 5 5 --chinese >$@
examples/mixed.journal: tools/generatejournal
tools/generatejournal 3 5 5 --mixed >$@
BENCHEXES=hledger
# or, eg: BENCHEXES=ledger,hledger-1.4,hledger
bench: samplejournals bench.sh $(call def-help,bench, benchmark commands in bench.sh with quickbench and $(BENCHEXES))
quickbench -v -w $(BENCHEXES)
# bench: samplejournals tests/bench.tests tools/simplebench \
# $(call def-help,bench,\
# run simple performance benchmarks and archive results\
# Requires some commands defined in tests/bench.tests and some BENCHEXES defined above.\
# )
# tools/simplebench -v -ftests/bench.tests $(BENCHEXES) | tee doc/profs/$(TIME).bench
# @rm -f benchresults.*
# @(cd doc/profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench)
# criterionbench: samplejournals tools/criterionbench \
# $(call def-help,criterionbench,\
# run criterion benchmark tests and save graphical results\
# )
# tools/criterionbench -t png -k png
# progressionbench: samplejournals tools/progressionbench \
# $(call def-help,progressionbench,\
# run progression benchmark tests and save graphical results\
# )
# tools/progressionbench -- -t png -k png
# prof: samplejournals \
# $(call def-help,prof,\
# generate and archive an execution profile\
# ) #bin/hledgerprof
# @echo "Profiling: $(PROFCMD)"
# -$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS
# mv hledgerprof.prof doc/profs/$(TIME).prof
# (cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof)
# viewprof: prof \
# $(call def-help,viewprof,\
# generate, archive, simplify and display an execution profile\
# )
# tools/simplifyprof.hs doc/profs/latest.prof
quickprof-%: hledgerprof samplejournals \
$(call def-help,quickprof-"CMD", run some command against a sample journal and display the execution profile )
$(STACK) exec -- hledgerprof +RTS $(PROFRTSFLAGS) -RTS $* -f examples/10000x1000x10.journal >/dev/null
profiteur hledgerprof.prof
@echo
@head -20 hledgerprof.prof
@echo ...
@echo
@echo see hledgerprof.prof or hledgerprof.prof.html for the full report
# heap: samplejournals \
# $(call def-help,heap,\
# generate and archive a graphical heap profile\
# ) #bin/hledgerprof
# @echo "Profiling heap with: $(PROFCMD)"
# $(PROFCMD) +RTS -hc -RTS
# mv hledgerprof.hp doc/profs/$(TIME).hp
# (cd doc/profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \
# hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps; rm -f *.aux)
# viewheap: heap \
# $(call def-help,viewheap,\
# \
# )
# $(VIEWPS) doc/profs/latest.ps
quickheap-%: hledgerprof samplejournals \
$(call def-help,quickheap-"CMD", run some command against a sample journal and display the heap profile )
$(STACK) exec -- hledgerprof +RTS -hc -RTS $* -f examples/10000x1000x10.journal >/dev/null
hp2ps hledgerprof.hp
@echo generated hledgerprof.ps
$(VIEWPS) hledgerprof.ps
# quickcoverage: hledgercov \
# $(call def-help,quickcoverage,\
# display a code coverage text report from running hledger COVCMD\
# )
# @echo "Generating code coverage text report for hledger command: $(COVCMD)"
# tools/runhledgercov "report" $(COVCMD)
# coverage: samplejournals hledgercov \
# $(call def-help,coverage,\
# generate a code coverage html report from running hledger COVCMD\
# )
# @echo "Generating code coverage html report for hledger command: $(COVCMD)"
# tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD)
# cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html
# viewcoverage: \
# $(call def-help,viewcoverage,\
# view the last html code coverage report\
# )
# $(VIEWHTML) doc/profs/coverage/index.html
# # XXX with a sandbox, use sandbox-repl-* instead
# repl-lib:\
# $(call def-help,repl-lib, start a cabal REPL and load the hledger-lib package)
# (cd hledger-lib; cabal repl)
# repl-cli:\
# $(call def-help,repl-cli, start a cabal REPL and load the hledger package)
# (cd hledger; cabal repl exe:hledger)
# repl-web:\
# $(call def-help,repl-web, start a cabal REPL and load the hledger-web package)
# (cd hledger-web; cabal repl exe:hledger-web)
###############################################################################
$(call def-help-subheading,DOCUMENTATION:)
# docs: site codedocs \
# $(call def-help,docs,\
# rebuild all docs\
# )
# cleandocs: site-clean \
# $(call def-help,cleandocs,\
# \
# )
hakyll-std site/hakyll-std/hakyll-std: \
site/hakyll-std/hakyll-std.hs \
site/hakyll-std/TableOfContents.hs \
$(call def-help,hakyll-std, build a generic hakyll site builder script )
cd site/hakyll-std; ./hakyll-std.hs
site-build: site/hakyll-std/hakyll-std site/manual.md \
$(call def-help,site-build, generate the hledger.org website with hakyll-std )
-cd site; hakyll-std/hakyll-std build
site/index.md: wiki/_Sidebar.md \
$(call def-help,site/index.md, update home page with ./wiki/_Sidebar content )
(sed -ne '1,/<!-- WIKICONTENT -->/ p' site/index.md ; \
sed -ne '/^#.*User/,$$ p' wiki/_Sidebar.md \
| perl -p \
-e 's/\[\[([^\|]*)\|([^\]]*)\]\]/[\1](https:\/\/github.com\/simonmichael\/hledger\/wiki\/\2)/g;' \
-e 's/\[\[([^\]]*)\]\]/[\1](https:\/\/github.com\/simonmichael\/hledger\/wiki\/\1)/g;' \
-e 's/^# >/##/;' \
; \
sed -ne '/<!-- ENDWIKICONTENT -->/,$$ p' site/index.md ) \
> site/_index.md.$$$$ && \
mv site/_index.md.$$$$ site/index.md
site/index.md-push: \
$(call def-help,site/index.md-push, update home page with ./wiki/_Sidebar content and commit and do a git push if changed )
git diff --quiet site/index.md && \
make -s site/index.md && \
( git diff --quiet site/index.md || (git commit -q -m 'site: home: update from wiki' -m '[ci skip]' site/index.md && git push) )
site-clean: site/hakyll-std/hakyll-std \
$(call def-help,site-clean, remove hakyll-generated files (& take down the website) ) #cleanolddocs
-cd site; hakyll-std/hakyll-std clean
# rm -rf site/_site/*
# regenerate html whenever markdown files change (and serve it on port 8000)
# XXX hakyll preview/watch often fail to notice changes in large files
# XXX can get confused when docs are generated concurrently by a Shake command
# XXX individual file updates loses the stylesheets for some reason
# more robust: "ls site/*.md | entr ./Shake website" and reload file:///Users/simon/src/hledger/site/_site/docs.html
site-preview: site/hakyll-std/hakyll-std \
$(call def-help,site-preview, run a hakyll server to preview the website ) #site/site
-cd site; hakyll-std/hakyll-std watch # -h hledger.org
# open a browser on the latest site html and reload the page whenever it changes
site-reload:
(sleep 1; open http://localhost:8001) &
livereloadx -p 8001 --static site/_site
# site-view: site \
# $(call def-help,site-view,\
# \
# )
# $(VIEWHTML) site/_site/index.html
# # site-auto:
# # cd site; $(AUTOBUILD) site.hs -o site $(PREFERMACUSRLIBFLAGS) --run preview
# # ensure some old doc versions are in place:
# #olddocs: doc/0.22 doc/0.21
# #doc/0.23:
# # (cd doc; git archive --prefix doc/0.23/ tags/0.23 'doc/MANUAL.md') | tar xf -
# # doc/0.22:
# # git archive --prefix doc/0.22/ tags/0.22 'MANUAL.md' | tar xf -
# # doc/0.21:
# # git archive --prefix doc/0.21/ tags/0.21.3 'MANUAL.md' | tar xf -
# # cleanolddocs:
# # cd doc; rm -rf 0.22 0.21
# pdf: codepdf \
# $(call def-help,pdf,\
# \
# ) #docspdf
# # generate pdf versions of main docs
# # docspdf:
# # -for d in $(DOCFILES); do (cd site && ln -sf ../$$d && pandoc $$d -w pdf && rm -f $$d); done
# # # format all code as a pdf for offline reading
# # ENSCRIPT=enscript -q --header='$$n|$$D{%+}|Page $$% of $$=' --highlight=haskell --line-numbers --font=Courier6 --color -o-
# # codepdf:
# # $(ENSCRIPT) --pretty-print=makefile hledger.cabal >cabal.ps
# # $(ENSCRIPT) --pretty-print=makefile Makefile >make.ps
# # $(ENSCRIPT) --pretty-print=haskell $(SOURCEFILES) >haskell.ps
# # cat cabal.ps make.ps haskell.ps | ps2pdf - >code.pdf
# # # view all docs and code as pdf
# # PDFS=site/{README,README2,MANUAL,CHANGES,CONTRIBUTORS}.pdf code.pdf
# # viewall: pdf
# # $(VIEWPDF) $(PDFS)
# # # print all docs and code for offline reading
# # printall: pdf
# # $(PRINT) $(PDFS)
# pushdocs: push \
# $(call def-help,pushdocs,\
# push latest docs etc. and update the hledger.org site\