-CFLAGS= -Wall -Werror -rdynamic -fPIC -c
-
+export CFLAGS= -Wall -Werror -rdynamic -fPIC -c
all:
- gcc $(CFLAGS) libwebsockets.c
- gcc $(CFLAGS) md5.c
- gcc libwebsockets.o md5.o --shared -o libwebsockets.so
-
- gcc $(CFLAGS) test-server.c
- gcc test-server.o ./libwebsockets.so -o test-server
- ./kernel-doc -text libwebsockets.c test-server.c > \
- libwebsockets-api-doc.txt
+ make -C lib
+ make -C test-server
+ ./scripts/kernel-doc -text \
+ ./lib/libwebsockets.c \
+ ./test-server/test-server.c > libwebsockets-api-doc.txt
clean:
- rm -f *.o *.so test-server
-
+ make -C lib clean
+ make -C test-server clean
+
+install:
+ make -C lib install
+ make -C test-server install
+
---------------------------------
$ make
-$ ./test-server
+$ sudo make install
+$ libwebsockets-test-server
should be enough to get a test server listening on port 7861.
http://127.0.0.1:7681
-It will fetch "test.html", and then run the script in there
-on the browser to open a websocket connection. Incrementing
-numbers should appear in the browser display.
+It will fetch "./test-server/test.html", and then run the
+script in there on the browser to open a websocket connection.
+Incrementing numbers should appear in the browser display.
test-server.c is all that is needed to use libwebsockets for
serving both the script html over http and websockets.
--- /dev/null
+export LDIR=$(shell if [ -z "gcc --print-search-dirs | grep libraries | sed s/\\//\\n/g | grep lib64 | grep 64 | head -n1" ] ; then echo lib; else echo lib64 ; fi )
+
+all:
+ gcc $(CFLAGS) libwebsockets.c
+ gcc $(CFLAGS) md5.c
+ gcc libwebsockets.o md5.o --shared -o libwebsockets.so
+
+clean:
+ rm -f *.o *.so
+
+install:
+ cp -rf libwebsockets.so $(DESTDIR)/usr/$(LDIR)
+ cp -rf libwebsockets.h $(DESTDIR)/usr/include
+
+
--- /dev/null
+all:
+ gcc $(CFLAGS) test-server.c
+ gcc test-server.o \
+ -L ../lib \
+ -lwebsockets \
+ -o libwebsockets-test-server
+
+clean:
+ rm -f *.o libwebsockets-test-server
+
+install:
+ cp -f libwebsockets-test-server $(DESTDIR)/usr/bin
+
+
#include <getopt.h>
#include <string.h>
-#include "libwebsockets.h"
+#include "../lib/libwebsockets.h"
/*
* libwebsocket Example server Copyright 2010 Andy Green <andy@warmcat.com>
function got_packet(msg){
// alert('got packet' + msg.data);
- document.write(msg.data + "\n");
+ document.body.textContent = msg.data + "\n";
}
</script>