forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
915 lines (804 loc) · 35.6 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
#
# Makefile for the Duktape development repo
#
# This Makefile is intended for ONLY internal Duktape development
# on Linux (or other UNIX-like operating systems), and covers:
#
# - building the Duktape source distributable
# - running test cases
# - building the duktape.org website
#
# The Makefile now also works in a very limited fashion with Cygwin,
# you can 'make dist' as long as you have enough software installed.
# The closure compiler requires a working JDK installation (JRE is
# not enough, JAVA_HOME must point to the JDK), and a working Apache
# 'ant' command.
#
# The source distributable has more platform neutral example Makefiles
# for end user projects (though an end user should really just use their
# own Makefile).
#
# YOU SHOULD NOT COMPILE DUKTAPE WITH THIS MAKEFILE IN YOUR PROJECT!
#
# Duktape command line tools are built by first creating a source dist
# directory, and then using the sources from the dist directory for
# compilation. This is as close as possible to the sources used by an
# end user, at the risk of accidentally polluting the dist directory.
#
# When creating actual distributables, always clean first.
#
# External projects are downloaded on-the-fly. Clone git repos shallowly
# (--depth 1) whenever possible. With build-critical resources, use a
# specific version instead of "trunk".
#
# The makefile should work with -jN except for the 'clean' target, use:
#
# $ make clean; make -j4
#
# A few commands which may need to be edited. NodeJS is sometimes found
# as 'nodejs', sometimes as 'node'; sometimes 'node' is unrelated to NodeJS
# so check 'nodejs' first.
GIT:=$(shell which git)
NODE:=$(shell which nodejs node | head -1)
WGET:=$(shell which wget)
JAVA:=$(shell which java)
VALGRIND:=$(shell which valgrind)
PYTHON:=$(shell which python)
# Scrape version from the public header; convert from e.g. 10203 -> '1.2.3'
DUK_VERSION:=$(shell cat src/duk_api_public.h.in | grep define | grep DUK_VERSION | tr -s ' ' ' ' | cut -d ' ' -f 3 | tr -d 'L')
DUK_MAJOR:=$(shell echo "$(DUK_VERSION) / 10000" | bc)
DUK_MINOR:=$(shell echo "$(DUK_VERSION) % 10000 / 100" | bc)
DUK_PATCH:=$(shell echo "$(DUK_VERSION) % 100" | bc)
DUK_VERSION_FORMATTED:=$(DUK_MAJOR).$(DUK_MINOR).$(DUK_PATCH)
GIT_DESCRIBE:=$(shell git describe --always --dirty)
BUILD_DATETIME:=$(shell date +%Y%m%d%H%M%S)
# Ditz release (next release name)
DITZ_RELEASE=v1.1
DISTSRCSEP = dist/src-separate
DISTSRCCOM = dist/src
DISTCMD = dist/examples/cmdline
DUKTAPE_SOURCES_COMBINED = \
$(DISTSRCCOM)/duktape.c
DUKTAPE_SOURCES_SEPARATE = \
$(DISTSRCSEP)/duk_util_hashbytes.c \
$(DISTSRCSEP)/duk_util_hashprime.c \
$(DISTSRCSEP)/duk_util_bitdecoder.c \
$(DISTSRCSEP)/duk_util_bitencoder.c \
$(DISTSRCSEP)/duk_util_tinyrandom.c \
$(DISTSRCSEP)/duk_util_misc.c \
$(DISTSRCSEP)/duk_alloc_default.c \
$(DISTSRCSEP)/duk_debug_macros.c \
$(DISTSRCSEP)/duk_debug_vsnprintf.c \
$(DISTSRCSEP)/duk_debug_heap.c \
$(DISTSRCSEP)/duk_debug_hobject.c \
$(DISTSRCSEP)/duk_debug_fixedbuffer.c \
$(DISTSRCSEP)/duk_error_macros.c \
$(DISTSRCSEP)/duk_error_longjmp.c \
$(DISTSRCSEP)/duk_error_throw.c \
$(DISTSRCSEP)/duk_error_augment.c \
$(DISTSRCSEP)/duk_error_misc.c \
$(DISTSRCSEP)/duk_heap_misc.c \
$(DISTSRCSEP)/duk_heap_memory.c \
$(DISTSRCSEP)/duk_heap_alloc.c \
$(DISTSRCSEP)/duk_heap_refcount.c \
$(DISTSRCSEP)/duk_heap_markandsweep.c \
$(DISTSRCSEP)/duk_heap_hashstring.c \
$(DISTSRCSEP)/duk_heap_stringtable.c \
$(DISTSRCSEP)/duk_heap_stringcache.c \
$(DISTSRCSEP)/duk_hstring_misc.c \
$(DISTSRCSEP)/duk_hthread_misc.c \
$(DISTSRCSEP)/duk_hthread_alloc.c \
$(DISTSRCSEP)/duk_hthread_builtins.c \
$(DISTSRCSEP)/duk_hthread_stacks.c \
$(DISTSRCSEP)/duk_hobject_alloc.c \
$(DISTSRCSEP)/duk_hobject_class.c \
$(DISTSRCSEP)/duk_hobject_enum.c \
$(DISTSRCSEP)/duk_hobject_props.c \
$(DISTSRCSEP)/duk_hobject_finalizer.c \
$(DISTSRCSEP)/duk_hobject_pc2line.c \
$(DISTSRCSEP)/duk_hobject_misc.c \
$(DISTSRCSEP)/duk_hbuffer_alloc.c \
$(DISTSRCSEP)/duk_hbuffer_ops.c \
$(DISTSRCSEP)/duk_unicode_tables.c \
$(DISTSRCSEP)/duk_unicode_support.c \
$(DISTSRCSEP)/duk_builtins.c \
$(DISTSRCSEP)/duk_js_ops.c \
$(DISTSRCSEP)/duk_js_var.c \
$(DISTSRCSEP)/duk_numconv.c \
$(DISTSRCSEP)/duk_api_stack.c \
$(DISTSRCSEP)/duk_api_heap.c \
$(DISTSRCSEP)/duk_api_call.c \
$(DISTSRCSEP)/duk_api_compile.c \
$(DISTSRCSEP)/duk_api_codec.c \
$(DISTSRCSEP)/duk_api_memory.c \
$(DISTSRCSEP)/duk_api_string.c \
$(DISTSRCSEP)/duk_api_object.c \
$(DISTSRCSEP)/duk_api_buffer.c \
$(DISTSRCSEP)/duk_api_var.c \
$(DISTSRCSEP)/duk_api_logging.c \
$(DISTSRCSEP)/duk_api_debug.c \
$(DISTSRCSEP)/duk_lexer.c \
$(DISTSRCSEP)/duk_js_call.c \
$(DISTSRCSEP)/duk_js_executor.c \
$(DISTSRCSEP)/duk_js_compiler.c \
$(DISTSRCSEP)/duk_regexp_compiler.c \
$(DISTSRCSEP)/duk_regexp_executor.c \
$(DISTSRCSEP)/duk_bi_duktape.c \
$(DISTSRCSEP)/duk_bi_thread.c \
$(DISTSRCSEP)/duk_bi_thrower.c \
$(DISTSRCSEP)/duk_bi_array.c \
$(DISTSRCSEP)/duk_bi_boolean.c \
$(DISTSRCSEP)/duk_bi_date.c \
$(DISTSRCSEP)/duk_bi_error.c \
$(DISTSRCSEP)/duk_bi_function.c \
$(DISTSRCSEP)/duk_bi_global.c \
$(DISTSRCSEP)/duk_bi_json.c \
$(DISTSRCSEP)/duk_bi_math.c \
$(DISTSRCSEP)/duk_bi_number.c \
$(DISTSRCSEP)/duk_bi_object.c \
$(DISTSRCSEP)/duk_bi_regexp.c \
$(DISTSRCSEP)/duk_bi_string.c \
$(DISTSRCSEP)/duk_bi_proxy.c \
$(DISTSRCSEP)/duk_bi_buffer.c \
$(DISTSRCSEP)/duk_bi_pointer.c \
$(DISTSRCSEP)/duk_bi_logger.c \
$(DISTSRCSEP)/duk_selftest.c \
$(DISTSRCSEP)/duk_strings.c
# Use combined sources for testing etc.
DUKTAPE_SOURCES = $(DUKTAPE_SOURCES_COMBINED)
#DUKTAPE_SOURCES = $(DUKTAPE_SOURCES_SEPARATE)
# Duktape command line tool - example of a main() program, used
# for unit testing
DUKTAPE_CMDLINE_SOURCES = \
$(DISTCMD)/duk_cmdline.c \
dist/examples/alloc-logging/duk_alloc_logging.c \
dist/examples/alloc-torture/duk_alloc_torture.c \
dist/examples/alloc-hybrid/duk_alloc_hybrid.c
# Compiler setup for Linux
CC = gcc
GXX = g++
CCOPTS_FEATURES =
#CCOPTS_FEATURES += -DDUK_OPT_NO_PACKED_TVAL
#CCOPTS_FEATURES += -DDUK_OPT_FORCE_ALIGN=4
#CCOPTS_FEATURES += -DDUK_OPT_FORCE_ALIGN=8
#CCOPTS_FEATURES += -DDUK_OPT_FORCE_BYTEORDER=1 # little
#CCOPTS_FEATURES += -DDUK_OPT_FORCE_BYTEORDER=2 # middle
#CCOPTS_FEATURES += -DDUK_OPT_FORCE_BYTEORDER=3 # big
#CCOPTS_FEATURES += -DDUK_OPT_DEEP_C_STACK
#CCOPTS_FEATURES += -DDUK_OPT_NO_REFERENCE_COUNTING
#CCOPTS_FEATURES += -DDUK_OPT_NO_MARK_AND_SWEEP
#CCOPTS_FEATURES += -DDUK_OPT_NO_VOLUNTARY_GC
CCOPTS_FEATURES += -DDUK_OPT_SEGFAULT_ON_PANIC # segfault on panic allows valgrind to show stack trace on panic
CCOPTS_FEATURES += -DDUK_OPT_DPRINT_COLORS
#CCOPTS_FEATURES += -DDUK_OPT_NO_FILE_IO
#CCOPTS_FEATURES += '-DDUK_OPT_PANIC_HANDLER(code,msg)={printf("*** %d:%s\n",(code),(msg));abort();}'
CCOPTS_FEATURES += -DDUK_OPT_SELF_TESTS
#CCOPTS_FEATURES += -DDUK_OPT_NO_TRACEBACKS
#CCOPTS_FEATURES += -DDUK_OPT_NO_PC2LINE
#CCOPTS_FEATURES += -DDUK_OPT_NO_VERBOSE_ERRORS
#CCOPTS_FEATURES += -DDUK_OPT_GC_TORTURE
#CCOPTS_FEATURES += -DDUK_OPT_NO_MS_RESIZE_STRINGTABLE
CCOPTS_FEATURES += -DDUK_OPT_DEBUG_BUFSIZE=512
#CCOPTS_FEATURES += -DDUK_OPT_NO_REGEXP_SUPPORT
#CCOPTS_FEATURES += -DDUK_OPT_NO_OCTAL_SUPPORT
#CCOPTS_FEATURES += -DDUK_OPT_NO_SOURCE_NONBMP
#CCOPTS_FEATURES += -DDUK_OPT_STRICT_UTF8_SOURCE
#CCOPTS_FEATURES += -DDUK_OPT_NO_BROWSER_LIKE
#CCOPTS_FEATURES += -DDUK_OPT_NO_SECTION_B
#CCOPTS_FEATURES += -DDUK_OPT_NO_INTERRUPT_COUNTER
#CCOPTS_FEATURES += -DDUK_OPT_NO_JX
#CCOPTS_FEATURES += -DDUK_OPT_NO_JC
#CCOPTS_FEATURES += -DDUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT
#CCOPTS_FEATURES += -DDUK_OPT_NO_NONSTD_FUNC_STMT
#CCOPTS_FEATURES += -DDUK_OPT_NONSTD_FUNC_CALLER_PROPERTY
#CCOPTS_FEATURES += -DDUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY
#CCOPTS_FEATURES += -DDUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT
#CCOPTS_FEATURES += -DDUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER
#CCOPTS_FEATURES += -DDUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER
#CCOPTS_FEATURES += -DDUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029
#CCOPTS_FEATURES += -DDUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY
#CCOPTS_FEATURES += -DDUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF
#CCOPTS_FEATURES += -DDUK_OPT_NO_ES6_PROXY
#CCOPTS_FEATURES += -DDUK_OPT_NO_ZERO_BUFFER_DATA
#CCOPTS_FEATURES += -DDUK_OPT_USER_INITJS='"this.foo = 123"'
#CCOPTS_FEATURES += -DDUK_OPT_LIGHTFUNC_BUILTINS
CCOPTS_FEATURES += -DDUK_CMDLINE_FANCY
CCOPTS_FEATURES += -DDUK_CMDLINE_ALLOC_LOGGING
CCOPTS_FEATURES += -DDUK_CMDLINE_ALLOC_TORTURE
CCOPTS_FEATURES += -DDUK_CMDLINE_ALLOC_HYBRID
CCOPTS_SHARED =
CCOPTS_SHARED += -pedantic -ansi -std=c99 -fstrict-aliasing
# -Wextra is very picky but catches e.g. signed/unsigned comparisons
CCOPTS_SHARED += -Wall -Wextra -Wunused-result
CCOPTS_SHARED += -I./dist/src -I./dist/examples/alloc-logging -I./dist/examples/alloc-torture -I./dist/examples/alloc-hybrid
#CCOPTS_SHARED += -I./dist/src-separate
#CCOPTS_SHARED += -m32 # force 32-bit compilation on a 64-bit host
#CCOPTS_SHARED += -mx32 # force X32 compilation on a 64-bit host
CCOPTS_NONDEBUG = $(CCOPTS_SHARED) $(CCOPTS_FEATURES)
CCOPTS_NONDEBUG += -Os -fomit-frame-pointer -g -ggdb
#CCOPTS_NONDEBUG += -DDUK_OPT_ASSERTIONS
CCOPTS_DEBUG = $(CCOPTS_SHARED) $(CCOPTS_FEATURES)
CCOPTS_DEBUG += -O0 -g -ggdb
CCOPTS_DEBUG += -DDUK_OPT_DEBUG
CCOPTS_DEBUG += -DDUK_OPT_DPRINT
#CCOPTS_DEBUG += -DDUK_OPT_DDPRINT
#CCOPTS_DEBUG += -DDUK_OPT_DDDPRINT
CCOPTS_DEBUG += -DDUK_OPT_ASSERTIONS
GXXOPTS_NONDEBUG = -pedantic -ansi -std=c++11 -fstrict-aliasing -Wall -Wextra -Wunused-result -Os -fomit-frame-pointer
GXXOPTS_NONDEBUG += -I./dist/src -I./dist/examples/alloc-logging -I./dist/examples/alloc-torture -I./dist/examples/alloc-hybrid
GXXOPTS_DEBUG = -pedantic -ansi -std=c++11 -fstrict-aliasing -Wall -Wextra -Wunused-result -O0 -g -ggdb
GXXOPTS_DEBUG += -I./dist/src -I./dist/examples/alloc-logging -I./dist/examples/alloc-torture -I./dist/examples/alloc-hybrid
GXXOPTS_DEBUG += -DDUK_OPT_DEBUG -DDUK_OPT_DPRINT -DDUK_OPT_ASSERTIONS -DDUK_OPT_SELF_TESTS
#GXXOPTS_DEBUG += -DDUK_OPT_DDPRINT -DDUK_OPT_DDDPRINT
CCLIBS = -lm
CCLIBS += -lreadline
CCLIBS += -lncurses # on some systems -lreadline also requires -lncurses (e.g. RHEL)
# Replace 'duk' and 'dukd' with automatic valgrind wrappers (plain commands
# will be duk.raw and dukd.raw). Targets for runtests.js bypass the wrapper
# because runtests.js has its own valgrind handling.
#VALGRIND_WRAP=1
# Compile 'duk' only by default
.PHONY: all
all: checksetup duk
.PHONY: checksetup
checksetup:
@util/check_setup.sh
.PHONY: clean
clean:
@rm -rf dist/
@rm -rf site/
@rm -f duk.raw dukd.raw duk.vg dukd.vg duk dukd
@rm -f duk-g++ dukd-g++
@rm -f ajduk ajdukd
@rm -f libduktape*.so*
@rm -f duktape-*.tar.*
@rm -f duktape-*.iso
@rm -f doc/*.html
@rm -f src/*.pyc
@rm -rf massif.out.* ms_print.tmp.*
@rm -rf cachegrind.out.*
@rm -rf callgrind.out.*
@rm -rf oprofile_data/
@rm -f /tmp/duk_sizes.html
@rm -f /tmp/duk-test-eval-file-temp.js # used by api-testcase/test-eval-file.js
@rm -rf /tmp/duktape-regfuzz/
@rm -f /tmp/duk-test.log /tmp/duk-api-test.log
@rm -f /tmp/duk-test262.log /tmp/duk-test262-filtered.log
@rm -f /tmp/duk-emcc-test*
@rm -f /tmp/duk-emcc-luatest*
@rm -f /tmp/duk-emcc-duktest*
@rm -f /tmp/duk-jsint-test*
@rm -f /tmp/duk-luajs-mandel.js /tmp/duk-luajs-test.js
@rm -f /tmp/duk-closure-test*
@rm -f a.out
@rm -rf test262-*
@rm -f compiler.jar
@rm -rf lua-5.2.3
@rm -rf luajs
@rm -f dukweb.js
@rm -rf /tmp/dukweb-test/
@rm -f massif-*.out
.PHONY: cleanall
cleanall: clean
# Don't delete these in 'clean' to avoid re-downloading them over and over
@rm -rf duktape-releases
@rm -f regfuzz-*.tar.gz
@rm -rf UglifyJS
@rm -rf UglifyJS2
@rm -rf closure-compiler
@rm -rf underscore
@rm -f d067d2f0ca30.tar.bz2
@rm -rf emscripten
@rm -rf JS-Interpreter
@rm -f compiler-latest.zip
@rm -f cloc-1.60.pl
@rm -f lua-5.2.3.tar.gz
@rm -f luajs.zip
@rm -f jquery-1.11.0.js
@rm -rf coffee-script
@rm -rf LiveScript
@rm -rf coco
@rm -rf sax-js
@rm -rf xmldoc
@rm -rf FlameGraph
@rm -rf dtrace4linux
@rm -rf flow
@rm -rf 595a36b252ee97110724e6fa89fc92c9aa9a206a.zip
@rm -rf alljoyn-js ajtcl
libduktape.so.1.0.0: dist
rm -f $(subst .so.1.0.0,.so.1,$@) $(subst .so.1.0.0,.so.1.0.0,$@) $(subst .so.1.0.0,.so,$@)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
ln -s $@ $(subst .so.1.0.0,.so.1,$@)
ln -s $@ $(subst .so.1.0.0,.so,$@)
libduktaped.so.1.0.0: dist
rm -f $(subst .so.1.0.0,.so.1,$@) $(subst .so.1.0.0,.so.1.0.0,$@) $(subst .so.1.0.0,.so,$@)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
ln -s $@ $(subst .so.1.0.0,.so.1,$@)
ln -s $@ $(subst .so.1.0.0,.so,$@)
duk.raw: dist
$(CC) -o $@ $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
-@size $@
# Test target for g++ compile
duk-g++: dist
$(GXX) -o $@ $(GXXOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
-@size $@
dukd-g++: dist
$(GXX) -o $@ $(GXXOPTS_DEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
-@size $@
dump-public: duk.raw
@(objdump -t $< | grep ' g' | grep .text | grep -v .hidden | tr -s ' ' | cut -d ' ' -f 5 | sort > /tmp/duk-public.txt ; true)
@echo "Symbol dump in /tmp/duk-public.txt"
@(grep duk__ /tmp/duk-public.txt ; true) # check for leaked file local symbols (does not cover internal, but not public symbols)
duk.vg: duk.raw
@rm -f $@
@echo '#!/bin/sh' > $@
@echo 'valgrind "$(shell pwd)/$<" "$$@"' >> $@
@chmod ugo+rx $@
duk: duk.raw duk.vg
@rm -f $@
ifeq ($(VALGRIND_WRAP),1)
@echo "Using valgrind wrapped $@"
@cp duk.vg $@
else
@cp duk.raw $@
endif
dukd.raw: dist
$(CC) -o $@ $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
-@size $@
dukd.vg: dukd.raw
@rm -f $@
@echo '#!/bin/sh' > $@
@echo 'valgrind "$(shell pwd)/$<" "$$@"' >> $@
@chmod ugo+rx $@
dukd: dukd.raw dukd.vg
@rm -f dukd
ifeq ($(VALGRIND_WRAP),1)
@echo "Using valgrind wrapped $@"
@cp dukd.vg $@
else
@cp dukd.raw $@
endif
.PHONY: duksizes
duksizes: duk.raw
$(PYTHON) src/genexesizereport.py $< > /tmp/duk_sizes.html
.PHONY: issuecount
issuecount:
@echo "FIXME: `grep FIXME: src/*.c src/*.h src/*.in | wc -l | tr -d ' '`"
@echo "XXX: `grep XXX: src/*.c src/*.h src/*.in | wc -l | tr -d ' '`"
@echo "TODO: `grep TODO: src/*.c src/*.h src/*.in | wc -l | tr -d ' '`"
@echo "NOTE: `grep NOTE: src/*.c src/*.h src/*.in | wc -l | tr -d ' '`"
@echo "SCANBUILD: `grep SCANBUILD: src/*.c src/*.h src/*.in | wc -l | tr -d ' '`"
@echo "Ditz ($(DITZ_RELEASE)): `ditz todo $(DITZ_RELEASE) | wc -l | tr -d ' '`"
.PHONY: issues
issues:
ditz todo $(DITZ_RELEASE)
.PHONY: dukscanbuild
dukscanbuild: dist
scan-build gcc -o/tmp/duk.scanbuild -Idist/src-separate/ $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES_SEPARATE) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
.PHONY: dukdscanbuild
dukdscanbuild: dist
scan-build gcc -o/tmp/duk.scanbuild -Idist/src-separate/ $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES_SEPARATE) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
.PHONY: test
test: qecmatest apitest regfuzztest underscoretest emscriptentest test262test
.PHONY: ecmatest
ecmatest: npminst duk
ifeq ($(VALGRIND_WRAP),1)
@echo "### ecmatest (valgrind)"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.raw --report-diff-to-other --valgrind --run-nodejs --run-rhino --num-threads 1 --log-file=/tmp/duk-test.log ecmascript-testcases/
else
@echo "### ecmatest"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk --report-diff-to-other --run-nodejs --run-rhino --num-threads 8 --log-file=/tmp/duk-test.log ecmascript-testcases/
endif
.PHONY: ecmatestd
ecmatestd: npminst dukd
ifeq ($(VALGRIND_WRAP),1)
@echo "### ecmatestd (valgrind)"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/dukd.raw --report-diff-to-other --valgrind --run-nodejs --run-rhino --num-threads 1 --log-file=/tmp/duk-test.log ecmascript-testcases/
else
@echo "### ecmatestd"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/dukd --report-diff-to-other --run-nodejs --run-rhino --num-threads 8 --log-file=/tmp/duk-test.log ecmascript-testcases/
endif
.PHONY: qecmatest
qecmatest: npminst duk
ifeq ($(VALGRIND_WRAP),1)
@echo "### qecmatest (valgrind)"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.raw --valgrind --num-threads 1 --log-file=/tmp/duk-test.log ecmascript-testcases/
else
@echo "### qecmatest"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk --num-threads 16 --log-file=/tmp/duk-test.log ecmascript-testcases/
endif
.PHONY: qecmatestd
qecmatestd: npminst dukd
ifeq ($(VALGRIND_WRAP),1)
@echo "### qecmatestd (valgrind)"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/dukd.raw --valgrind --num-threads 1 --log-file=/tmp/duk-test.log ecmascript-testcases/
else
@echo "### qecmatestd"
$(NODE) runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/dukd --num-threads 16 --log-file=/tmp/duk-test.log ecmascript-testcases/
endif
# Separate target because it's also convenient to run manually.
.PHONY: apiprep
apiprep: npminst libduktape.so.1.0.0
.PHONY: apitest
apitest: apiprep
ifeq ($(VALGRIND_WRAP),1)
@echo "### apitest (valgrind)"
$(NODE) runtests/runtests.js --num-threads 1 --valgrind --log-file=/tmp/duk-api-test.log api-testcases/
else
@echo "### apitest"
$(NODE) runtests/runtests.js --num-threads 1 --log-file=/tmp/duk-api-test.log api-testcases/
endif
regfuzz-0.1.tar.gz:
# https://code.google.com/p/regfuzz/
# SHA1: 774be8e3dda75d095225ba699ac59969d92ac970
$(WGET) https://regfuzz.googlecode.com/files/regfuzz-0.1.tar.gz
.PHONY: regfuzztest
regfuzztest: regfuzz-0.1.tar.gz duk
@echo "### regfuzztest"
# Spidermonkey test is pretty close, just lacks 'arguments'
# Should run with assertions enabled in 'duk'
rm -rf /tmp/duktape-regfuzz; mkdir -p /tmp/duktape-regfuzz
cp regfuzz-0.1.tar.gz duk /tmp/duktape-regfuzz
tar -C /tmp/duktape-regfuzz -x -v -z -f regfuzz-0.1.tar.gz
echo "arguments = [ 0xdeadbeef ];" > /tmp/duktape-regfuzz/regfuzz-test.js
cat /tmp/duktape-regfuzz/regfuzz-0.1/examples/spidermonkey/regexfuzz.js >> /tmp/duktape-regfuzz/regfuzz-test.js
cd /tmp/duktape-regfuzz; ./duk regfuzz-test.js
underscore:
# http://underscorejs.org/
# https://github.com/jashkenas/underscore
# Master is OK because not a critical dependency
$(GIT) clone --depth 1 https://github.com/jashkenas/underscore.git
.PHONY: underscoretest
underscoretest: underscore duk
@echo "### underscoretest"
@echo "Run underscore tests with underscore-test-shim.js"
-util/underscore_test.sh ./duk underscore/test/arrays.js
-util/underscore_test.sh ./duk underscore/test/chaining.js
-util/underscore_test.sh ./duk underscore/test/collections.js
-util/underscore_test.sh ./duk underscore/test/functions.js
-util/underscore_test.sh ./duk underscore/test/objects.js
# speed test disabled, requires JSLitmus
#-util/underscore_test.sh ./duk underscore/test/speed.js
-util/underscore_test.sh ./duk underscore/test/utility.js
595a36b252ee97110724e6fa89fc92c9aa9a206a.zip:
# http://test262.ecmascript.org/
# https://github.com/tc39/test262
# HG repo seems to have migrated to https://github.com/tc39/test262
#$(WGET) http://hg.ecmascript.org/tests/test262/archive/d067d2f0ca30.tar.bz2
$(WGET) https://github.com/tc39/test262/archive/595a36b252ee97110724e6fa89fc92c9aa9a206a.zip
test262-595a36b252ee97110724e6fa89fc92c9aa9a206a: 595a36b252ee97110724e6fa89fc92c9aa9a206a.zip
unzip $<
touch $@
.PHONY: test262test
test262test: test262-595a36b252ee97110724e6fa89fc92c9aa9a206a duk
@echo "### test262test"
# http://wiki.ecmascript.org/doku.php?id=test262:command
rm -f /tmp/duk-test262.log /tmp/duk-test262-filtered.log
-cd test262-595a36b252ee97110724e6fa89fc92c9aa9a206a; $(PYTHON) tools/packaging/test262.py --command "../duk {{path}}" --summary >/tmp/duk-test262.log
cat /tmp/duk-test262.log | $(PYTHON) util/filter_test262_log.py doc/test262-known-issues.json > /tmp/duk-test262-filtered.log
cat /tmp/duk-test262-filtered.log
# Unholy helper to write out a testcase, the unholiness is that it reads
# command line arguments and complains about missing targets etc:
# http://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line
.PHONY: test262cat
test262cat: test262-595a36b252ee97110724e6fa89fc92c9aa9a206a
@echo "NOTE: this Makefile target will print a 'No rule...' error, ignore it" >&2
-@cd test262-595a36b252ee97110724e6fa89fc92c9aa9a206a; $(PYTHON) tools/packaging/test262.py --command "../duk {{path}}" --cat $(filter-out $@,$(MAKECMDGOALS))
emscripten:
# https://github.com/kripken/emscripten
# Master is OK because not a critical dependency
$(GIT) clone --depth 1 https://github.com/kripken/emscripten.git
cd emscripten; ./emconfigure
# Reducing the TOTAL_MEMORY and TOTAL_STACK values is useful if you run
# Duktape cmdline with resource limits (i.e. "duk -r test.js").
# Recent Emscripten will assume typed array support unless EMCC_FAST_COMPILER=0
# is given through the environment:
# https://github.com/kripken/emscripten/wiki/LLVM-Backend
#EMCCOPTS=-s USE_TYPED_ARRAYS=0 -s TOTAL_MEMORY=2097152 -s TOTAL_STACK=524288 --memory-init-file 0
EMCCOPTS=-s USE_TYPED_ARRAYS=0 --memory-init-file 0
.PHONY: emscriptentest
emscriptentest: emscripten duk
@echo "### emscriptentest"
@rm -f /tmp/duk-emcc-test*
@echo "NOTE: this emscripten test is incomplete (compiles hello_world.cpp and tries to run it, no checks yet)"
EMCC_FAST_COMPILER=0 emscripten/emcc $(EMCCOPTS) emscripten/tests/hello_world.cpp -o /tmp/duk-emcc-test.js
cat /tmp/duk-emcc-test.js | $(PYTHON) util/fix_emscripten.py > /tmp/duk-emcc-test-fixed.js
@ls -l /tmp/duk-emcc-test*
./duk /tmp/duk-emcc-test-fixed.js
#./duk /tmp/duk-emcc-test.js
# Compile Duktape with Emscripten and execute it with NodeJS.
# Current status: requires Duktape alignment fixes (alignment by 8).
# With manual alignment hacks the result works. Emscripten options
# need to be chosen carefully:
# - Without DUK_OPT_NO_PACKED_TVAL some asserts fail, at least when
# -O2 (with asm.js) is used
# - -O1 and above triggers asm.js use, which has at least the following
# problem:
# "too many setjmps in a function call, build with a higher value for MAX_SETJMPS"
# - Using -O2 without asm.js for now.
# - --memory-init-file 0 to avoid a separate memory init file (this is
# not mandatory but keeps the result in a single file)
# https://github.com/kripken/emscripten/wiki/Optimizing-Code
# http://mozakai.blogspot.fi/2013/08/outlining-workaround-for-jits-and-big.html
EMCCOPTS_DUKVM=-O2 -std=c99 -Wall -s OUTLINING_LIMIT=20000 -s MAX_SETJMPS=1000 -s ASM_JS=0 --memory-init-file 0 -DEMSCRIPTEN
MAND_BASE64=dyA9IDgwOyBoID0gNDA7IGl0ZXIgPSAxMDA7IGZvciAoaSA9IDA7IGkgLSBoOyBpICs9IDEpIHsgeTAgPSAoaSAvIGgpICogNC4wIC0gMi4wOyByZXMgPSBbXTsgZm9yIChqID0gMDsgaiAtIHc7IGogKz0gMSkgeyB4MCA9IChqIC8gdykgKiA0LjAgLSAyLjA7IHh4ID0gMDsgeXkgPSAwOyBjID0gIiMiOyBmb3IgKGsgPSAwOyBrIC0gaXRlcjsgayArPSAxKSB7IHh4MiA9IHh4Knh4OyB5eTIgPSB5eSp5eTsgaWYgKE1hdGgubWF4KDAsIDQuMCAtICh4eDIgKyB5eTIpKSkgeyB5eSA9IDIqeHgqeXkgKyB5MDsgeHggPSB4eDIgLSB5eTIgKyB4MDsgfSBlbHNlIHsgYyA9ICIuIjsgYnJlYWs7IH0gfSByZXNbcmVzLmxlbmd0aF0gPSBjOyB9IHByaW50KHJlcy5qb2luKCIiKSk7IH0K
.PHONY: emscriptenduktest
emscriptenduktest: emscripten dist
@echo "### emscriptenduktest"
@rm -f /tmp/duk-emcc-duktest.js
EMCC_FAST_COMPILER=0 emscripten/emcc $(EMCCOPTS_DUKVM) -DDUK_OPT_ASSERTIONS -DDUK_OPT_SELF_TESTS -Idist/src/ dist/src/duktape.c dist/examples/eval/eval.c -o /tmp/duk-emcc-duktest.js
$(NODE) /tmp/duk-emcc-duktest.js \
'print("Hello from Duktape running inside Emscripten/NodeJS");' \
'print(Duktape.version, Duktape.env);' \
'for(i=0;i++<100;)print((i%3?"":"Fizz")+(i%5?"":"Buzz")||i)'
$(NODE) /tmp/duk-emcc-duktest.js "eval(''+Duktape.dec('base64', '$(MAND_BASE64)'))"
# This is a prototype of running Duktape in a web environment with Emscripten,
# and providing an eval() facility from both sides. This is a placeholder now
# and doesn't do anything useful yet.
EMCCOPTS_DUKWEB_EXPORT=-s EXPORTED_FUNCTIONS='["_dukweb_is_open", "_dukweb_open","_dukweb_close","_dukweb_eval"]'
EMCCOPTS_DUKWEB_DEFINES=-DDUK_OPT_ASSERTIONS -DDUK_OPT_SELF_TESTS -DDUK_OPT_DEEP_C_STACK '-DDUK_OPT_DECLARE=extern void dukweb_panic_handler(int code, const char *msg);' '-DDUK_OPT_PANIC_HANDLER(code,msg)={dukweb_panic_handler((code),(msg));abort();}'
# FIXME: need to be able to declare dukweb_panic_handler to avoid warnings
dukweb.js: emscripten dist
EMCC_FAST_COMPILER=0 emscripten/emcc $(EMCCOPTS_DUKVM) $(EMCCOPTS_DUKWEB_EXPORT) $(EMCCOPTS_DUKWEB_DEFINES) \
-Idist/src/ dist/src/duktape.c dukweb/dukweb.c -o dukweb.js
cat dukweb/dukweb_extra.js >> dukweb.js
@wc dukweb.js
.PHONY: dukwebtest
dukwebtest: dukweb.js jquery-1.11.0.js
@echo "### dukwebtest"
@rm -rf /tmp/dukweb-test/
mkdir /tmp/dukweb-test/
cp dukweb.js jquery-1.11.0.js dukweb/dukweb.html dukweb/dukweb.css /tmp/dukweb-test/
@echo "Now point your browser to: file:///tmp/dukweb-test/dukweb.html"
jquery-1.11.0.js:
$(WGET) http://code.jquery.com/jquery-1.11.0.js
lua-5.2.3.tar.gz:
$(WGET) http://www.lua.org/ftp/lua-5.2.3.tar.gz
lua-5.2.3: lua-5.2.3.tar.gz
tar xfz lua-5.2.3.tar.gz
LUASRC= lapi.c lauxlib.c lbaselib.c lbitlib.c lcode.c lcorolib.c lctype.c \
ldblib.c ldebug.c ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c \
llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c loslib.c \
lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c \
lua.c lundump.c lvm.c lzio.c
# This doesn't currently work: -s USE_TYPED_ARRAYS=0 causes compilation to
# fail. Duktape also used to run out of registers trying to run the result,
# but this should no longer be the case.
.PHONY: emscriptenluatest
emscriptenluatest: emscripten duk lua-5.2.3
@echo "### emscriptenluatest"
@rm -f /tmp/duk-emcc-luatest*
EMCC_FAST_COMPILER=0 emscripten/emcc $(EMCCOPTS) -Ilua-5.2.3/src/ $(patsubst %,lua-5.2.3/src/%,$(LUASRC)) -o /tmp/duk-emcc-luatest.js
cat /tmp/duk-emcc-luatest.js | $(PYTHON) util/fix_emscripten.py > /tmp/duk-emcc-luatest-fixed.js
@ls -l /tmp/duk-emcc-luatest*
./duk /tmp/duk-emcc-luatest-fixed.js
JS-Interpreter:
# https://github.com/NeilFraser/JS-Interpreter
# Master is OK because not a critical dependency
$(GIT) clone --depth 1 https://github.com/NeilFraser/JS-Interpreter.git
.PHONY: jsinterpretertest
jsinterpretertest: JS-Interpreter duk
@echo "### jsinterpretertest"
@rm -f /tmp/duk-jsint-test*
echo "window = {};" > /tmp/duk-jsint-test.js
cat JS-Interpreter/acorn.js JS-Interpreter/interpreter.js >> /tmp/duk-jsint-test.js
cat jsinterpreter-testcases/addition.js >> /tmp/duk-jsint-test.js
./duk /tmp/duk-jsint-test.js
luajs.zip:
# https://github.com/mherkender/lua.js
$(WGET) https://github.com/mherkender/lua.js/raw/precompiled2/luajs.zip
luajs: luajs.zip
@rm -rf luajs/
mkdir luajs
cd luajs; unzip ../luajs.zip
.PHONY: luajstest
luajstest: luajs duk
@rm -f /tmp/duk-luajs-mandel.js /tmp/duk-luajs-test.js
luajs/lua2js luajs-testcases/mandel.lua /tmp/duk-luajs-mandel.js
echo "console = { log: function() { print(Array.prototype.join.call(arguments, ' ')); } };" > /tmp/duk-luajs-test.js
cat luajs/lua.js /tmp/duk-luajs-mandel.js >> /tmp/duk-luajs-test.js
./duk /tmp/duk-luajs-test.js
# Closure
compiler-latest.zip:
# Prebuilt latest version; this is not good as a build dependency
# because closure changes may break minified initjs code and make
# old builds unreliable.
# https://code.google.com/p/closure-compiler/
$(WGET) http://dl.google.com/closure-compiler/compiler-latest.zip
closure-compiler:
# https://github.com/google/closure-compiler
@rm -f v20140814.tar.gz
$(WGET) https://github.com/google/closure-compiler/archive/v20140814.tar.gz
tar xfz v20140814.tar.gz
mv closure-compiler-20140814 closure-compiler
@rm -f v20140814.tar.gz
closure-compiler/build/compiler.jar: closure-compiler
cd closure-compiler; ant
compiler.jar: closure-compiler/build/compiler.jar
cp closure-compiler/build/compiler.jar $@
touch $@ # ensure date is newer than compiler-latest.zip
.PHONY: closuretest
closuretest: compiler.jar duk
@echo "### closuretest"
@rm -f /tmp/duk-closure-test*
$(JAVA) -jar compiler.jar ecmascript-testcases/test-dev-mandel2-func.js > /tmp/duk-closure-test.js
./duk /tmp/duk-closure-test.js
UglifyJS:
# https://github.com/mishoo/UglifyJS
# Use a specific release because UglifyJS is used in building Duktape
@rm -f v1.3.5.tar.gz
$(WGET) https://github.com/mishoo/UglifyJS/archive/v1.3.5.tar.gz
tar xfz v1.3.5.tar.gz
mv UglifyJS-1.3.5 UglifyJS
@rm -f v1.3.5.tar.gz
# Don't use this because it's a moving critical dependency
#$(GIT) clone --depth 1 https://github.com/mishoo/UglifyJS.git
UglifyJS2:
# https://github.com/mishoo/UglifyJS2
# Use a specific release because UglifyJS2 is used in building Duktape
# (This is now a bit futile because UglifyJS2 requires an 'npm install',
# the NodeJS dependencies need to be controlled for this to really work.)
@rm -f v2.4.12.tar.gz
$(WGET) https://github.com/mishoo/UglifyJS2/archive/v2.4.12.tar.gz
tar xfz v2.4.12.tar.gz
mv UglifyJS2-2.4.12 UglifyJS2
@rm -f v2.4.12.tar.gz
# Don't use this because it's a moving critical dependency
#$(GIT) clone --depth 1 https://github.com/mishoo/UglifyJS2.git
cd UglifyJS2; npm install; cd -
cloc-1.60.pl:
# http://cloc.sourceforge.net/
$(WGET) http://downloads.sourceforge.net/project/cloc/cloc/v1.60/cloc-1.60.pl
coffee-script:
# http://coffeescript.org/
# https://github.com/jashkenas/coffee-script
$(GIT) clone --depth 1 https://github.com/jashkenas/coffee-script.git
LiveScript:
# http://livescript.net/
# https://github.com/gkz/LiveScript
$(GIT) clone --depth 1 https://github.com/gkz/LiveScript.git
coco:
# https://github.com/satyr/coco
$(GIT) clone --depth 1 https://github.com/satyr/coco
sax-js:
# https://github.com/isaacs/sax-js
$(GIT) clone --depth 1 https://github.com/isaacs/sax-js.git
xmldoc:
# https://github.com/nfarina/xmldoc
# http://nfarina.com/post/34302964969/a-lightweight-xml-document-class-for-nodejs-javascript
$(GIT) clone --depth 1 https://github.com/nfarina/xmldoc.git
xmldoctest: sax-js xmldoc duk
@echo "### xmldoctest"
@rm -f /tmp/duk-xmldoc-test*
cat sax-js/lib/sax.js > /tmp/duk-xmldoc-test.js
echo ";" >> /tmp/duk-xmldoc-test.js # missing end semicolon causes automatic semicolon problem
cat xmldoc/lib/xmldoc.js >> /tmp/duk-xmldoc-test.js
echo ";" >> /tmp/duk-xmldoc-test.js # missing end semicolon causes automatic semicolon problem
cat xmldoc-testcases/basic.js >> /tmp/duk-xmldoc-test.js
./duk /tmp/duk-xmldoc-test.js
FlameGraph:
# http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
# https://github.com/brendangregg/FlameGraph
$(GIT) clone --depth 1 https://github.com/brendangregg/FlameGraph.git
dtrace4linux:
# https://github.com/dtrace4linux/linux
# http://crtags.blogspot.fi/
$(GIT) clone --depth 1 https://github.com/dtrace4linux/linux.git dtrace4linux
flow:
# https://github.com/facebook/flow
$(GIT) clone --depth 1 https://github.com/facebook/flow.git
alljoyn-js:
# https://git.allseenalliance.org/cgit/core/alljoyn-js.git/
# no --depth 1 ("dumb http transport does not support --depth")
$(GIT) clone https://git.allseenalliance.org/cgit/core/alljoyn-js.git/
ajtcl:
# https://git.allseenalliance.org/cgit/core/ajtcl.git/
# no --depth 1 ("dumb http transport does not support --depth")
$(GIT) clone https://git.allseenalliance.org/cgit/core/ajtcl.git/
ajduk: alljoyn-js ajtcl dist
# Command line with Alljoyn.js pool allocator, for low memory testing.
# The pool sizes only make sense with -m32, so force that. This forces
# us to use barebones cmdline too. The compilation produces some
# harmless warnings at present.
$(CC) -o $@ \
-Ialljoyn-js/ -Iajtcl/inc/ -Iajtcl/target/linux/ \
$(CCOPTS_NONDEBUG) \
-m32 \
-UDUK_CMDLINE_FANCY -DDUK_CMDLINE_AJSHEAP -D_POSIX_C_SOURCE=200809L \
-DDUK_OPT_LIGHTFUNC_BUILTINS \
$(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) \
alljoyn-js/ajs_heap.c ajtcl/src/aj_debug.c ajtcl/target/linux/aj_target_util.c \
-lm -lpthread
@echo "*** SUCCESS:"
@ls -l ajduk
.PHONY: gccpredefs
gccpredefs:
gcc -dM -E - < /dev/null
.PHONY: clangpredefs
clangpredefs:
clang -dM -E - < /dev/null
.PHONY: npminst
npminst: runtests/node_modules
runtests/node_modules:
echo "Installing required NodeJS modules for runtests"
cd runtests; npm install
.PHONY: doc
doc: $(patsubst %.txt,%.html,$(wildcard doc/*.txt))
doc/%.html: doc/%.txt
rst2html $< $@
# Source distributable for end users
# XXX: want to run codepolicycheck when dist gets built, but don't want to depend on it.
# XXX: make prints a harmless warning related to the sub-make.
dist: compiler.jar cloc-1.60.pl
@make codepolicycheck
sh util/make_dist.sh --minify closure
.PHONY: dist-src
dist-src: dist
rm -rf duktape-$(DUK_VERSION_FORMATTED)
rm -rf duktape-$(DUK_VERSION_FORMATTED).tar*
mkdir duktape-$(DUK_VERSION_FORMATTED)
cp -r dist/* duktape-$(DUK_VERSION_FORMATTED)/
tar cvfz duktape-$(DUK_VERSION_FORMATTED).tar.gz duktape-$(DUK_VERSION_FORMATTED)/
tar cvf duktape-$(DUK_VERSION_FORMATTED).tar duktape-$(DUK_VERSION_FORMATTED)/
xz -z -e -9 duktape-$(DUK_VERSION_FORMATTED).tar
cp duktape-$(DUK_VERSION_FORMATTED).tar.gz duktape-$(DUK_VERSION_FORMATTED)-$(BUILD_DATETIME)-$(GIT_DESCRIBE).tar.gz
cp duktape-$(DUK_VERSION_FORMATTED).tar.xz duktape-$(DUK_VERSION_FORMATTED)-$(BUILD_DATETIME)-$(GIT_DESCRIBE).tar.xz
rm -rf duktape-$(DUK_VERSION_FORMATTED)
# ISO target is useful with some system emulators with no network access
.PHONY: dist-iso
dist-iso: dist-src
mkisofs -input-charset utf-8 -o duktape-$(DUK_VERSION_FORMATTED)-$(BUILD_DATETIME)-$(GIT_DESCRIBE).iso duktape-$(DUK_VERSION_FORMATTED)-$(BUILD_DATETIME)-$(GIT_DESCRIBE).tar.gz
.PHONY: tidy-site
tidy-site:
for i in website/*/*.html; do echo "*** Checking $$i"; tidy -q -e -xml $$i; done
# Duktape binary releases are in a separate repo
duktape-releases:
$(GIT) clone https://github.com/svaarala/duktape-releases.git
# Website
site: duktape-releases dukweb.js jquery-1.11.0.js
rm -rf site
mkdir site
-cd duktape-releases/; git pull --rebase # get binaries up-to-date, but allow errors for offline use
cd website/; $(PYTHON) buildsite.py ../site/
@rm -rf /tmp/site/
cp -r site /tmp/ # FIXME
.PHONY: dist-site
dist-site: tidy-site site
# When doing a final dist build, run html tidy
# Also pull binaries up-to-date
cd duktape-releases/; git pull --rebase # get binaries up-to-date
rm -rf duktape-site-$(DUK_VERSION_FORMATTED)
rm -rf duktape-site-$(DUK_VERSION_FORMATTED).tar*
mkdir duktape-site-$(DUK_VERSION_FORMATTED)
cp -r site/* duktape-site-$(DUK_VERSION_FORMATTED)/
tar cvf duktape-site-$(DUK_VERSION_FORMATTED).tar duktape-site-$(DUK_VERSION_FORMATTED)/
xz -z -e -9 duktape-site-$(DUK_VERSION_FORMATTED).tar
cp duktape-site-$(DUK_VERSION_FORMATTED).tar.xz duktape-site-$(DUK_VERSION_FORMATTED)-$(BUILD_DATETIME)-$(GIT_DESCRIBE).tar.xz
rm -rf duktape-site-$(DUK_VERSION_FORMATTED)
.PHONY: codepolicycheck
codepolicycheck:
-python util/check_code_policy.py src/*.c src/*.h src/*.h.in api-testcases/*.c
.PHONY: codepolicycheckvim
codepolicycheckvim:
-python util/check_code_policy.py --dump-vim-commands src/*.c src/*.h src/*.h.in api-testcases/*.c
.PHONY: big-git-files
big-git-files:
util/find_big_git_files.sh
# Simple heap graph and peak usage using valgrind --tool=massif, for quick
# and dirty baseline comparison. Say e.g. 'make massif-test-dev-hello-world'.
# The target name is intentionally not 'massif-%.out' so that the rule is never
# satisfied and can be executed multiple times without cleaning.
# Grep/sed hacks from:
# http://stackoverflow.com/questions/774556/peak-memory-usage-of-a-linux-unix-process
massif-%: ecmascript-testcases/%.js duk
@rm -f $(@).out
valgrind --tool=massif --peak-inaccuracy=0.0 --massif-out-file=$(@).out ./duk $< >/dev/null 2>/dev/null
@ms_print $(@).out | head -35
@echo "[... clipped... ]"
@echo ""
@echo -n "MAXIMUM: "
@cat $(@).out | grep mem_heap_B | sed -e 's/mem_heap_B=\(.*\)/\1/' | sort -g | tail -n 1
# Convenience targets
massif-helloworld: massif-test-dev-hello-world
massif-deepmerge: massif-test-dev-deepmerge
massif-arcfour: massif-test-dev-arcfour