4bb5617b097bede57e1d3ef34193c67f95e69cbe
[platform/upstream/iotjs.git] / targets / tizenrt-artik05x / app / iotjs / Makefile
1 ###########################################################################
2 #
3 # Copyright 2016 Samsung Electronics All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14 # either express or implied. See the License for the specific
15 # language governing permissions and limitations under the License.
16 #
17 ###########################################################################
18 ############################################################################
19 # apps/examples/iotjs/Makefile
20 #
21 #   Copyright (C) 2008, 2010-2013 Gregory Nutt. All rights reserved.
22 #   Author: Gregory Nutt <gnutt@nuttx.org>
23 #
24 # Redistribution and use in source and binary forms, with or without
25 # modification, are permitted provided that the following conditions
26 # are met:
27 #
28 # 1. Redistributions of source code must retain the above copyright
29 #    notice, this list of conditions and the following disclaimer.
30 # 2. Redistributions in binary form must reproduce the above copyright
31 #    notice, this list of conditions and the following disclaimer in
32 #    the documentation and/or other materials provided with the
33 #    distribution.
34 # 3. Neither the name NuttX nor the names of its contributors may be
35 #    used to endorse or promote products derived from this software
36 #    without specific prior written permission.
37 #
38 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45 # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 # POSSIBILITY OF SUCH DAMAGE.
50 #
51 ############################################################################
52
53 EXTRA_LIBPATHS += -L$(IOTJS_LIB_DIR)
54 EXTRA_LIBS += libhttpparser.a libiotjs.a libjerrycore.a libtuv.a libjerry-libm.a
55
56 LINKLIBS=$(EXTRA_LIBS)
57
58 -include $(TOPDIR)/.config
59 -include $(TOPDIR)/Make.defs
60 include $(APPDIR)/Make.defs
61
62
63 # IoT.js application
64 CONFIG_IOTJS_PRIORITY ?= SCHED_PRIORITY_DEFAULT
65 CONFIG_IOTJS_STACKSIZE ?= 16384
66 IOTJS_LIB_DIR ?= n
67
68 APPNAME = iotjs
69 PRIORITY = $(CONFIG_IOTJS_PRIORITY)
70 STACKSIZE = $(CONFIG_IOTJS_STACKSIZE)
71 HEAPSIZE = $(CONFIG_IOTJS_HEAPSIZE)
72
73 ASRCS =
74 CSRCS =
75 MAINSRC = iotjs_main.c
76
77 AOBJS = $(ASRCS:.S=$(OBJEXT))
78 COBJS = $(CSRCS:.c=$(OBJEXT))
79 MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
80
81 SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
82 OBJS = $(AOBJS) $(COBJS)
83
84 ifeq ($(R),1)
85   BUILD_TYPE = release
86 else
87   BUILD_TYPE = debug
88 endif
89
90 ifneq ($(CONFIG_BUILD_KERNEL),y)
91   OBJS += $(MAINOBJ)
92 endif
93
94 ifeq ($(CONFIG_WINDOWS_NATIVE),y)
95   BIN = ..\..\libapps$(LIBEXT)
96 else
97 ifeq ($(WINTOOL),y)
98   BIN = ..\\..\\libapps$(LIBEXT)
99 else
100   BIN = ../../libapps$(LIBEXT)
101 endif
102 endif
103
104 ifeq ($(WINTOOL),y)
105   INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
106 else
107   INSTALL_DIR = $(BIN_DIR)
108 endif
109
110 CONFIG_IOTJS_PROGNAME ?= iotjs$(EXEEXT)
111 PROGNAME = $(CONFIG_IOTJS_PROGNAME)
112
113 ROOTDEPPATH = --dep-path .
114
115 # Common build
116
117 VPATH =
118
119 all: .built
120 .PHONY: clean depend distclean check_iotjs
121
122 $(AOBJS): %$(OBJEXT): %.S
123         $(call ASSEMBLE, $<, $@)
124
125 $(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
126         $(call COMPILE, $<, $@)
127
128 .built: $(OBJS) check_iotjs
129         $(call ARCHIVE, $(BIN), $(OBJS))
130         @touch .built
131
132 ifeq ($(CONFIG_BUILD_KERNEL),y)
133 $(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) check_iotjs
134         $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
135         $(Q) $(NM) -u  $(INSTALL_DIR)$(DELIM)$(PROGNAME)
136
137 install: $(BIN_DIR)$(DELIM)$(PROGNAME)
138
139 else
140 install:
141
142 endif
143
144 check_iotjs:
145 ifeq ($(IOTJS_LIB_DIR),n)
146         @echo "ERROR: IOTJS_LIB_DIR not set! Aborting..."
147         @exit 1
148 endif
149         @echo IOTJS_LIB_DIR set!
150         @echo "$(LDLIBPATH), $(IOTJS_LIB_DIR) $(TOPDIR)"
151         @cp $(IOTJS_LIB_DIR)/lib* $(TOPDIR)/../build/output/libraries/
152         @cp $(IOTJS_LIB_DIR)/../deps/jerry/lib/libjerry-libm.a $(TOPDIR)/../build/output/libraries/
153
154 context:
155
156 .depend: Makefile $(SRCS)
157         @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
158         @touch $@
159
160 depend: .depend
161
162 clean:
163         $(call DELFILE, .built)
164         $(call CLEAN)
165
166 distclean: clean
167         $(call DELFILE, Make.dep)
168         $(call DELFILE, .depend)
169
170 -include Make.dep