diff --git a/common.h b/common.h index 3be975f..fe70434 100644 --- a/common.h +++ b/common.h @@ -32,11 +32,16 @@ //#include #include #include + +#if !defined(NO_LIBEV_EMBED) #include +#else +#include "ev.h" +#endif #if defined(__MINGW32__) #include -#include +#include typedef int socklen_t; #else #include diff --git a/connection.cpp b/connection.cpp index 8ad4b9a..294cabc 100644 --- a/connection.cpp +++ b/connection.cpp @@ -22,7 +22,7 @@ void server_clear_function(u64_t u64)//used in conv_manager in server mode.for s address_t &addr=fd_manager.get_info(fd64).addr;// assert(conn_manager.exist(addr));// - ev_loop *loop =conn_manager.find_insert(addr).loop; // overkill ? should we just use ev_default_loop(0)? + struct ev_loop *loop =conn_manager.find_insert(addr).loop; // overkill ? should we just use ev_default_loop(0)? ev_io_stop(loop,&watcher); diff --git a/connection.h b/connection.h index 9846a9f..91a391f 100644 --- a/connection.h +++ b/connection.h @@ -295,7 +295,7 @@ struct conn_info_t:not_copy_able_t //stores info for a raw connection.for cl u64_t last_active_time; stat_t stat; - ev_loop* loop=0; + struct ev_loop* loop=0; int local_listen_fd; int remote_fd; //only used for client diff --git a/makefile b/makefile index 7d1f50d..38d429f 100755 --- a/makefile +++ b/makefile @@ -1,40 +1,63 @@ cc_cross=/home/wangyu/Desktop/arm-2014.05/bin/arm-none-linux-gnueabi-g++ cc_local=g++ -#cc_mips34kc=/toolchains/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++ cc_mips24kc_be=/toolchains/lede-sdk-17.01.2-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-g++ cc_mips24kc_le=/toolchains/lede-sdk-17.01.2-ramips-mt7621_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin/mipsel-openwrt-linux-musl-g++ -#cc_arm= /toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -march=armv6 -marm cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++ +cc_mingw_cross=i686-w64-mingw32-g++-posix +cc_mac_cross=o64-clang++ -stdlib=libc++ -std=c++11 #cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ + FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers ${OPT} -SOURCES=main.cpp log.cpp common.cpp lib/fec.cpp lib/rs.cpp packet.cpp delay_manager.cpp fd_manager.cpp connection.cpp fec_manager.cpp misc.cpp tunnel_client.cpp tunnel_server.cpp my_ev.cpp -isystem libev +SOURCES0=main.cpp log.cpp common.cpp lib/fec.cpp lib/rs.cpp packet.cpp delay_manager.cpp fd_manager.cpp connection.cpp fec_manager.cpp misc.cpp tunnel_client.cpp tunnel_server.cpp +SOURCES=${SOURCES0} my_ev.cpp -isystem libev NAME=speederv2 + TARGETS=amd64 arm mips24kc_be x86 mips24kc_le -TAR=${NAME}_binaries.tar.gz `echo ${TARGETS}|sed -r 's/([^ ]+)/speederv2_\1/g'` version.txt +TAR=${NAME}_binaries.tar.gz `echo ${TARGETS}|sed -r 's/([^ ]+)/${NAME}_\1/g'` version.txt +# targets for nativei (non-cross) compile all:git_version rm -f ${NAME} - ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O3 + ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O2 freebsd:git_version rm -f ${NAME} - ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O3 - -cygwin:git_version - rm -f ${NAME} - ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O3 -D_GNU_SOURCE + ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O2 mingw:git_version rm -f ${NAME} ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -ggdb -static -O2 -lws2_32 +mingw_wepoll:git_version #to compile you need a pacthed version of libev with wepoll backend + rm -f ${NAME} + ${cc_local} -o ${NAME} -I. ${SOURCES0} ${FLAGS} -ggdb -static -O2 -DNO_LIBEV_EMBED -D_WIN32 -lev -lws2_32 + mac:git_version rm -f ${NAME} - ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -ggdb -O3 + ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -ggdb -O2 +cygwin:git_version + rm -f ${NAME} + ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb -static -O2 -D_GNU_SOURCE + +#targes for general cross compile + +cross:git_version + ${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -O2 + +cross2:git_version + ${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -lgcc_eh -O2 + +cross3:git_version + ${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -O2 + +#targets only for debug purpose +fast: git_version + rm -f ${NAME} + ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -ggdb debug: git_version rm -f ${NAME} ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -Wformat-nonliteral -D MY_DEBUG @@ -42,45 +65,47 @@ debug2: git_version rm -f ${NAME} ${cc_local} -o ${NAME} -I. ${SOURCES} ${FLAGS} -lrt -Wformat-nonliteral -ggdb -mips24kc_be: git_version - ${cc_mips24kc_be} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O3 +#targets only for cross compile windows targets on linux -mips24kc_be_debug: git_version - ${cc_mips24kc_be} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -ggdb +mingw_cross:git_version #to build this and the below one you need 'mingw-w64' installed (the cross compile version on linux) + rm -f ${NAME} + ${cc_mingw_cross} -o ${NAME}.exe -I. ${SOURCES} ${FLAGS} -ggdb -static -O2 -lws2_32 + +mingw_cross_wepoll:git_version #to compile you need a pacthed version of libev with wepoll backend installed + rm -f ${NAME} + ${cc_mingw_cross} -o ${NAME}_wepoll.exe -I. ${SOURCES0} ${FLAGS} -ggdb -static -O2 -DNO_LIBEV_EMBED -D_WIN32 -lev -lws2_32 + +#targets only for cross compile macos targets on linux + +mac_cross:git_version #need to install 'osxcross' first. + rm -f ${NAME} + ${cc_mac_cross} -o ${NAME}_mac -I. ${SOURCES} ${FLAGS} -ggdb -O2 + +#targets only for 'make release' + +mips24kc_be: git_version + ${cc_mips24kc_be} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O2 mips24kc_le: git_version - ${cc_mips24kc_le} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O3 + ${cc_mips24kc_le} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O2 amd64:git_version - ${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O3 -amd64_debug:git_version - ${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -ggdb -x86:git_version - ${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O3 -m32 + ${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O2 + +x86:git_version #to build this you need 'g++-multilib' installed + ${cc_local} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O2 -m32 arm:git_version - ${cc_arm} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O3 + ${cc_arm} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -O2 -ggdb -arm_debug:git_version - ${cc_arm} -o ${NAME}_$@ -I. ${SOURCES} ${FLAGS} -lrt -static -ggdb -cross:git_version - ${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -O3 - -cross2:git_version - ${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -lgcc_eh -O3 - -cross3:git_version - ${cc_cross} -o ${NAME}_cross -I. ${SOURCES} ${FLAGS} -lrt -static -O3 - -release: ${TARGETS} +release: ${TARGETS} cp git_version.h version.txt tar -zcvf ${TAR} clean: rm -f ${TAR} - rm -f speeder speeder_cross + rm -f ${NAME} ${NAME}_cross ${NAME}.exe ${NAME}_wepoll.exe ${NAME}_mac rm -f git_version.h git_version: - echo "const char * const gitversion = \"$(shell git rev-parse HEAD)\";" > git_version.h - + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > git_version.h