You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

273 lines
9.2 KiB

#
# Makefile for the Duktape repository (Duktape development)
#
# This is an internal Makefile usd to create distributables like a
# source package, documentation, or Duktape website pages. It also
# supports Duktape development, e.g. convenient test case runs for
# both Ecmascript and Duktape C API test cases.
#
# 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 sources used
# by a developer, at the risk of polluting the dist directory
# (accidentally; we try to avoid that of course).
#
# When creating actual distributables, always clean first.
#
# FIXME: stripping and size reporting
VERSION=0.6.0
DISTSRCSEP = dist/src-separate
DISTSRCCOM = dist/src-combined
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_fatal.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_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_strings.c \
$(DISTSRCSEP)/duk_builtins.c \
$(DISTSRCSEP)/duk_js_ops.c \
$(DISTSRCSEP)/duk_js_var.c \
$(DISTSRCSEP)/duk_numconv.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_thread.c \
$(DISTSRCSEP)/duk_api_buffer.c \
$(DISTSRCSEP)/duk_api_var.c \
$(DISTSRCSEP)/duk_api.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_builtin_duk.c \
$(DISTSRCSEP)/duk_builtin_thread.c \
$(DISTSRCSEP)/duk_builtin_thrower.c \
$(DISTSRCSEP)/duk_builtin_array.c \
$(DISTSRCSEP)/duk_builtin_boolean.c \
$(DISTSRCSEP)/duk_builtin_date.c \
$(DISTSRCSEP)/duk_builtin_error.c \
$(DISTSRCSEP)/duk_builtin_function.c \
$(DISTSRCSEP)/duk_builtin_global.c \
$(DISTSRCSEP)/duk_builtin_json.c \
$(DISTSRCSEP)/duk_builtin_math.c \
$(DISTSRCSEP)/duk_builtin_number.c \
$(DISTSRCSEP)/duk_builtin_object.c \
$(DISTSRCSEP)/duk_builtin_regexp.c \
$(DISTSRCSEP)/duk_builtin_string.c
# Use combined sources for testing etc.
DUKTAPE_SOURCES = $(DUKTAPE_SOURCES_COMBINED)
# Duktape command line tool - example of a main() program, used
# for unit testing
DUKTAPE_CMDLINE_SOURCES = \
$(DISTCMD)/duk_cmdline.c \
$(DISTCMD)/duk_ncurses.c \
$(DISTCMD)/duk_socket.c \
$(DISTCMD)/duk_fileio.c
DUK_SHARED_LIBS_NONDEBUG = \
libduktape100.so.1.0.0 libduktape101.so.1.0.0 \
libduktape200.so.1.0.0 libduktape201.so.1.0.0 \
libduktape300.so.1.0.0 libduktape301.so.1.0.0 \
libduktape400.so.1.0.0 libduktape401.so.1.0.0 \
libduktape500.so.1.0.0 libduktape501.so.1.0.0
DUK_SHARED_LIBS_DEBUG = \
libduktape100d.so.1.0.0 libduktape101d.so.1.0.0 \
libduktape200d.so.1.0.0 libduktape201d.so.1.0.0 \
libduktape300d.so.1.0.0 libduktape301d.so.1.0.0 \
libduktape400d.so.1.0.0 libduktape401d.so.1.0.0 \
libduktape500d.so.1.0.0 libduktape501d.so.1.0.0
DUK_CMDLINE_TOOLS_NONDEBUG = \
duk.100 duk.101 \
duk.200 duk.201 \
duk.300 duk.301 \
duk.400 duk.401 \
duk.500 duk.501
DUK_CMDLINE_TOOLS_DEBUG = \
duk.100d duk.101d \
duk.200d duk.201d \
duk.300d duk.301d \
duk.400d duk.401d \
duk.500d duk.501d
# Compiler setup for Linux
CC = gcc
CCOPTS_SHARED = -pedantic -ansi -std=c99 -Wall -fstrict-aliasing
CCOPTS_SHARED += -I./dist/src-combined
#CCOPTS_SHARED += -I./dist/src-separate
#CCOPTS_SHARED += -m32 # force 32-bit compilation on a 64-bit host
CCOPTS_SHARED += -I/usr/include/ncurses # for cmdline tool
CCOPTS_NONDEBUG = $(CCOPTS_SHARED) -Os -fomit-frame-pointer
CCOPTS_DEBUG = $(CCOPTS_SHARED) -O0 -g -ggdb
CCLIBS = -lm
CCLIBS += -lreadline -lncurses # for cmdline tool
.PHONY: default all clean test install
default: all64
all32: $(DUK_CMDLINE_TOOLS_NONDEBUG) \
$(DUK_CMDLINE_TOOLS_DEBUG) \
$(DUK_SHARED_LIBS_NONDEBUG) \
$(DUK_SHARED_LIBS_DEBUG)
all64: duk.400 duk.401 \
duk.400d duk.401d \
duk.500 duk.501 \
duk.500d duk.501d \
libduktape400.so.1.0.0 libduktape401.so.1.0.0 \
libduktape400d.so.1.0.0 libduktape401d.so.1.0.0 \
libduktape500.so.1.0.0 libduktape501.so.1.0.0 \
libduktape500d.so.1.0.0 libduktape501d.so.1.0.0
clean:
-@rm -rf dist/
-@rm -rf maint/
-@rm -f $(DUK_CMDLINE_TOOLS_NONDEBUG)
-@rm -f $(DUK_CMDLINE_TOOLS_DEBUG)
-@rm -f $(DUK_SHARED_LIBS_NONDEBUG)
-@rm -f $(DUK_SHARED_LIBS_DEBUG)
-@rm -f libduktape*.so*
-@rm -rf duktape-$(VERSION)/
-@rm -f duktape-$(VERSION).tar*
-@rm -f duktape-$(VERSION).iso
-@rm -rf duktape-maint-$(VERSION)/
-@rm -f duktape-maint-$(VERSION).tar*
-@rm -rf duktape-web-$(VERSION)/
-@rm -f duktape-web-$(VERSION).tar*
-@rm -f doc/*.html
$(DUK_SHARED_LIBS_NONDEBUG): dist
-rm -f $(subst .so.1.0.0,.so.1,$@) $(subst .so.1.0.0,.so.1.0.0,$@)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC -DDUK_PROFILE=$(subst d,,$(subst .so.1.0.0,,$(subst libduktape,,$@))) $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
ln -s $@ $(subst .so.1.0.0,.so.1,$@)
ln -s $@ $(subst .so.1.0.0,.so,$@)
$(DUK_SHARED_LIBS_DEBUG): dist
-rm -f $(subst .so.1.0.0,.so.1,$@) $(subst .so.1.0.0,.so.1.0.0,$@)
$(CC) -o $@ -shared -Wl,-soname,$(subst .so.1.0.0,.so.1,$@) -fPIC -DDUK_PROFILE=$(subst d,,$(subst .so.1.0.0,,$(subst libduktape,,$@))) $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(CCLIBS)
ln -s $@ $(subst .so.1.0.0,.so.1,$@)
ln -s $@ $(subst .so.1.0.0,.so,$@)
$(DUK_CMDLINE_TOOLS_NONDEBUG): dist
$(CC) -o $@ -DDUK_PROFILE=$(subst d,,$(subst duk.,,$@)) $(CCOPTS_NONDEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
$(DUK_CMDLINE_TOOLS_DEBUG): dist
$(CC) -o $@ -DDUK_PROFILE=$(subst d,,$(subst duk.,,$@)) $(CCOPTS_DEBUG) $(DUKTAPE_SOURCES) $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
test: duk.400
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.400 --run-nodejs --run-rhino --num-threads 8 --log-file=/tmp/duk-test.log ecmascript-testcases/
qtest: duk.400
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.400 --num-threads 16 --log-file=/tmp/duk-test.log ecmascript-testcases/
vgtest: duk.400
node runtests/runtests.js --run-duk --cmd-duk=$(shell pwd)/duk.400 --num-threads 1 --log-file=/tmp/duk-vgtest.log --valgrind --verbose ecmascript-testcases/
apitest: libduktape400.so.1.0.0
node runtests/runtests.js --num-threads 1 --log-file=/tmp/duk-api-test.log api-testcases/
# FIXME: torturetest; torture + valgrind
.PHONY: doc
doc: $(patsubst %.txt,%.html,$(wildcard doc/*.txt))
doc/%.html: doc/%.txt
rst2html $< $@
# Source distributable for end users
dist:
sh make_dist.sh
dist-src: dist
rm -rf duktape-$(VERSION)
rm -rf duktape-$(VERSION).tar*
mkdir duktape-$(VERSION)
cp -r dist/* duktape-$(VERSION)/
tar cvfj duktape-$(VERSION).tar.bz2 duktape-$(VERSION)/
tar cvf duktape-$(VERSION).tar duktape-$(VERSION)/
xz -z -e -9 duktape-$(VERSION).tar
mkisofs -o duktape-$(VERSION).iso duktape-$(VERSION).tar.bz2
# Maintenance distributable
maint:
sh make_maint.sh
dist-maint: maint
rm -rf duktape-maint-$(VERSION)
rm -rf duktape-maint-$(VERSION).tar*
mkdir duktape-maint-$(VERSION)
cp -r maint/* duktape-maint-$(VERSION)/
tar cvfj duktape-maint-$(VERSION).tar.bz2 duktape-maint-$(VERSION)/
tar cvf duktape-maint-$(VERSION).tar duktape-maint-$(VERSION)/
xz -z -e -9 duktape-maint-$(VERSION).tar
mkisofs -o duktape-maint-$(VERSION).iso duktape-maint-$(VERSION).tar.bz2
# Website
web:
rm -rf web
mkdir web
cd website/; python buildsite.py ../web/
-@rm -rf /tmp/web/
cp -r web /tmp/ # FIXME
dist-web: web
rm -rf duktape-web-$(VERSION)
rm -rf duktape-web-$(VERSION).tar*
mkdir duktape-web-$(VERSION)
cp -r web/* duktape-web-$(VERSION)/
tar cvf duktape-web-$(VERSION).tar duktape-web-$(VERSION)/
xz -z -e -9 duktape-web-$(VERSION).tar