refactor-into-dirs.patch
authorAndy Green <andy@warmcat.com>
Mon, 1 Nov 2010 09:12:17 +0000 (09:12 +0000)
committerAndy Green <andy@warmcat.com>
Mon, 1 Nov 2010 09:12:17 +0000 (09:12 +0000)
Signed-off-by: Andy Green <andy@warmcat.com>
Makefile
README-test-server
lib/Makefile [new file with mode: 0644]
lib/libwebsockets.c [moved from libwebsockets.c with 100% similarity]
lib/libwebsockets.h [moved from libwebsockets.h with 100% similarity]
lib/md5.c [moved from md5.c with 100% similarity]
scripts/kernel-doc [moved from kernel-doc with 100% similarity]
test-server/Makefile [new file with mode: 0644]
test-server/favicon.ico [moved from favicon.ico with 100% similarity]
test-server/test-server.c [moved from test-server.c with 99% similarity]
test-server/test.html [moved from test.html with 94% similarity]

index 84a6f90..bf67643 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,17 @@
-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
+
        
index abeb07e..bc9af54 100644 (file)
@@ -2,7 +2,8 @@ Using test-server as a quickstart
 ---------------------------------
 
 $ make
-$ ./test-server
+$ sudo make install
+$ libwebsockets-test-server
 
 should be enough to get a test server listening on port 7861.
 
@@ -10,9 +11,9 @@ If you point your browser (eg, Chrome) to
 
   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.
diff --git a/lib/Makefile b/lib/Makefile
new file mode 100644 (file)
index 0000000..be381c3
--- /dev/null
@@ -0,0 +1,15 @@
+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
+
+
similarity index 100%
rename from libwebsockets.c
rename to lib/libwebsockets.c
similarity index 100%
rename from libwebsockets.h
rename to lib/libwebsockets.h
diff --git a/md5.c b/lib/md5.c
similarity index 100%
rename from md5.c
rename to lib/md5.c
similarity index 100%
rename from kernel-doc
rename to scripts/kernel-doc
diff --git a/test-server/Makefile b/test-server/Makefile
new file mode 100644 (file)
index 0000000..61a6a98
--- /dev/null
@@ -0,0 +1,14 @@
+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
+
+
similarity index 100%
rename from favicon.ico
rename to test-server/favicon.ico
similarity index 99%
rename from test-server.c
rename to test-server/test-server.c
index a37aa12..2245a67 100644 (file)
@@ -4,7 +4,7 @@
 #include <getopt.h>
 #include <string.h>
 
-#include "libwebsockets.h"
+#include "../lib/libwebsockets.h"
 
 /*
  * libwebsocket Example server  Copyright 2010 Andy Green <andy@warmcat.com>
similarity index 94%
rename from test.html
rename to test-server/test.html
index 59ad43f..905a0c5 100644 (file)
--- a/test.html
@@ -30,7 +30,7 @@
 function got_packet(msg){
 
 //     alert('got packet' + msg.data);
-       document.write(msg.data + "\n");
+       document.body.textContent = msg.data + "\n";
        
 }  
 </script>