diff --git a/.gitignore b/.gitignore index 6f94d98..139e1cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # Prerequisites -libjpeg -zlib +plugins build *._* *.d +*.deb .vscode # Object files *.o @@ -51,6 +51,23 @@ build *.cmd modules.order Module.symvers -Mkfile.old +Makefile.old dkms.con .DS_Store +.* +*.cache +Makefile +antd +compile +config.guess +depcomp +install-sh +missing +libtool +config.log +config.status +config.sub +configure +aclocal.m4 +ltmain.sh +Makefile.in \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 811b110..0000000 --- a/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -include ../../var.mk -PL_NAME=wvnc -PLUGINS=$(PL_NAME).$(EXT) -APP_DIR=$(BUILDIRD)/htdocs/ - -OBJS = $(PLUGINS_BASE)/plugin.o - -PLUGINSDEP = $(OBJS) \ - wvnc.o - -DEP = -WEB_BUILD_PATH = /home/mrsang/myws/antd-web-apps/apps/assets/scripts -ifeq ($(UNAME_S),Darwin) - DEP= -I/usr/local/opt/jpeg-turbo/include -L/usr/local/opt/jpeg-turbo/lib - WEB_BUILD_PATH= /Users/mrsang/Documents/workspace/antd-web-apps/apps/assets/scripts -endif - -PLUGINLIBS = libantd.$(EXT) -lvncclient -lpthread -lz -ljpeg# -lsqlite3 - -PCFLAGS=-W -Wall -g -D DEBUG $(PPF_FLAG) $(DEP) -D USE_JPEG -D USE_ZLIB - -main: $(PLUGINSDEP) $(PLUGINS) #lib - -%.o: %.c - $(CC) $(PCFLAGS) -fPIC $(INCFLAG) -c $< -o $@ - -%.$(EXT): - -ln -s $(PBUILDIRD)/libantd.$(EXT) . - $(CC) $(PCFLAGS) $(PLUGINSDEP) $(PLUGINLIBS) -shared -o $(PBUILDIRD)/$(basename $@).$(EXT) - - -clean: #libclean - -rm -f *.o *.$(EXT) $(PBUILDIRD)/$(PLUGINS) - -rm $(PLUGINS_BASE)/plugin.o - -libclean: - for file in lib/* ;do \ - if [ -d "$$file" ]; then \ - echo "Cleaning $$file" ;\ - make -C "$$file" clean; \ - fi \ - done - - - - -.PRECIOUS: %.o -.PHONY: lib clean -full: clean main - - - diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..d5df0b3 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,19 @@ +AUTOMAKE_OPTIONS = foreign + + + +# check for system +if LINUX + AM_CPPFLAGS = -Wl,--no-as-needed +else + AM_CPPFLAGS = -Wl,-undefined,dynamic_lookup +endif + + +AM_CPPFLAGS += -W -Wall -g -std=c99 -fPIC + +lib_LTLIBRARIES = wvnc.la +wvnc_la_LDFLAGS = -module -avoid-version -shared +wvnc_la_SOURCES = wvnc.c + +EXTRA_DIST = README.md \ No newline at end of file diff --git a/README.md b/README.md index 3a6b7a3..e310bcb 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,13 @@ An [Antd HTTP/HTTPS server's](https://github.com/lxsang/ant-http) plugin that ac To speed up the data transmission, **WVNC** uses **libjpeg** and **zlib** for data compression. ## Build from source -As **WVNC** is an **Antd's** plugin, it need to be built along with the server. This requires the following application/libraries to be pre installed: +As **WVNC** is an **Antd's** plugin, the server need to be pre-installed: ### build dep * git * make * build-essential -### server dependencies -* libssl-dev -* libsqlite3-dev ### Plugin Dependencies * Zlib @@ -27,11 +24,17 @@ As **WVNC** is an **Antd's** plugin, it need to be built along with the server. When all dependencies are installed, the build can be done with a few single command lines: ```bash -mkdir antd -cd antd -wget -O- https://get.bitdojo.dev/antd | bash -s "wvnc" +# replace x.x.x by a version number +wget -O- https://get.bitdojo.dev/antd_plugin | bash -s "wvnc-x.x.x" + +# or from the distribution tarball +tar xvzf wvnc-x.x.x.tar.gz +cd wvnc-x.x.x +./configure --prefix=/opt/www --enable-debug=yes +make +sudo make install + ``` -The script will ask for a place to put the binaries (should be an absolute path, otherwise the build will fail) and the default HTTP port for the server config. ## Run To run the Antd server with the **wvnc** plugin: @@ -44,3 +47,12 @@ Web applications can be put on **/path/to/your/build/htdocs**, the web socket to ws://your_host:your_port/wvnc ``` This websocket address can be used with my client side javascript library [**wvnc.js**](https://github.com/lxsang/wvnc.js) to provide web based VNC client + +### Generate distribution +```sh +libtoolize +aclocal +autoconf +automake --add-missing +make distcheck +``` \ No newline at end of file diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..ff28d02 --- /dev/null +++ b/configure.ac @@ -0,0 +1,125 @@ +# initialise autoconf and set up some basic information about the program we’re packaging +AC_INIT([wvnc], [0.2.5a], [xsang.le@gmail.com]) + +# We’re going to use automake for this project +# [subdir-objects] if needed +AM_INIT_AUTOMAKE() + +# dependencies +# C compiler +AC_PROG_CC +# libtool for linking +AC_PROG_LIBTOOL + +has_antd=no +# check for lib antd +AC_CHECK_HEADER([antd/plugin.h],[ + has_antd=yes + # check if the library exists +],[ + AC_MSG_ERROR([Unable to find antd, please install it first]) +]) +AC_CHECK_LIB([antd],[antd_send],[],[ + if test "$has_antd" = "yes"; then + AC_MSG_ERROR([Unable to find antd shared library, please install it first]) + fi +]) + + +# check for pthread +AC_CHECK_LIB([pthread], [pthread_create], [], [ + AC_MSG_ERROR([libpthread is not found])]) + +# check for dl +AC_CHECK_LIB([dl], [dlopen], [], [ + AC_MSG_ERROR([unable to find dlopen()]) +]) + +# check for libjpeg +use_jpeg=no +# check if libssl header exists +AC_CHECK_HEADER([jpeglib.h],[ + # check if the library exists + AC_DEFINE([USE_JPEG], [1],[Use jpeglib]) + use_jpeg=yes +], []) +AC_CHECK_LIB([jpeg],[jpeg_CreateCompress],[], [ + if test "$use_jpeg" = "yes"; then + AC_MSG_ERROR([Unable to find libjpeg shared library]) + fi +]) + +# check for zlib +use_zlib=no +# check if libssl header exists +AC_CHECK_HEADER([zlib.h],[ + # check if the library exists + AC_DEFINE([USE_ZLIB], [1],[Use zlib]) + use_zlib=yes +], []) +AC_CHECK_LIB([z],[deflate],[], [ + if test "$use_zlib" = "yes"; then + AC_MSG_ERROR([Unable to find libz shared library]) + fi +]) + + +# check for lib antd +AC_CHECK_HEADER([rfb/rfbclient.h],[ + has_vncclient=yes + # check if the library exists +],[ + AC_MSG_ERROR([Unable to find libvncclient, please install it first]) +]) +AC_CHECK_LIB([vncclient],[rfbClientGetClientData],[],[ + AC_MSG_ERROR([Unable to find libvncclient shared library, please install it first]) +]) + + +AC_DEFINE([_GNU_SOURCE], [1],[Use GNU source]) +# AC_CANONICAL_HOST is needed to access the 'host_os' variable + +# debug option +AC_ARG_ENABLE([debug], + [ --enable-debug Turn on debugging], + [case "${enableval}" in + yes) AC_DEFINE([DEBUG], [1],[Enable debug]) ;; + no) ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; + esac],[debug=false]) + +AC_CANONICAL_HOST +build_linux=no +build_windows=no +build_mac=no +# Detect the target system +case "${host_os}" in + linux*) + AC_DEFINE([LINUX], [1],[Linux system]) + build_linux=yes + ;; + darwin*) + build_mac=yes + AC_DEFINE([MACOS], [1],[MacOS system]) + ;; + *) + AC_MSG_ERROR(["OS $host_os is not supported"]) + ;; +esac +# case for window: +# cygwin*|mingw*) +# build_windows=yes +# ;; +# Pass the conditionals to automake +AM_CONDITIONAL([DB], [test "$use_db" = "yes"]) +AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"]) +AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"]) +AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"]) + +# find a file called Makefile.in, substitute placeholders +# like @PACKAGE_VERSION@ with values like 0.1.0a, +# and write the results to Makefile. +AC_CONFIG_FILES([Makefile]) + +# output the script: +AC_OUTPUT \ No newline at end of file diff --git a/dist/wvnc-0.2.5a.tar.gz b/dist/wvnc-0.2.5a.tar.gz new file mode 100644 index 0000000..83bd2cc Binary files /dev/null and b/dist/wvnc-0.2.5a.tar.gz differ diff --git a/wvnc.c b/wvnc.c index 5408db3..63cf55c 100644 --- a/wvnc.c +++ b/wvnc.c @@ -9,7 +9,7 @@ #ifdef USE_JPEG #include #endif -#include "plugin.h" +#include #define get_user_data(x) ((wvnc_user_data_t *)x) #define R_SHIFT(x) (0) #define G_SHIFT(x) ((x >= 24) ? 8 :)