]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - Makefile
Compile our version of libwebsockets if not found in the system
[coffee/mt-apps.git] / Makefile
index 37068568d17fbac3824d3fadd07ac63792b7e7a7..7207748741b389af6dc4df7177f2059e84eb4a21 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
 OUTPUT_DIR    = build
 
-CFLAGS       = -Ilibwebsockets/include -Llibwebsockets/lib
 can_compile   = $(shell if echo '$(1)' | $(CC) $(CFLAGS) -c -xc - -o /dev/null >/dev/null 2>&1; then echo yes; fi)
 HAVE_RFID    := $(call can_compile,\#include <uFCoder.h>)
 
@@ -39,7 +38,23 @@ all: mtserver mtkeys mtaio
 clean:
        rm -rf $(OUTPUT_DIR)
 
+# Check LWS version and compile our own if not found
+ifeq ($(shell pkg-config libwebsockets = 2.2.1 || echo no),no)
+libwebsockets/CMakeLists.txt:
+       git submodupe update --init libwebsockets
+
+libwebsockets/CMakeCache.txt: libwebsockets/CMakeLists.txt
+       cd libwebsockets && cmake -DLWS_WITH_LIBEV=ON -DLWS_WITH_SHARED=OFF .
+
+libwebsockets/lib/libwebsockets.a: libwebsockets/CMakeCache.txt
+       cd libwebsockets && cmake --build .
+
+mt_server.c: libwebsockets/lib/libwebsockets.a
+
+CFLAGS       += -Ilibwebsockets/include -Llibwebsockets/lib -g -lz $(shell pkg-config --libs openssl)
+endif
+
 .SECONDEXPANSION:
-mt%: $$($$@_SRCS)
+mtserver mtkeys mtaio mtrfid: $$($$@_SRCS)
        mkdir -p $(OUTPUT_DIR)
        $(CC) $(CFLAGS) $($@_DEFS) -o $(OUTPUT_DIR)/$@ $^ $($@_LIBS)