2017-08-18 19:42:29 +08:00
cc_cross = /home/wangyu/Desktop/arm-2014.05/bin/arm-none-linux-gnueabi-g++
cc_local = g++
2023-03-25 06:13:09 +00:00
cc_mips24kc_be = $( shell which g++ || /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 = $( shell which g++ || /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 = $( shell which c++ || /toolchains/lede-sdk-17.01.2-bcm53xx_gcc-5.4.0_musl-1.1.16_eabi.Linux-x86_64/staging_dir/toolchain-arm_cortex-a9_gcc-5.4.0_musl-1.1.16_eabi/bin/arm-openwrt-linux-c++)
2020-07-15 16:46:45 -04:00
cc_mingw_cross = i686-w64-mingw32-g++-posix
cc_mac_cross = o64-clang++ -stdlib= libc++
2023-03-25 06:13:09 +00:00
cc_x86 = $( shell which c++ || /toolchains/lede-sdk-17.01.2-x86-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-i386_pentium4_gcc-5.4.0_musl-1.1.16/bin/i486-openwrt-linux-c++)
cc_amd64 = $( shell which c++ || /toolchains/lede-sdk-17.01.2-x86-64_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/bin/x86_64-openwrt-linux-c++)
#cc_bcm2708=$(shell which g++ || /home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++)
2019-07-15 08:36:06 -04:00
2017-08-18 19:42:29 +08:00
2020-07-15 16:46:45 -04:00
FLAGS = -std= c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers ${ OPT }
COMMON = main.cpp lib/md5.cpp lib/pbkdf2-sha1.cpp lib/pbkdf2-sha256.cpp encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp client.cpp server.cpp -lpthread
SOURCES0 = $( COMMON) lib/aes_faster_c/aes.cpp lib/aes_faster_c/wrapper.cpp
SOURCES = ${ SOURCES0 } my_ev.cpp -isystem libev
SOURCES_AES_ACC = $( COMMON) $( wildcard lib/aes_acc/aes*.c) my_ev.cpp -isystem libev
PCAP = "-lpcap"
MP = "-DUDP2RAW_MP"
2017-08-18 19:42:29 +08:00
NAME = udp2raw
2020-07-15 16:46:45 -04:00
2017-09-10 00:09:18 -05:00
TARGETS = amd64 arm amd64_hw_aes arm_asm_aes mips24kc_be mips24kc_be_asm_aes x86 x86_asm_aes mips24kc_le mips24kc_le_asm_aes
2017-08-18 19:42:29 +08:00
2020-07-15 16:46:45 -04:00
TAR = ${ NAME } _binaries.tar.gz ` echo ${ TARGETS } | sed -r 's/([^ ]+)/${NAME}_\1/g' ` version.txt
TARGETS_MP = mingw_cross mingw_cross_wepoll mac_cross
export STAGING_DIR = /tmp/ #just for supress warning of staging_dir not define
# targets for nativei (non-cross) compile
2017-09-06 05:31:29 -05:00
all : git_version
2017-08-18 19:42:29 +08:00
rm -f ${ NAME }
2020-07-15 16:46:45 -04:00
${ cc_local } -o ${ NAME } -I. ${ SOURCES } ${ FLAGS } -lrt -ggdb -static -O2
#dynamic link
dynamic : git_version
2020-08-18 03:19:18 -04:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES } ${ FLAGS } -lrt -O2
2020-07-15 16:46:45 -04:00
#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
2017-09-06 05:31:29 -05:00
fast : git_version
2017-08-18 19:42:29 +08:00
rm -f ${ NAME }
2017-08-23 07:01:21 -05:00
${ cc_local } -o ${ NAME } -I. ${ SOURCES } ${ FLAGS } -lrt -ggdb
2017-09-06 05:31:29 -05:00
debug : git_version
2017-08-18 19:42:29 +08:00
rm -f ${ NAME }
2020-08-18 03:19:18 -04:00
${ cc_local } -o ${ NAME } -I. ${ SOURCES } ${ FLAGS } -lrt -Wformat-nonliteral -D MY_DEBUG -ggdb
2017-09-06 05:31:29 -05:00
debug2 : git_version
2017-09-22 14:36:35 -05:00
rm -f ${ NAME }
2020-07-26 19:07:17 +00:00
${ cc_local } -o ${ NAME } -I. ${ SOURCES } ${ FLAGS } -lrt -Wformat-nonliteral -ggdb -fsanitize= address
2017-09-22 11:20:44 -05:00
2020-07-15 16:46:45 -04:00
#targets only for 'make release'
2019-07-15 08:36:06 -04:00
2017-09-10 00:09:18 -05:00
mips24kc_be : git_version
2020-08-18 03:19:18 -04:00
${ cc_mips24kc_be } -o ${ NAME } _$@ -I. ${ SOURCES } ${ FLAGS } -lrt -lgcc_eh -static -O2
2017-09-10 00:09:18 -05:00
mips24kc_be_asm_aes : git_version
2020-08-18 03:19:18 -04:00
${ cc_mips24kc_be } -o ${ NAME } _$@ -I. ${ SOURCES_AES_ACC } ${ FLAGS } -lrt -lgcc_eh -static -O2 lib/aes_acc/asm/mips_be.S
2017-09-10 00:09:18 -05:00
mips24kc_le : git_version
2020-08-18 03:19:18 -04:00
${ cc_mips24kc_le } -o ${ NAME } _$@ -I. ${ SOURCES } ${ FLAGS } -lrt -lgcc_eh -static -O2
2017-09-10 00:09:18 -05:00
mips24kc_le_asm_aes : git_version
2020-08-18 03:19:18 -04:00
${ cc_mips24kc_le } -o ${ NAME } _$@ -I. ${ SOURCES_AES_ACC } ${ FLAGS } -lrt -lgcc_eh -static -O2 lib/aes_acc/asm/mips.S
2017-09-06 05:31:29 -05:00
amd64 : git_version
2020-08-18 03:19:18 -04:00
${ cc_amd64 } -o ${ NAME } _$@ -I. ${ SOURCES } ${ FLAGS } -lrt -static -O2 -lgcc_eh -ggdb
2017-09-06 05:31:29 -05:00
amd64_hw_aes : git_version
2020-08-18 03:19:18 -04:00
${ cc_amd64 } -o ${ NAME } _$@ -I. ${ SOURCES_AES_ACC } ${ FLAGS } -lrt -static -O2 lib/aes_acc/asm/x64.S -lgcc_eh -ggdb
2017-09-06 05:31:29 -05:00
x86 : git_version
2020-08-18 03:19:18 -04:00
${ cc_x86 } -o ${ NAME } _$@ -I. ${ SOURCES } ${ FLAGS } -lrt -static -O2 -lgcc_eh -ggdb
2017-09-06 05:31:29 -05:00
x86_asm_aes : git_version
2020-08-18 03:19:18 -04:00
${ cc_x86 } -o ${ NAME } _$@ -I. ${ SOURCES_AES_ACC } ${ FLAGS } -lrt -static -O2 lib/aes_acc/asm/x86.S -lgcc_eh -ggdb
2017-09-06 05:31:29 -05:00
arm : git_version
2020-08-18 03:19:18 -04:00
${ cc_arm } -o ${ NAME } _$@ -I. ${ SOURCES } ${ FLAGS } -lrt -static -O2 -lgcc_eh
2017-09-06 05:31:29 -05:00
arm_asm_aes : git_version
2020-08-18 03:19:18 -04:00
${ cc_arm } -o ${ NAME } _$@ -I. ${ SOURCES_AES_ACC } ${ FLAGS } -lrt -static -O2 lib/aes_acc/asm/arm.S -lgcc_eh
2017-08-18 19:57:37 +08:00
2020-07-15 16:46:45 -04:00
release : ${TARGETS }
cp git_version.h version.txt
tar -zcvf ${ TAR }
2017-08-18 19:42:29 +08:00
2020-07-15 16:46:45 -04:00
#targets for multi-platform version (native compile)
cygwin : git_version
2021-02-17 16:58:32 -05:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES } pcap_wrapper.cpp ${ FLAGS } -lrt -ggdb -static -O2 -D_GNU_SOURCE ${ MP }
2017-08-18 19:42:29 +08:00
2020-07-15 16:46:45 -04:00
mingw : git_version
2021-02-17 16:58:32 -05:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES } pcap_wrapper.cpp ${ FLAGS } -ggdb -static -O2 -lws2_32 ${ MP }
2017-08-18 19:42:29 +08:00
2020-07-15 16:46:45 -04:00
mingw_wepoll : git_version
2021-02-17 16:58:32 -05:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES0 } pcap_wrapper.cpp ${ FLAGS } -ggdb -static -O2 -DNO_LIBEV_EMBED -D_WIN32 -lev -lws2_32 ${ MP }
2020-07-15 16:46:45 -04:00
linux : git_version
2021-02-17 16:58:32 -05:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES } ${ PCAP } ${ FLAGS } -lrt -ggdb -static -O2 ${ MP }
2020-07-15 16:46:45 -04:00
freebsd : git_version
2021-02-17 16:58:32 -05:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES } ${ PCAP } ${ FLAGS } -lrt -ggdb -static -O2 ${ MP }
2020-07-15 16:46:45 -04:00
mac : git_version
2021-02-17 16:58:32 -05:00
${ cc_local } -o ${ NAME } _$@ -I. ${ SOURCES } ${ PCAP } ${ FLAGS } -ggdb -O2 ${ MP }
2020-07-15 16:46:45 -04:00
#targets for multi-platform version (cross compile)
mingw_cross : git_version
${ cc_mingw_cross } -o ${ NAME } _mp.exe -I. ${ SOURCES } pcap_wrapper.cpp ${ FLAGS } -ggdb -static -O2 -lws2_32 ${ MP }
mingw_cross_wepoll : git_version
${ cc_mingw_cross } -o ${ NAME } _mp_wepoll.exe -I. ${ SOURCES0 } pcap_wrapper.cpp ${ FLAGS } -ggdb -static -O2 -DNO_LIBEV_EMBED -D_WIN32 -lev -lws2_32 ${ MP }
mac_cross : git_version
${ cc_mac_cross } -o ${ NAME } _mp_mac -I. ${ SOURCES } ${ PCAP } ${ FLAGS } -ggdb -O2 ${ MP }
release_mp : ${TARGETS_MP }
2017-11-03 01:04:59 -05:00
cp git_version.h version.txt
2020-07-27 11:33:26 -04:00
tar -zcvf ${ NAME } _mp_binaries.tar.gz ${ NAME } _mp.exe ${ NAME } _mp_wepoll.exe ${ NAME } _mp_mac version.txt
2020-07-15 16:46:45 -04:00
2017-08-18 19:42:29 +08:00
clean :
rm -f ${ TAR }
2020-07-15 16:46:45 -04:00
rm -f ${ NAME } ${ NAME } _cross ${ NAME } .exe ${ NAME } _wepoll.exe ${ NAME } _mac
rm -f ${ NAME } _mp_binaries.tar.gz ${ NAME } _mp.exe ${ NAME } _mp_wepoll.exe ${ NAME } _mp_mac
2017-09-06 05:31:29 -05:00
rm -f git_version.h
git_version :
echo " const char *gitversion = \" $( shell git rev-parse HEAD) \"; " > git_version.h