Upload packaging folder
[platform/upstream/iotjs.git] / targets / nuttx-stm32f4 / app / Makefile
1 # Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2 #
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
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 ############################################################################
16 #   Copyright (C) 2009, 2011-2013 Gregory Nutt. All rights reserved.
17 #   Author: Gregory Nutt <gnutt@nuttx.org>
18 #
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions
21 # are met:
22 #
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
28 #    distribution.
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.
32 #
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.
45 #
46 ############################################################################
47
48 # TODO, this makefile should run make under the app dirs, instead of
49 # sourcing the Make.defs!
50
51 -include $(TOPDIR)/.config
52 -include $(TOPDIR)/Make.defs
53 include $(APPDIR)/Make.defs
54
55
56 CONFIG_IOTJS_PRIORITY ?= SCHED_PRIORITY_DEFAULT
57 CONFIG_IOTJS_STACKSIZE ?= 16384
58 # NSH sysinfo command
59
60 APPNAME = iotjs
61 IOTJS_ROOT_DIR = ../../../iotjs
62 PRIORITY = $(CONFIG_IOTJS_PRIORITY)
63 STACKSIZE = $(CONFIG_IOTJS_STACKSIZE)
64 HEAPSIZE = $(CONFIG_IOTJS_HEAPSIZE)
65
66 ASRCS =
67 CSRCS =
68 CXXSRCS =
69 MAINSRC = iotjs_main.cxx
70 LIBS = libhttpparser.a libiotjs.a libjerry-core.a libtuv.a libjerry-libm.a libjerry-libc.a
71
72 AOBJS = $(ASRCS:.S=$(OBJEXT))
73 COBJS = $(CSRCS:.c=$(OBJEXT))
74 CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
75 MAINOBJ = $(MAINSRC:.cxx=$(OBJEXT))
76
77 SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
78 OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
79
80 ifeq ($(R),1)
81   BUILD_TYPE = release
82 else
83   BUILD_TYPE = debug
84 endif
85
86 ifneq ($(CONFIG_BUILD_KERNEL),y)
87   OBJS += $(MAINOBJ)
88 endif
89
90 ifeq ($(CONFIG_WINDOWS_NATIVE),y)
91   BIN = ..\..\libapps$(LIBEXT)
92 else
93 ifeq ($(WINTOOL),y)
94   BIN = ..\\..\\libapps$(LIBEXT)
95 else
96   BIN = ../../libapps$(LIBEXT)
97 endif
98 endif
99
100 ifeq ($(WINTOOL),y)
101   INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
102 else
103   INSTALL_DIR = $(BIN_DIR)
104 endif
105
106 CONFIG_XYZ_PROGNAME ?= iotjs$(EXEEXT)
107 PROGNAME = $(CONFIG_XYZ_PROGNAME)
108
109 ROOTDEPPATH = --dep-path .
110
111 # Common build
112
113 VPATH =
114
115 all: .built
116 .PHONY: context depend clean distclean
117
118 chkcxx:
119 ifneq ($(CONFIG_HAVE_CXX),y)
120   @echo ""
121   @echo "In order to use this example, you toolchain must support must"
122   @echo ""
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."
126   @echo ""
127   @exit 1
128 endif
129
130
131 $(AOBJS): %$(OBJEXT): %.S
132         $(call ASSEMBLE, $<, $@)
133
134 $(COBJS): %$(OBJEXT): %.c
135         $(call COMPILE, $<, $@)
136
137 $(CXXOBJS) $(MAINOBJ): %$(OBJEXT): %.cxx
138         $(call COMPILEXX, $<, $@)
139
140 copylibs :
141         cp $(IOTJS_ROOT_DIR)/build/arm-nuttx/$(BUILD_TYPE)/lib/lib*.a .
142
143 $(LIBS) : copylibs
144         $(firstword $(AR)) x $@
145
146 .built: chkcxx $(LIBS) $(OBJS)
147         $(eval OBJS += $(shell find . -name "*.obj"))
148         $(call ARCHIVE, $(BIN), $(OBJS))
149         $(Q) touch .built
150
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)
156
157 install: $(BIN_DIR)$(DELIM)$(PROGNAME)
158
159 else
160 install:
161
162 endif
163
164 # Register application
165
166 ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
167 $(BUILTIN_REGISTRY)$(DELIM)iotjs.bdat: $(DEPCONFIG) Makefile
168         $(call REGISTER,"iotjs",$(PRIORITY),$(STACKSIZE),iotjs_main)
169
170 context: $(BUILTIN_REGISTRY)$(DELIM)iotjs.bdat
171 else
172 context:
173 endif
174
175 # Create dependencies
176
177 .depend: Makefile $(SRCS)
178         $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep
179         $(Q) touch $@
180
181 depend: .depend
182
183 clean:
184         $(eval OBJS += $(shell find . -name "*.obj"))
185         $(call DELFILE, $(OBJS))
186         $(call DELFILE, .built)
187         $(call CLEAN)
188
189 distclean: clean
190         $(call DELFILE, Make.dep)
191         $(call DELFILE, .depend)
192
193 -include Make.dep
194 .PHONY: preconfig
195 preconfig: