From 704714a6ca0eeb9654a1c0acb6305bb98e1d0b44 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Mon, 27 May 2013 09:26:18 +0200 Subject: [PATCH] Preparing for use of dynamic library (currently disabled by referring to liblabcomm.a in liblabcomm.so). --- lib/c/Makefile | 23 ++++++++++++++++------- lib/c/labcomm_private.h | 6 ++++++ lib/c/liblabcomm.so | 2 ++ 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 lib/c/liblabcomm.so diff --git a/lib/c/Makefile b/lib/c/Makefile index 9608548..4dcf336 100644 --- a/lib/c/Makefile +++ b/lib/c/Makefile @@ -1,12 +1,15 @@ ## Macros -# Use LLVM clang if it's found. -CC = $(shell hash clang 2>/dev/null && echo clang || echo gcc) -CFLAGS = -g -Wall -Werror -O3 -I. -Itest -DLABCOMM_ENCODER_LINEAR_SEARCH -LDFLAGS = -L. -LDLIBS_TEST = -Tlabcomm.linkscript -lcunit -llabcomm +CC=gcc +CFLAGS=-g -Wall -Werror -O3 -I. -Itest -DLABCOMM_ENCODER_LINEAR_SEARCH +LDFLAGS=-L. +#LDLIBS_TEST=-Tlabcomm.linkscript -lcunit -llabcomm +LDLIBS_TEST=-lcunit -llabcomm + +OBJS= labcomm.o \ + labcomm_dynamic_buffer_writer.o labcomm_fd_reader.o labcomm_fd_writer.o \ + labcomm_pthread_mutex_lock.o -OBJS= labcomm.o labcomm_dynamic_buffer_writer.o labcomm_fd_reader.o labcomm_fd_writer.o #FIXME: labcomm_mem_reader.o labcomm_mem_writer.o LABCOMM_JAR=../../compiler/labComm.jar LABCOMM=java -jar $(LABCOMM_JAR) @@ -35,11 +38,13 @@ endif .PHONY: all run-test clean distclean -all: liblabcomm.a +all: liblabcomm.a liblabcomm.so.1 liblabcomm.a: $(OBJS) ar -r liblabcomm.a $^ +liblabcomm.so.1: $(OBJS:%.o=%.pic.o) + gcc -shared -Wl,-soname,$@ -o $@ $^ -lc labcomm.o : labcomm.c labcomm.h labcomm_private.h @@ -85,6 +90,9 @@ $(LABCOMM_JAR): cd $(shell dirname $(LABCOMM_JAR)); ant jar @echo "======End building LabComm compiler======" +%.pic.o: %.c + $(CC) -fPIC $(CFLAGS) -c -o $@ $< + %.o: %.c %.h clean: @@ -98,6 +106,7 @@ clean: $(RM) $(TEST_DIR)/test_labcomm distclean: clean + $(RM) liblabcomm.so.1 $(RM) liblabcomm.a # Extra dependencies diff --git a/lib/c/labcomm_private.h b/lib/c/labcomm_private.h index b6af148..60c0ce2 100644 --- a/lib/c/labcomm_private.h +++ b/lib/c/labcomm_private.h @@ -44,6 +44,12 @@ #define LABCOMM_DECLARE_SIGNATURE(name) \ struct labcomm_signature name __attribute__((section("labcomm"))) +/* + * Semi private lock declarations + */ +struct labcomm_lock { +}; + /* * Semi private decoder declarations */ diff --git a/lib/c/liblabcomm.so b/lib/c/liblabcomm.so new file mode 100644 index 0000000..3f4a85c --- /dev/null +++ b/lib/c/liblabcomm.so @@ -0,0 +1,2 @@ +/*INPUT(liblabcomm.so.1 -ltinfo)*/ +INPUT(liblabcomm.a) -- GitLab