Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Commit

Permalink
linux:build: Add new client and server library
Browse files Browse the repository at this point in the history
Added client-server library for whom want to play both roles.

It's not re-using the already built objects to keep the libraries with
the minimum required symbols. The drawback of this is the build time
increasing.

Change-Id: Iecb87f27191a34110c88fdb8cd33db433eb611da
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17409
Reviewed-by: Kishen Maloor <kishen.maloor@intel.com>
Tested-by: Kishen Maloor <kishen.maloor@intel.com>
  • Loading branch information
ceolin authored and kmaloor committed Feb 24, 2017
1 parent 255ec6c commit c0d9b24
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ port/linux/client_block_linux
port/linux/server_block_linux
port/linux/libiotivity-constrained-client.*
port/linux/libiotivity-constrained-server.*
port/linux/libiotivity-constrained-client-server.*
port/linux/iotivity-constrained-server.pc
port/linux/iotivity-constrained-client.pc
port/linux/iotivity-constrained-client-server.pc
port/linux/obj/
port/zephyr/outdir/
port/contiki/*.a
Expand Down
24 changes: 22 additions & 2 deletions port/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CFLAGS=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestand
OBJ_COMMON=$(addprefix obj/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix obj/client/,$(notdir $(SRC:.c=.o)))
OBJ_SERVER=$(addprefix obj/server/,$(notdir $(SRC:.c=.o)))
OBJ_CLIENT_SERVER=$(addprefix obj/client_server/,$(notdir $(SRC:.c=.o)))
VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:
LIBS?= -lm -pthread -lrt

Expand All @@ -55,8 +56,10 @@ endif
SAMPLES = server client temp_sensor simpleserver simpleclient client_collections_linux \
server_collections_linux server_block_linux client_block_linux
CONSTRAINED_LIBS = libiotivity-constrained-server.a libiotivity-constrained-client.a \
libiotivity-constrained-server.so libiotivity-constrained-client.so
PC = iotivity-constrained-client.pc iotivity-constrained-server.pc
libiotivity-constrained-server.so libiotivity-constrained-client.so \
libiotivity-constrained-client-server.so libiotivity-constrained-client-server.a
PC = iotivity-constrained-client.pc iotivity-constrained-server.pc \
iotivity-constrained-client-server.pc

all: $(CONSTRAINED_LIBS) $(SAMPLES) $(PC)

Expand All @@ -74,6 +77,10 @@ obj/client/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT

obj/client_server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER

libiotivity-constrained-server.a: $(OBJ_COMMON) $(OBJ_SERVER)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_SERVER)

Expand All @@ -86,6 +93,12 @@ libiotivity-constrained-client.a: $(OBJ_COMMON) $(OBJ_CLIENT)
libiotivity-constrained-client.so: $(OBJ_COMMON) $(OBJ_CLIENT)
$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_CLIENT) $(LIBS)

libiotivity-constrained-client-server.a: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)

libiotivity-constrained-client-server.so: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_CLIENT_SERVER) $(LIBS)

server: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

Expand Down Expand Up @@ -127,6 +140,13 @@ iotivity-constrained-client.pc: iotivity-constrained-client.pc.in
-e 's,@libdir@,$(libdir),' \
-e 's,@includedir@,$(includedir),'

iotivity-constrained-client-server.pc: iotivity-constrained-client-server.pc.in
$(SED) > $@ < $< \
-e 's,@prefix@,$(prefix),' \
-e 's,@exec_prefix@,$(exec_prefix),' \
-e 's,@libdir@,$(libdir),' \
-e 's,@includedir@,$(includedir),'

clean:
rm -rf obj $(PC) $(CONSTRAINED_LIBS)

Expand Down
25 changes: 25 additions & 0 deletions port/linux/iotivity-constrained-client-server.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2017 Intel Corporation
#
# 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.

prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: iotivity-constrained-client-server
Description: Iotivity constrained client and server library
Version: 1.0
Libs.private: -lm -pthread
Cflags: -I${includedir}/iotivity-constrained -DOC_CLIENT -DOC_SERVER
Libs: -L${libdir} -liotivity-constrained-client-server

0 comments on commit c0d9b24

Please sign in to comment.