From 2af94823e38ffb30b37375d9ef12f813c9308986 Mon Sep 17 00:00:00 2001 From: wangyu Date: Sun, 13 Aug 2017 02:14:50 +0800 Subject: [PATCH] better makefile --- main.cpp | 4 ++-- makefile | 54 ++++++++++++++++++++++++++++++----------------------- network.cpp | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/main.cpp b/main.cpp index b2d21d7..427299e 100755 --- a/main.cpp +++ b/main.cpp @@ -1155,7 +1155,7 @@ int client_on_timer(conn_info_t &conn_info) //for client { conn_info.state.client_current_state=client_idle; conn_info.my_id=get_true_random_number_nz(); - mylog(log_info,"state back to client_idle from client_ready bc of recv-direction timeout\n"); + mylog(log_info,"state back to client_idle from client_ready bc of server-->client direction timeout\n"); return 0; } @@ -1168,7 +1168,7 @@ int client_on_timer(conn_info_t &conn_info) //for client { conn_info.state.client_current_state=client_idle; conn_info.my_id=get_true_random_number_nz(); - mylog(log_info,"state back to client_idle from client_ready bc of send-direction timeout\n"); + mylog(log_info,"state back to client_idle from client_ready bc of client-->server direction timeout\n"); } mylog(log_debug,"heartbeat sent <%x,%x>\n",conn_info.oppsite_id,conn_info.my_id); diff --git a/makefile b/makefile index 1b868ef..ecab5a5 100755 --- a/makefile +++ b/makefile @@ -1,29 +1,37 @@ cc_cross=/home/wangyu/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++ -FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -FLAGS2= -O3 +cc_local=g++ +cc_ar71xx=/home/wangyu/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_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 +SOURCES=main.cpp lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp +TAR=udp2raw_binaries.tar.gz udp2raw_amd64 udp2raw_x86 udp2raw_ar71xx udp2raw_bcm2708 + all: - sudo killall udp2raw||true - sleep 0.2 - g++ main.cpp -o udp2raw -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2} -# ${ccmips} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2} + rm -f udp2raw + ${cc_local} -o udp2raw -I. ${SOURCES} ${FLAGS} -lrt -static -O3 fast: - sudo killall udp2raw||true - sleep 0.2 - g++ main.cpp -o udp2raw -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} - - + rm -f udp2raw + ${cc_local} -o udp2raw -I. ${SOURCES} ${FLAGS} -lrt debug: - g++ main.cpp -o udp2raw -static -ggdb -I. -Ilib lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} -Wformat-nonliteral -D MY_DEBUG -cross: - ${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2} -cross2: - ${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} -static -lgcc_eh -O3 -cross3: - ${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} -static -lgcc_eh + rm -f udp2raw + ${cc_local} -o udp2raw -I. ${SOURCES} ${FLAGS} -lrt -Wformat-nonliteral -D MY_DEBUG -release: - g++ main.cpp -o udp2raw_amd64 -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2} - g++ main.cpp -o udp2raw_x86 -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2} -m32 - ${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} -static -lgcc_eh -O3 - tar -zcvf udp2raw_binaries.tar.gz udp2raw_amd64 udp2raw_x86 udp2raw_ar71xx +ar71xx: + ${cc_ar71xx} -o udp2raw_ar71xx -I. ${SOURCES} ${FLAGS} -lrt -lgcc_eh -static -O3 +bcm2708: + ${cc_bcm2708} -o udp2raw_bcm2708 -I. ${SOURCES} ${FLAGS} -lrt -static -O3 + +cross: + ${cc_cross} -o udp2raw_cross -I. ${SOURCES} ${FLAGS} -lrt -static -lgcc_eh -O3 + +cross2: + ${cc_cross} -o udp2raw_cross -I. ${SOURCES} ${FLAGS} -lrt -O3 + +release: ar71xx bcm2708 + ${cc_local} -o udp2raw_amd64 -I. ${SOURCES} ${FLAGS} -lrt -static -O3 + ${cc_local} -o udp2raw_x86 -I. ${SOURCES} ${FLAGS} -lrt -m32 -static -O3 + tar -zcvf ${TAR} + +clean: + rm -f ${TAR} diff --git a/network.cpp b/network.cpp index be84833..189d249 100644 --- a/network.cpp +++ b/network.cpp @@ -987,7 +987,7 @@ int recv_raw_udp(raw_info_t &raw_info, char *&payload, int &payloadlen) } udphdr *udph=(struct udphdr*)ip_payload; - if(ntohs(udph->len)!=ip_payloadlen) + if(int(ntohs(udph->len))!=ip_payloadlen) { mylog(log_debug,"udp length error %d %d \n",ntohs(udph->len),ip_payloadlen);