Makefile 4.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
###########################################################################
#
# Copyright 2016 Samsung Electronics All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
#
###########################################################################

-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs

# Hello, World! built-in application info

APPNAME = stapp
FUNCNAME = $(APPNAME)_main
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 8192
THREADEXEC = TASH_EXECMD_ASYNC

# Hello, World! Example

IOTCON_BASE_DIR = $(APPDIR)/../external/iotivity-constrained/iotivity-constrained

CFLAGS += -I$(IOTCON_BASE_DIR)/
CFLAGS += -I$(IOTCON_BASE_DIR)/include
CFLAGS += -I$(IOTCON_BASE_DIR)/port/tizenrt
CFLAGS += -I$(IOTCON_BASE_DIR)/port/
CFLAGS += -I$(IOTCON_BASE_DIR)/security
CFLAGS += -I$(IOTCON_BASE_DIR)/service/easy-setup/enrollee
CFLAGS += -I$(IOTCON_BASE_DIR)/service/easy-setup/enrollee/include
CFLAGS += -I$(IOTCON_BASE_DIR)/service/easy-setup/enrollee/include/samsung
CFLAGS += -I$(IOTCON_BASE_DIR)/service/cloud-access/include
CFLAGS += -I$(IOTCON_BASE_DIR)/service/resource-directory/client/include
45
CFLAGS += -I$(IOTCON_BASE_DIR)/service/st-app-fw/include
46 47 48 49 50 51 52

CFLAGS += -D__TIZENRT__ -DOC_SECURITY -DOC_CLIENT -DOC_IPV4 -DOC_DEBUG -DOC_SERVER -DOC_DYNAMIC_ALLOCATION -DOC_PROCESS_CONF_NO_OC_PROCESS_NAMES=0 -DOC_PROCESS_CONF_STATS=0 -std=gnu99


ASRCS =
CSRCS =

53
MAINSRC = tizenrt/st_ref_app_tizenrt.c tizenrt/port_tinyara.c
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
ifeq ($(CONFIG_IOTLITE_ST_APP_FW),y)
	ST_DEVICE_DEF= ./json/st_device_def
	ST_JSON_FILE := $(wildcard ./json/*.json)
	ST_DEVICE_DEF_HEADER=./tizenrt/st_device_def.h
ifeq ($(CONFIG_IOTLITE_ARCH), x86_64)
	JSON_TO_CBOR=$(IOTCON_BASE_DIR)/tools/json/json2cbor
else
	JSON_TO_CBOR=$(IOTCON_BASE_DIR)/tools/json/json2cbor_32
endif
	HEADER_DIR +=-I./tizenrt/
endif

prep_st_app_fw_json_present:
ifneq ("$(wildcard $(ST_DEVICE_DEF_HEADER))","")
else
ifneq ("$(wildcard $(ST_JSON_FILE))", "")
else
	$(error please use proper json file in apps/st_app/json)
endif
ifneq ($(words $(ST_JSON_FILE)), 1)
	$(error please use 1 json file in apps/st_app/json)
endif
endif

prep_st_app_fw_create_device_def:
	$(info make new st_device_def file using $(ST_JSON_FILE))
	$(shell $(JSON_TO_CBOR) $(ST_JSON_FILE) > $(ST_DEVICE_DEF))
	$(shell xxd -i $(ST_DEVICE_DEF) > $(ST_DEVICE_DEF_HEADER))
	$(shell sed -i 's/_.*st_device_def/st_device_def/g' $(ST_DEVICE_DEF_HEADER))

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))

SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)

ifneq ($(CONFIG_BUILD_KERNEL),y)
  OBJS += $(MAINOBJ)
endif

ifeq ($(CONFIG_WINDOWS_NATIVE),y)
  BIN = ..\..\libapps$(LIBEXT)
else
ifeq ($(WINTOOL),y)
  BIN = ..\\..\\libapps$(LIBEXT)
else
  BIN = ../../libapps$(LIBEXT)
endif
endif

ifeq ($(WINTOOL),y)
  INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
else
  INSTALL_DIR = $(BIN_DIR)
endif

CONFIG_EXAMPLES_STAPP_PROGNAME ?= iotlite$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_STAPP_PROGNAME)

ROOTDEPPATH = --dep-path .

# Common build

VPATH =

all: .built
.PHONY: clean depend distclean

$(AOBJS): %$(OBJEXT): %.S
	$(call ASSEMBLE, $<, $@)

127
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c prep_st_app_fw_json_present prep_st_app_fw_create_device_def
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
	$(call COMPILE, $<, $@)

.built: $(OBJS)
	$(call ARCHIVE, $(BIN), $(OBJS))
	@touch .built

ifeq ($(CONFIG_BUILD_KERNEL),y)
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
	@echo "LD: $(PROGNAME)"
	$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
	$(Q) $(NM) -u  $(INSTALL_DIR)$(DELIM)$(PROGNAME)

install: $(BIN_DIR)$(DELIM)$(PROGNAME)

else
install:

endif

ifeq ($(CONFIG_BUILTIN_APPS)$(CONFIG_EXAMPLES_STAPP),yy)
$(BUILTIN_REGISTRY)$(DELIM)$(FUNCNAME).bdat: $(DEPCONFIG) Makefile
	$(Q) $(call REGISTER,$(APPNAME),$(FUNCNAME),$(THREADEXEC),$(PRIORITY),$(STACKSIZE))

context: $(BUILTIN_REGISTRY)$(DELIM)$(FUNCNAME).bdat

else
context:

endif

.depend: Makefile $(SRCS)
	@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
	@touch $@

depend: .depend

clean:
	$(call DELFILE, .built)
	$(call CLEAN)

distclean: clean
	$(call DELFILE, Make.dep)
	$(call DELFILE, .depend)

-include Make.dep
.PHONY: preconfig
preconfig: