From 7603e2decc2883dc07707f3b03c7a233fd1f90db Mon Sep 17 00:00:00 2001 From: overflowerror Date: Mon, 2 Jan 2017 23:01:06 +0100 Subject: [PATCH] we now generate a lib \o/ --- Makefile | 10 +++++++--- ws_utils.c | 1 + ws_utils.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 89b024f..7823d27 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,13 @@ CC = gcc DEFS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -CFLAGS = -Wall -Wextra -g -std=c99 -pedantic -DENDEBUG $(DEFS) +CFLAGS = -Wall -Wextra -g -std=c99 -pedantic -DENDEBUG $(DEFS) -fPIC LDFLAGS = $(DEFS) +LIBFLAGS = -shared $(DEFS) .PHONY: all clean -all: example +all: example libserwer.so %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< @@ -20,6 +21,9 @@ all: example example: example.o serwer.o ws_linear.o ws_utils.o help.o $(CC) $(LDFLAGS) -o $@ $^ +libserwer.so: serwer.o ws_linear.o ws_utils.o help.o + $(CC) $(LIBFLAGS) -o $@ $^ + example.o: example.c serwer.h help.h help.o: help.c help.h serwer.o: serwer.c serwer.h ws_types.h ws_modes.h ws_utils.h help.h @@ -27,4 +31,4 @@ ws_utils.o: ws_utils.c ws_utils.h ws_types.h ws_linear.o: ws_linear.c ws_modes.h ws_types.h serwer.h ws_utils.h clean: - rm -f *.o example + rm -f *.o example libserwer.so diff --git a/ws_utils.c b/ws_utils.c index 771496c..cb3b04f 100644 --- a/ws_utils.c +++ b/ws_utils.c @@ -3,6 +3,7 @@ #include #include #include +#include method_t ws_method(const char* string) { if (strcmp(string, "OPTIONS") == 0) diff --git a/ws_utils.h b/ws_utils.h index 41e4470..921abad 100644 --- a/ws_utils.h +++ b/ws_utils.h @@ -3,6 +3,8 @@ #include "ws_types.h" +#include + method_t ws_method(const char*); const char* ws_method_string(method_t); const char* ws_code_reason(int);