From 1df3dd1f44d1128403fe39a8da7aaca8379022e7 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Mon, 21 Sep 2015 00:39:44 +0200 Subject: [PATCH] Every likes shared objects ... and I can use it from Rust --- Makefile | 18 +++++++++--------- include/twinklsocket.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 97475a4..eb19ed8 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,13 @@ -TARGET = twinkl-client -SRC = main.c twinklsocket.c -HEADERS = include/twinklsocket.h +HEADERS = include/twinklsocket.h +HEADERS += twinkl/include/twinkl.h twinkl/include/config.h twinkl/include/message.h OBJDIR = bin CC = clang -CFLAGS = -Wall -O2 -I include -I twinkl/include -LDFLAGS = - -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) +CFLAGS = -fPIC -Wall -O2 -I include -I twinkl/include +LDFLAGS = -all : start $(OBJDIR)/$(TARGET) +all : start $(OBJDIR)/twinkl-client @echo ":: Done !" start : @@ -25,7 +22,10 @@ $(OBJDIR)/%.o : %.c Makefile $(HEADERS) mkdir -p $$(dirname $@) $(CC) $(CFLAGS) -c $< -o $@ -$(OBJDIR)/$(TARGET) : $(OBJ) +$(OBJDIR)/twinklsocket.so : $(OBJDIR)/twinklsocket.o + $(CC) $+ -shared $(LDFLAGS) -o $@ + +$(OBJDIR)/twinkl-client : $(OBJDIR)/main.o $(OBJDIR)/twinklsocket.so $(CC) $+ $(LDFLAGS) -o $@ clean : diff --git a/include/twinklsocket.h b/include/twinklsocket.h index 831c5dc..3dcfadc 100644 --- a/include/twinklsocket.h +++ b/include/twinklsocket.h @@ -3,10 +3,10 @@ #include "message.h" -int twinklsocket_open(const char *host, const char *port); +extern int twinklsocket_open(const char *host, const char *port); -void twinklsocket_send(int sockfd, const struct twinkl_message *message); +extern void twinklsocket_send(int sockfd, const struct twinkl_message *message); -void twinklsocket_close(int sockfd); +extern void twinklsocket_close(int sockfd); #endif