1 # Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 ############################################################################
16 # Copyright (C) 2009, 2011-2013 Gregory Nutt. All rights reserved.
17 # Author: Gregory Nutt <gnutt@nuttx.org>
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions
23 # 1. Redistributions of source code must retain the above copyright
24 # notice, this list of conditions and the following disclaimer.
25 # 2. Redistributions in binary form must reproduce the above copyright
26 # notice, this list of conditions and the following disclaimer in
27 # the documentation and/or other materials provided with the
29 # 3. Neither the name NuttX nor the names of its contributors may be
30 # used to endorse or promote products derived from this software
31 # without specific prior written permission.
33 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
36 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
39 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
40 # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
41 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
43 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44 # POSSIBILITY OF SUCH DAMAGE.
46 ############################################################################
48 # TODO, this makefile should run make under the app dirs, instead of
49 # sourcing the Make.defs!
51 -include $(TOPDIR)/.config
52 -include $(TOPDIR)/Make.defs
53 include $(APPDIR)/Make.defs
56 CONFIG_IOTJS_PRIORITY ?= SCHED_PRIORITY_DEFAULT
57 CONFIG_IOTJS_STACKSIZE ?= 16384
61 IOTJS_ROOT_DIR = ../../../iotjs
62 PRIORITY = $(CONFIG_IOTJS_PRIORITY)
63 STACKSIZE = $(CONFIG_IOTJS_STACKSIZE)
64 HEAPSIZE = $(CONFIG_IOTJS_HEAPSIZE)
69 MAINSRC = iotjs_main.cxx
70 LIBS = libhttpparser.a libiotjs.a libjerry-core.a libtuv.a libjerry-libm.a libjerry-libc.a
72 AOBJS = $(ASRCS:.S=$(OBJEXT))
73 COBJS = $(CSRCS:.c=$(OBJEXT))
74 CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
75 MAINOBJ = $(MAINSRC:.cxx=$(OBJEXT))
77 SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
78 OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
86 ifneq ($(CONFIG_BUILD_KERNEL),y)
90 ifeq ($(CONFIG_WINDOWS_NATIVE),y)
91 BIN = ..\..\libapps$(LIBEXT)
94 BIN = ..\\..\\libapps$(LIBEXT)
96 BIN = ../../libapps$(LIBEXT)
101 INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
103 INSTALL_DIR = $(BIN_DIR)
106 CONFIG_XYZ_PROGNAME ?= iotjs$(EXEEXT)
107 PROGNAME = $(CONFIG_XYZ_PROGNAME)
109 ROOTDEPPATH = --dep-path .
116 .PHONY: context depend clean distclean
119 ifneq ($(CONFIG_HAVE_CXX),y)
121 @echo "In order to use this example, you toolchain must support must"
123 @echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
124 @echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
125 @echo " of the configuration that you are using."
131 $(AOBJS): %$(OBJEXT): %.S
132 $(call ASSEMBLE, $<, $@)
134 $(COBJS): %$(OBJEXT): %.c
135 $(call COMPILE, $<, $@)
137 $(CXXOBJS) $(MAINOBJ): %$(OBJEXT): %.cxx
138 $(call COMPILEXX, $<, $@)
141 cp $(IOTJS_ROOT_DIR)/build/arm-nuttx/$(BUILD_TYPE)/lib/lib*.a .
144 $(firstword $(AR)) x $@
146 .built: chkcxx $(LIBS) $(OBJS)
147 $(eval OBJS += $(shell find . -name "*.obj"))
148 $(call ARCHIVE, $(BIN), $(OBJS))
151 ifeq ($(CONFIG_BUILD_KERNEL),y)
152 $(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
153 @echo "LD: $(PROGNAME)"
154 $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
155 $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
157 install: $(BIN_DIR)$(DELIM)$(PROGNAME)
164 # Register application
166 ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
167 $(BUILTIN_REGISTRY)$(DELIM)iotjs.bdat: $(DEPCONFIG) Makefile
168 $(call REGISTER,"iotjs",$(PRIORITY),$(STACKSIZE),iotjs_main)
170 context: $(BUILTIN_REGISTRY)$(DELIM)iotjs.bdat
175 # Create dependencies
177 .depend: Makefile $(SRCS)
178 $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep
184 $(eval OBJS += $(shell find . -name "*.obj"))
185 $(call DELFILE, $(OBJS))
186 $(call DELFILE, .built)
190 $(call DELFILE, Make.dep)
191 $(call DELFILE, .depend)