1#
2# Copyright (c) 2015-2017 the Civetweb developers
3#
4# License http://opensource.org/licenses/mit-license.php MIT License
5#
6
7ifndef WITH_DUKTAPE
8  $(error WITH_DUKTAPE is not defined)
9endif
10
11# Duktape default version is 1.8.0 (108)
12WITH_DUKTAPE_VERSION ?= 108
13DUKTAPE_VERSION_KNOWN = 0
14
15# Select src and header according to the Duktape version
16ifeq ($(WITH_DUKTAPE_VERSION), 105)
17  $(info Duktape: Using version 1.5.2)
18  DUKTAPE_DIR = src/third_party/duktape-1.5.2/src
19  DUKTAPE_SHARED_LIB_FLAG = -lduktape1.5
20  DUKTAPE_CFLAGS = -DDUKTAPE_VERSION_MAKEFILE=105
21  DUKTAPE_VERSION_KNOWN = 1
22endif
23
24ifeq ($(WITH_DUKTAPE_VERSION), 108)
25  $(info Duktape: Using version 1.8.0)
26  DUKTAPE_DIR = src/third_party/duktape-1.8.0/src
27  DUKTAPE_SHARED_LIB_FLAG = -lduktape1.8
28  DUKTAPE_CFLAGS = -DDUKTAPE_VERSION_MAKEFILE=108
29  DUKTAPE_VERSION_KNOWN = 1
30endif
31
32ifeq ($(WITH_DUKTAPE_VERSION), 201)
33  $(info Duktape: Using version 2.1.1)
34  DUKTAPE_DIR = src/third_party/duktape-2.1.1/src
35  DUKTAPE_SHARED_LIB_FLAG = -lduktape2.1
36  DUKTAPE_CFLAGS = -DDUKTAPE_VERSION_MAKEFILE=201
37  DUKTAPE_VERSION_KNOWN = 1
38endif
39
40ifeq ($(WITH_DUKTAPE_VERSION), 202)
41  $(info Duktape: Using version 2.2.0)
42  DUKTAPE_DIR = src/third_party/duktape-2.2.0/src
43  DUKTAPE_SHARED_LIB_FLAG = -lduktape2.2
44  DUKTAPE_CFLAGS = -DDUKTAPE_VERSION_MAKEFILE=202
45  DUKTAPE_VERSION_KNOWN = 1
46endif
47
48ifneq ($(DUKTAPE_VERSION_KNOWN), 1)
49  $(error Duktape: Unknwon version - $(WITH_DUKTAPE_VERSION))
50endif
51
52
53# Add flags for all Duktape versions
54DUKTAPE_CFLAGS += -I$(DUKTAPE_DIR) -DUSE_DUKTAPE
55
56ifneq ($(TARGET_OS),WIN32)
57#  DUKTAPE_CFLAGS +=
58endif
59
60ifdef WITH_DUKTAPE_SHARED
61
62  DUKTAPE_SOURCE_FILES =
63
64  $(info Duktape: using dynamic linking)
65
66else
67
68  DUKTAPE_SOURCE_FILES = duktape.c
69
70ifeq ($(WITH_DUKTAPE_VERSION), 104)
71#    DUKTAPE_SOURCE_FILES += ... TODO ...
72endif
73
74  $(info Duktape: using static library)
75
76endif
77
78DUKTAPE_SOURCES = $(addprefix $(DUKTAPE_DIR)/, $(DUKTAPE_SOURCE_FILES))
79DUKTAPE_OBJECTS = $(DUKTAPE_SOURCES:.c=.o)
80
81OBJECTS += $(DUKTAPE_OBJECTS)
82CFLAGS += $(DUKTAPE_CFLAGS)
83SOURCE_DIRS = $(DUKTAPE_DIR)
84BUILD_DIRS += $(BUILD_DIR)/$(DUKTAPE_DIR)
85
86