diff --git a/package/firmware/linux-firmware/Makefile b/package/firmware/linux-firmware/Makefile index d056140f4..cc5c0db48 100644 --- a/package/firmware/linux-firmware/Makefile +++ b/package/firmware/linux-firmware/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=linux-firmware -PKG_VERSION:=20240220 +PKG_VERSION:=20240709 PKG_RELEASE:=1 PKG_SOURCE_URL:=@KERNEL/linux/kernel/firmware PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_HASH:=bf0f239dc0801e9d6bf5d5fb3e2f549575632cf4688f4348184199cb02c2bcd7 +PKG_HASH:=719662d2e8644c097f9a0bfb6e4c97280f8b2943e7bd9b47f77cf039412f5b14 PKG_MAINTAINER:=Felix Fietkau diff --git a/package/firmware/linux-firmware/amd.mk b/package/firmware/linux-firmware/amd.mk index 68b305e86..c1f5711e9 100644 --- a/package/firmware/linux-firmware/amd.mk +++ b/package/firmware/linux-firmware/amd.mk @@ -1,4 +1,4 @@ -Package/amd64-microcode = $(call Package/firmware-default,AMD64 CPU microcode,@TARGET_x86) +Package/amd64-microcode = $(call Package/firmware-default,AMD64 CPU microcode,,LICENSE.amd-ucode) define Package/amd64-microcode/install $(INSTALL_DIR) $(1)/lib/firmware/amd-ucode $(CP) \ @@ -8,7 +8,7 @@ endef $(eval $(call BuildPackage,amd64-microcode)) -Package/amdgpu-firmware = $(call Package/firmware-default,AMDGPU Video Driver firmware) +Package/amdgpu-firmware = $(call Package/firmware-default,AMDGPU Video Driver firmware,,LICENSE.amdgpura) define Package/amdgpu-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/amdgpu $(CP) \ @@ -18,7 +18,7 @@ endef $(eval $(call BuildPackage,amdgpu-firmware)) -Package/radeon-firmware = $(call Package/firmware-default,Radeon Video Driver firmware) +Package/radeon-firmware = $(call Package/firmware-default,Radeon Video Driver firmware,,LICENSE.radeon) define Package/radeon-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/radeon $(CP) \ diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index 3f681e24b..30f180fff 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -731,8 +731,7 @@ define KernelPackage/r8169 DEPENDS:=@PCI_SUPPORT +kmod-mii +r8169-firmware +kmod-phy-realtek +!LINUX_5_4:kmod-mdio-devres KCONFIG:= \ CONFIG_R8169 \ - CONFIG_R8169_NAPI=y \ - CONFIG_R8169_VLAN=n + CONFIG_R8169_LEDS=y@ge6.6 FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/r8169.ko AUTOLOAD:=$(call AutoProbe,r8169) endef diff --git a/package/lean/autocore/files/x86/sbin/cpuinfo b/package/lean/autocore/files/x86/sbin/cpuinfo index 96f2be41f..fd4e6eb6e 100755 --- a/package/lean/autocore/files/x86/sbin/cpuinfo +++ b/package/lean/autocore/files/x86/sbin/cpuinfo @@ -5,7 +5,7 @@ MHz=`grep 'MHz' /proc/cpuinfo | cut -c11- |sed -n '1p'` if [ "$(grep 'AMD' /proc/cpuinfo)" != "" ]; then TEMP=`sensors 2>/dev/null | grep 'Tctl' | cut -c16-` else -TEMP=`sensors 2>/dev/null | grep 'Core 0' | cut -c12-` +TEMP=`sensors 2>/dev/null | grep '0:' | awk -F ':' '{print $2}'` fi echo "$MHz MHz $TEMP " diff --git a/package/lean/default-settings/files/zzz-default-settings b/package/lean/default-settings/files/zzz-default-settings index 40c189b22..144596d4b 100755 --- a/package/lean/default-settings/files/zzz-default-settings +++ b/package/lean/default-settings/files/zzz-default-settings @@ -51,7 +51,7 @@ sed -i '/option disabled/d' /etc/config/wireless sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release -echo "DISTRIB_REVISION='R24.7.22-D'" >> /etc/openwrt_release +echo "DISTRIB_REVISION='R24.8.1'" >> /etc/openwrt_release sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release echo "DISTRIB_DESCRIPTION='OpenWrt '" >> /etc/openwrt_release diff --git a/package/lean/leigod-acc/Makefile b/package/lean/leigod-acc/Makefile new file mode 100644 index 000000000..65b57ce24 --- /dev/null +++ b/package/lean/leigod-acc/Makefile @@ -0,0 +1,58 @@ +# +# Copyright (C) 2015-2016 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v3. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=leigod-acc +PKG_VERSION:=1.3.0.30 +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=net + CATEGORY:=Network + TITLE:=Powerful Leigod Game Accelerater + DEPENDS:=@(x86_64||arm||mipsel||aarch64) + URL:=https://www.leigod.com/ +endef + +define Package/$(PKG_NAME)/description +leigod-acc is a powerful game accelerater +endef + +ifeq ($(ARCH),x86_64) + acc-arch:=amd64 +endif +ifeq ($(ARCH),mipsel) + acc-arch:=mipsle +endif +ifeq ($(ARCH),arm) + acc-arch:=arm +endif +ifeq ($(ARCH),aarch64) + acc-arch:=arm64 +endif + +define Build/Prepare +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/sbin/leigod + $(INSTALL_BIN) ./files/acc-gw.linux.$(acc-arch) $(1)/usr/sbin/leigod/acc-gw.linux.$(acc-arch) + $(INSTALL_BIN) ./files/leigod_uninstall.sh $(1)/usr/sbin/leigod/leigod_uninstall.sh + $(INSTALL_BIN) ./files/plugin_common.sh $(1)/usr/sbin/leigod/plugin_common.sh + $(INSTALL_BIN) ./files/update_plugin $(1)/usr/sbin/leigod/update_plugin + $(INSTALL_DATA) ./files/version $(1)/usr/sbin/leigod/version +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/lean/leigod-acc/files/acc-gw.linux.amd64 b/package/lean/leigod-acc/files/acc-gw.linux.amd64 new file mode 100644 index 000000000..d4ddab902 Binary files /dev/null and b/package/lean/leigod-acc/files/acc-gw.linux.amd64 differ diff --git a/package/lean/leigod-acc/files/acc-gw.linux.arm b/package/lean/leigod-acc/files/acc-gw.linux.arm new file mode 100644 index 000000000..7b72e853d Binary files /dev/null and b/package/lean/leigod-acc/files/acc-gw.linux.arm differ diff --git a/package/lean/leigod-acc/files/acc-gw.linux.arm64 b/package/lean/leigod-acc/files/acc-gw.linux.arm64 new file mode 100644 index 000000000..7f9d69266 Binary files /dev/null and b/package/lean/leigod-acc/files/acc-gw.linux.arm64 differ diff --git a/package/lean/leigod-acc/files/acc-gw.linux.mipsle b/package/lean/leigod-acc/files/acc-gw.linux.mipsle new file mode 100644 index 000000000..d0fe35884 Binary files /dev/null and b/package/lean/leigod-acc/files/acc-gw.linux.mipsle differ diff --git a/package/lean/leigod-acc/files/leigod-helper.sh b/package/lean/leigod-acc/files/leigod-helper.sh new file mode 100644 index 000000000..1dab4ddb2 --- /dev/null +++ b/package/lean/leigod-acc/files/leigod-helper.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# https://github.com/isecret/leigod-helper/blob/main/leigod-helper.sh + +USERNAME="${USERNAME:-phone}" +PASSWORD="${PASSWORD:-password}" + +if ! command -v "jq" > /dev/null; then + echo "缺失 jq 依赖"; + exit; +fi + +if command -v md5sum > /dev/null; then + password_hash=$(echo -n "$PASSWORD" | md5sum | awk '{print $1}') +elif command -v md5 > /dev/null; then + password_hash=$(echo -n "$PASSWORD" | md5) +else + echo "缺失 md5 或 md5sum 依赖,请手动安装" + exit 1 +fi + +login=$(curl -Lks -X POST https://webapi.leigod.com/api/auth/login \ + -H 'content-type: application/json' \ + -d "{ + \"account_token\": null, + \"country_code\": 86, + \"lang\": \"zh_CN\", + \"password\": \"$password_hash\", + \"region_code\": 1, + \"src_channel\": \"guanwang\", + \"user_type\": \"0\", + \"username\": \"$USERNAME\" + }") + +login_code=$(echo $login | jq -r ".code" 2>&1) +login_msg=$(echo $login | jq -r ".msg" 2>&1) + +if [ "$login_code" -eq 0 ]; then + account_token=$(echo $login | jq -r ".data.login_info.account_token" 2>&1) + pause=$(curl -Lks -X POST https://webapi.leigod.com/api/user/pause \ + -H 'content-type: application/json' \ + -d "{ + \"account_token\": \"$account_token\", + \"lang\": \"zh_CN\" + }") + pause_code=$(echo $pause | jq -r ".code" 2>&1) + pause_msg=$(echo $pause | jq -r ".msg" 2>&1) + + echo "暂停结果: $pause_msg" +else + echo "登录失败...原因: $login_msg" +fi diff --git a/package/lean/leigod-acc/files/leigod_uninstall.sh b/package/lean/leigod-acc/files/leigod_uninstall.sh new file mode 100644 index 000000000..cb9d5b5dc --- /dev/null +++ b/package/lean/leigod-acc/files/leigod_uninstall.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# this script is use to install leigod plugin +ver_name="version" +init_file_name="acc" +binary_prefix="acc-gw.linux" +common_file_name="plugin_common.sh" +download_base_url="http://119.3.40.126/router_plugin" + +# include common file +. ${common_file_name} + +# preinstall_check +# check and set env +preinstall_check + +if [ ${is_openwrt} ]; then + echo "remove openwrt config" + remove_openwrt_series_config + remove_openwrt_series_init +fi + +# remove_binary remove binary +remove_binary diff --git a/package/lean/leigod-acc/files/plugin_common.sh b/package/lean/leigod-acc/files/plugin_common.sh new file mode 100644 index 000000000..a46c5f2c8 --- /dev/null +++ b/package/lean/leigod-acc/files/plugin_common.sh @@ -0,0 +1,502 @@ +# this script is use to install leigod plugin +# sbin_dir="/usr/sbin/leigod" +ver_name="version" +init_file_name="acc" +binary_prefix="acc-gw.linux" +common_file_name="plugin_common.sh" +uninstall_file_name="leigod_uninstall.sh" +download_base_url="http://119.3.40.126/router_plugin" + +# get_device_os +# current support os: Linux +get_device_os() { + os=$(uname) + if [ $? == "0" ]; then + return 0 + fi + echo "os cant be get" + return -1 +} + +# get_device_arch, +# current support arch: arm64 arm x86_64 mips +get_device_arch() { + arch=$(uname -m) + if [ $? == "0" ]; then + return 0 + fi + echo "arch cant be get" + return -1 +} + +# get_xiaomi_name check if is xiaomi +get_xiaomi_name() { + local name=$(uci get misc.hardware.displayName) + if [[ $? == "0" && ${name} != "" ]]; then + echo "router is xiaomi series, name: ${name}" + sbin_dir="/userdisk/appdata/leigod" + init_dir="/userdisk/appdata/leigod" + is_xiaomi=true + return 0 + fi + local name=$(uci get misc.hardware.model) + if [[ $? == "0" && ${name} != "" ]]; then + echo "router is xiaomi series, name: ${name}" + sbin_dir="/userdisk/appdata/leigod" + init_dir="/userdisk/appdata/leigod" + is_xiaomi=true + return 0 + fi + + local name=$(uci get misc.hardware.model) + if [[ $? == "0" && ${name} != "" ]]; then + echo "router is xiaomi series, name: ${name}" + sbin_dir="/userdisk/appdata/leigod" + init_dir="/userdisk/appdata/leigod" + is_xiaomi=true + return 0 + fi + echo "router is not xiaomi, use general openwrt" + sbin_dir="/usr/sbin/leigod" + init_dir="/etc/init.d" + # stop openwrt service first + echo "stop openwrt acc service first, in casue install failed" + /etc/init.d/acc stop + sleep 1 + show_openwrt_suggestion + return 0 +} + +# get_asus_name get asus name +get_merlin_party() { + if [[ -d "/koolshare" ]]; then + echo "router is merlin series, name: $(nvram get build_name)" + nvram set 3rd-party=merlin + is_merlin=true + sbin_dir="/koolshare/leigod/acc" + init_dir="/koolshare/init.d" + echo "message" + return 0 + elif [[ -d "/jffs/softcenter" ]]; then + echo "router is swrt series, name: $(nvram get build_name)" + is_swrt=true + nvram set 3rd-party=swrt + sbin_dir="/jffs/softcenter/leigod/acc" + init_dir="/jffs/softcenter/init.d" + return 0 + fi + # check merlin + echo "route is not merlin, use general asus" + return 0 +} + +# get_device_firmware get device firmware +# current support firmware: openwrt merlin +get_device_firmware() { + # openwrt file exist + if [ -f "/etc/openwrt_release" ]; then + echo "firmware is openwrt series" + is_openwrt=true + get_xiaomi_name + elif [[ -f "/etc/image_version" ]] || [[ -d "/koolshare" ]] || [[ -d "/jffs/softcenter" ]]; then + echo "firmware is asus series" + is_asus=true + echo "stop asus acc service first, in casue install failed" + PIDS=$(ps | grep acc | grep -v grep | awk '{print $1}') + # check if process exist + get_merlin_party + fi +} + +# install_openwrt_package install openwrt +install_binary() { + # create sbin dir + mkdir -p ${sbin_dir} + # create name + local acc_name=${binary_prefix}.${arch} + local download_bin_url=${download_base_url}/${acc_name} + echo "install ${acc_name} to ${sbin_dir}" + # download file + curl -s -o ${sbin_dir}/${acc_name} ${download_bin_url} + if [ $? != "0" ]; then + echo "download and install binary failed" + return -1 + fi + echo "install binary success" + chmod +x ${sbin_dir}/${acc_name} + if [ $? != "0" ]; then + echo "add binary permission failed" + return -1 + fi + echo "add acc binary permission success" + # download common file + local download_common_url=${download_base_url}/${common_file_name} + curl -s -o ${sbin_dir}/${common_file_name} ${download_common_url} + if [ $? != "0" ]; then + echo "download and install common file failed" + return -1 + fi + + # remote uninstall_file_name + local remote_uninstall_file_name=${download_base_url}/"plugin_uninstall.sh" + curl -s -o ${sbin_dir}/${uninstall_file_name} ${remote_uninstall_file_name} + if [ $? != "0" ]; then + echo "download and install uninstall file failed" + return -1 + fi + echo "add uninstall permission success" + local ver_file=${sbin_dir}/${ver_name} + touch ${ver_file} + if [ $? != "0" ]; then + echo "create version file failed" + return -1 + fi + # add version to file + echo "version=1.3.0.30" > ${ver_file} + echo "add version file success" +} + +# remove_binary remove binary +remove_binary() { + rm -r ${sbin_dir} +} + +# install xiaomi monitor +install_xiaomi_monitor() { + local cron_path="/etc/crontabs/root" + local monitor_file_name="plugin_monitor.sh" + local download_monitor_url=${download_base_url}/${monitor_file_name} + curl -o ${sbin_dir}/${monitor_file_name} ${download_monitor_url} + if [ $? != "0" ]; then + echo "download monitor file failed" + return -1 + fi + chmod +x ${sbin_dir}/${monitor_file_name} + # download + echo "download monitor file success" + echo "*/1 * * * * ${sbin_dir}/${monitor_file_name}" >> ${cron_path} + if [ $? != "0" ]; then + echo "add monitor to cron failed" + return -1 + fi + echo "add monitor to cron success" +} + +# install_openwrt_series_config save openwrt config +install_openwrt_series_config() { + # create accelerator config + touch /etc/config/accelerator + if [ $? != "0" ]; then + echo "make acc config file failed" + return -1 + fi + if [ ${install_env} == "test" ]; then + # use uci to add config + uci set accelerator.base=system + uci set accelerator.bind=bind + uci set accelerator.device=hardware + uci set accelerator.Phone=acceleration + uci set accelerator.PC=acceleration + uci set accelerator.Game=acceleration + uci set accelerator.Unknown=acceleration + uci set accelerator.base.url='https://test-opapi.nn.com/speed/router/plug/check' + uci set accelerator.base.heart='https://test-opapi.nn.com/speed/router/heartbeat' + uci set accelerator.base.base_url='https://test-opapi.nn.com/speed' + uci commit accelerator + elif [ ${install_env} == "test1" ]; then + # use uci to add config + uci set accelerator.base=system + uci set accelerator.bind=bind + uci set accelerator.device=hardware + uci set accelerator.Phone=acceleration + uci set accelerator.PC=acceleration + uci set accelerator.Game=acceleration + uci set accelerator.Unknown=acceleration + uci set accelerator.base.url='https://test1-opapi.nn.com/speed/router/plug/check' + uci set accelerator.base.heart='https://test1-opapi.nn.com/speed/router/heartbeat' + uci set accelerator.base.base_url='https://test1-opapi.nn.com/speed' + uci commit accelerator + else + # use uci to add config + uci set accelerator.base=system + uci set accelerator.bind=bind + uci set accelerator.device=hardware + uci set accelerator.Phone=acceleration + uci set accelerator.PC=acceleration + uci set accelerator.Game=acceleration + uci set accelerator.Unknown=acceleration + uci set accelerator.base.url='https://opapi.nn.com/speed/router/plug/check' + uci set accelerator.base.heart='https://opapi.nn.com/speed/router/heartbeat' + uci set accelerator.base.base_url='https://opapi.nn.com/speed' + uci commit accelerator + fi + if [ $? != "0" ]; then + echo "create openwrt config unit failed" + return -1 + fi + echo "create openwrt config unit success" +} + +# install_openwrt_series_luasrc install openwrt lua src +install_openwrt_series_luasrc() { + lua_base="/usr/lib/lua/luci" + # download index file + curl --create-dirs -o ${lua_base}/controller/acc.lua ${download_base_url}/openwrt/controller/acc.lua + if [ $? != "0" ]; then + echo "download acc.lua failed" + return -1 + fi + # download service view file + curl --create-dirs -o ${lua_base}/model/cbi/leigod/service.lua ${download_base_url}/openwrt/model/cbi/leigod/service.lua + if [ $? != "0" ]; then + echo "download service.lua failed" + return -1 + fi + # download device view file + curl --create-dirs -o ${lua_base}/model/cbi/leigod/device.lua ${download_base_url}/openwrt/model/cbi/leigod/device.lua + if [ $? != "0" ]; then + echo "download device.lua failed" + return -1 + fi + # download notice view file + curl --create-dirs -o ${lua_base}/model/cbi/leigod/notice.lua ${download_base_url}/openwrt/model/cbi/leigod/notice.lua + if [ $? != "0" ]; then + echo "download notice.lua failed" + return -1 + fi + # download service view file + curl --create-dirs -o ${lua_base}/view/leigod/notice.htm ${download_base_url}/openwrt/view/leigod/notice.htm + if [ $? != "0" ]; then + echo "download notice.htm failed" + return -1 + fi + # download service view file + curl --create-dirs -o ${lua_base}/view/leigod/service.htm ${download_base_url}/openwrt/view/leigod/service.htm + if [ $? != "0" ]; then + echo "download service.htm failed" + return -1 + fi + # download service translate file + curl --create-dirs -o ${lua_base}/i18n/acc.zh-cn.lmo ${download_base_url}/openwrt/po/zh-cn/acc.zh-cn.lmo + if [ $? != "0" ]; then + echo "download acc.zh-cn.lmo failed" + return -1 + fi + echo "download lua src success" +} + +install_openwrt_series_web() { + local luci_base="/usr/lib/lua/luci" + +} + +# remove_openwrt_series_config remove openwrt config +remove_openwrt_series_config() { + rm /etc/config/accelerator +} + +# install asus series config +install_asus_series_config() { + mkdir -p ${sbin_dir}/config + if [ ${install_env} == "test" ]; then + # install test asus config + echo " +[base] +url="https://test-opapi.nn.com/speed/router/plug/check" +channel="2" +appid="nnMobile_d0k3duup" +heart="https://test-opapi.nn.com/speed/router/heartbeat" +base_url="https://test-opapi.nn.com/speed" + +[update] +domain="https://test-opapi.nn.com/nn-version/version/plug/upgrade" + +[device] + " > ${sbin_dir}/config/accelerator + elif [ ${install_env} == "test1" ]; then + # install test1 asus config + echo " +[base] +url="https://test1-opapi.nn.com/speed/router/plug/check" +channel="2" +appid="nnMobile_d0k3duup" +heart="https://test1-opapi.nn.com/speed/router/heartbeat" +base_url="https://test1-opapi.nn.com/speed" + +[update] +domain="https://test1-opapi.nn.com/nn-version/version/plug/upgrade" + +[device] + " > ${sbin_dir}/config/accelerator + else + # install formel asus config + echo " +[base] +url="https://opapi.nn.com/speed/router/plug/check" +channel="2" +appid="nnMobile_d0k3duup" +heart="https://opapi.nn.com/speed/router/heartbeat" +base_url="https://opapi.nn.com/speed" + +[update] +domain="https://opapi.nn.com/nn-version/version/plug/upgrade" + +[device] + " > ${sbin_dir}/config/accelerator + + fi + + echo "create asus series config success" +} + +# remove_asus_series_config remove asus config +remove_asus_series_config() { + rm -r ${init_dir} +} + +# install_openwrt_init install openwrt to init +install_openwrt_series_init() { + local remote_init_name="openwrt_init.sh" + local download_init_url=${download_base_url}/${remote_init_name} + # download init file + curl -o ${init_dir}/${init_file_name} ${download_init_url} + if [ $? != "0" ]; then + echo "download init file failed" + return -1 + fi + echo "download init file success" + # add permission to file + chmod +x ${init_dir}/${init_file_name} + if [ $? != "0" ]; then + echo "add init permission failed" + return -1 + fi + echo "add init file permission success" + ${init_dir}/${init_file_name} enable + echo "set accelerator autostart success" + ${init_dir}/${init_file_name} start + if [ $? != "0" ]; then + echo "start accelerator failed" + return -1 + fi + echo "start accelerator success" +} + +# remove_openwrt_series_init remove openwrt init +remove_openwrt_series_init() { + ${init_dir}/${init_file_name} disable + ${init_dir}/${init_file_name} stop + rm ${init_dir}/${init_file_name} +} + +# install merlin init +install_merlin_init() { + local remote_init_name="asus_init.sh" + local download_init_url=${download_base_url}/${remote_init_name} + # download init file + curl -o ${sbin_dir}/${init_file_name} ${download_init_url} + if [ $? != "0" ]; then + echo "download init file failed" + return -1 + fi + # add permission + chmod +x ${sbin_dir}/${init_file_name} + # create link + local link_init_name="S99LeigodAcc.sh" + local link_init_file=${init_dir}/${link_init_name} + ln -sf ${sbin_dir}/${init_file_name} ${link_init_file} + if [ $? != "0" ]; then + echo "create merlin init link failed" + return -1 + fi + echo "create merlin link file success" + ${link_init_file} start + echo "acc start success" +} + +# show_openwrt_suggestion show openwrt install suggest +show_openwrt_suggestion() { + echo " + 雷神OpenWrt插件安装建议: + + 当前雷神路由器支持两种加速模式, + 1. tproxy加速模式(速度更快, CPU占用率更低) + 2. tun加速模式(需要依赖少, 安装灵活) + + 需要您根据以上的加速模式, 安装对应的依赖库, + 如下列出两种模式对应的安装依赖: + 1. TProxy模式: libpcap iptables kmod-ipt-nat iptables-mod-tproxy kmod-ipt-tproxy kmod-netem(可选) tc-full(可选) kmod-ipt-ipset ipset curl + 2. Tun模式: libpcap iptables kmod-tun kmod-ipt-nat kmod-ipt-ipset ipset curl + + 如何安装依赖: + 1. 升级依赖: opkg update + 2. 安装依赖: opkg install xxx + + 为了安装方便, 请选择一个模式, 复制以下命令到终端运行: + Tproxy模式: + opkg update + opkg install libpcap iptables kmod-ipt-nat iptables-mod-tproxy kmod-ipt-tproxy kmod-netem tc-full kmod-ipt-ipset ipset + + Tun模式: + opkg update + opkg install libpcap iptables kmod-tun kmod-ipt-nat kmod-ipt-ipset ipset curl + + 关于steamdeck的支持说明 + steamdeck设备请选择加速电脑游戏 + + 关于手机设备的支持: + 1. 安卓支持说明 + 当前代理仅支持ipv4代理, 请更改dhcp配置,更改完配置请重启路由器, + 配置路径在 /etc/config/dhcp + config dhcp 'lan' + ... 此处是一些其他配置 + ra 'disable' + dhcpv6 'disable' + list ra_flags 'none' + ... 此处是一些其他配置 + + 2. 关于ios设备的支持说明 + ios设备, 安装完插件后, 为了精准识别, 请在ios上选择忘记wifi, 然后重新连接即可 + " +} + +# preinstall_check check env +preinstall_check() { + # check os + get_device_os + if [ ${os} != "Linux" ]; then + echo "current os not support, os: ${os}" + return -1 + fi + # check arch + get_device_arch + if [[ ${arch} != "x86_64" && ${arch} != "aarch64" && ${arch} != "arm" && ${arch} != "mips" && ${arch} != "armv7l" ]];then + echo "current arch not support, arch: ${arch}" + return -1 + fi + # fix arch + if [ ${arch} == "x86_64" ]; then + echo "match x86_64 -> amd64" + arch="amd64" + elif [ ${arch} == "aarch64" ]; then + echo "match aarch64 -> arm64" + arch="arm64" + elif [ ${arch} == "mips" ]; then + echo "match mips -> mipsle" + arch="mipsle" + elif [ ${arch} == "armv7l" ]; then + arch="arm" + fi + # support plugin + echo "current system support plugin, system: ${os}-${arch}" + get_device_firmware + return 0 +} + +# show_install_success show install has been installed +show_install_success() { + echo "install success" + echo "雷神路由器插件安装已完成" + echo "请加群632342113体验" +} + diff --git a/package/lean/leigod-acc/files/update_plugin b/package/lean/leigod-acc/files/update_plugin new file mode 100644 index 000000000..c9061d9a8 --- /dev/null +++ b/package/lean/leigod-acc/files/update_plugin @@ -0,0 +1,175 @@ +#!/usr/bin/lua + +local util = require "luci.util" +local string = require "string" +local io = require "io" +local json = require "luci.jsonc" +local uci = require "luci.model.uci".cursor() +local client = require "luci.httpclient" +local helper = require "luci.helper" + +-- get cloud version +function get_cloud_version() + -- get cloud url + local url = uci:get("easyupdate", "main", "domain") + -- get request channel + local channel = uci:get("easyupdate", "main", "channel") + -- appid + local appid = uci:get("easyupdate", "main", "appid") + -- read brand and model from file + local brand, model = helper.get_board_info() + -- platfrom + local platform = 11 + -- create http request options + local options = {} + -- create http request method + options.method = "POST" + -- create http request headers + options.headers = {} + options.headers['appId'] = appid + options.headers['reqChannel'] = channel + options.headers['Content-Type'] = 'application/json' + -- create http request body + local body = { + -- + ['appId'] = 'spRouterPlugin_fhem2shgq9s5', + ['brand'] = brand, + ['model'] = model, + ['platform'] = platform, + } + -- marshal to json + local buf = util.serialize_json(body) + options.body = buf + -- begin to query + local status, _, buffer, _ = client.request_raw(url, options) + -- check if query success + if not status then + io.write("status is nil \n") + return "" + end + -- check if request success + if status ~= 200 and status ~=206 then + io.write("status is not success, status: " .. status .. "\n") + return "" + end + -- begin to parse response + local info = json.parse(buffer) + -- get ret data + local data = info['retData'] + -- check if data is nil + if data == nil then + io.write("response ret data is nil \n") + return "" + end + -- store url in config + local fw_url = data['url'] + local version = data['versionName'] + io.write("fw_url: " .. fw_url .. ", version: " .. version .. "\n") + -- get version success + return version, fw_url +end + +-- get local version +function get_local_version() + -- run command to get acc version + local cmd = 'opkg info acc' + local buf = util.exec(cmd) + -- check exec result + if buf == nil then + io.write("exec command failed \n") + return "" + end + io.write("buf: " .. buf .. "\n") + -- read line + for line in string.gmatch(buf, "[^\r\n]+") do + io.write("read line: " .. line .. "\n") + line = string.gsub(line, " ", "") + local valueSl = string.gmatch(line, "[^:]+") + local key = valueSl() + local value = valueSl() + if key == "Version" then + io.write("get local version: " .. value .. "\n") + return value + end + end + io.write("local version cant found \n") +end + +-- get file base name +function get_file_base_name(filepath) + local name = string.gmatch(filepath, "([^/]+)$") + io.write("get file base name: " .. name .. "\n") + return name +end + +-- download cloud version +function download_cloud_app(url, name) + io.write("download app, url: " .. url .. ", name: " .. name .. "\n") + -- run download + local cmd = 'curl -s -o /tmp/' .. name ..' -w %{http_code}' .. ' ' .. url + -- exec download + local code = util.exec(cmd) + if code ~= "200" then + io.write("download cloud app failed, code: " .. code .. "\n") + return false + end + io.write("download cloud app success \n") + return code +end + +-- install package name in tmp dir +function install_package(name) + io.write("install package, package name: " .. name .. "\n") + local cmd = "opkg install " .. "/tmp/" .. name .. " " .. "--force-overwrite" + local code = util.exec(cmd) + io.write("install package finish, package name: " .. name .. "\n") + return code +end + +-- remove pkg +function remove_pkg(name) + io.write("remove package, package name: " .. name .. "\n") + local cmd = "rm -rf " .. "/tmp/" .. name + local code = util.exec(cmd) + io.write("remove package finish, package name: " .. name .. "\n") + return code +end + +-- check network state +io.write("check network state \n") +while true do + local state_code = helper.get_network_state() + if state_code == 200 then + io.write("network available \n") + break + end + if state_code ~= nil then + io.write("network is not available, code: " .. state_code .. "\n") + end +end +io.write("network success") + +-- exec command +local local_version = get_local_version() +local cloud_version, url = get_cloud_version() +-- check if need update +if local_version >= cloud_version then + io.write("local version is new, dont need update, local ver: " .. local_version .. + ", cloud version:" .. cloud_version .. "\n") + return +end + +-- need update +io.write("local version is lower, need update, local version: " .. local_version .. + ", cloud version: " .. cloud_version .. "\n") + +-- download url +local name = "acc.ipk" +local result = download_cloud_app(url, name) +if not result then + return +end + +-- install package +install_package(name) +remove_pkg(name) diff --git a/package/lean/leigod-acc/files/version b/package/lean/leigod-acc/files/version new file mode 100644 index 000000000..aacce3421 --- /dev/null +++ b/package/lean/leigod-acc/files/version @@ -0,0 +1 @@ +version=1.3.0.30 diff --git a/package/lean/libcryptopp/Makefile b/package/lean/libcryptopp/Makefile index 02d06a4bf..cffea47d6 100644 --- a/package/lean/libcryptopp/Makefile +++ b/package/lean/libcryptopp/Makefile @@ -13,7 +13,7 @@ PKG_VERSION:=8.5.0 PKG_RELEASE:=1 PKG_SOURCE:=cryptopp$(subst .,,$(PKG_VERSION)).zip -PKG_SOURCE_URL:=https://www.cryptopp.com/ +PKG_SOURCE_URL:=https://github.com/weidai11/cryptopp/releases/download/CRYPTOPP_$(subst .,_,$(PKG_VERSION))/ PKG_HASH:=95fc50d59488ebf61a735cce2b2ec2c2561fc682077c7b496273d65a1ed93d9e PKG_FIXUP:=autoreconf @@ -38,9 +38,19 @@ define Package/libcryptopp/description use of templates and abstract base classes. endef +PKG_BUILD_FILE:=cryptopp-autotools$(subst .,,$(PKG_VERSION)).zip +define Download/autotools + URL:=https://github.com/noloader/cryptopp-autotools/releases/download/CRYPTOPP_$(subst .,_,$(PKG_VERSION))/ + FILE:=$(PKG_BUILD_FILE) + HASH:=91e06c53b517753f0ba02b92bb259e0ee929ebc6ad4f8b5c190d39ba407d3fbe +endef +$(eval $(call Download,autotools)) + define Build/Prepare - $(Build/Prepare/Default) + $(PKG_UNPACK) + unzip -q -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_BUILD_FILE) cd $(PKG_BUILD_DIR); rm -f GNUmakefile GNUmakefile-cross + $(Build/Patch) endef define Build/InstallDev diff --git a/package/lean/libcryptopp/patches/001-autotools.patch b/package/lean/libcryptopp/patches/001-autotools.patch new file mode 100644 index 000000000..05f2a719b --- /dev/null +++ b/package/lean/libcryptopp/patches/001-autotools.patch @@ -0,0 +1,24 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -458,14 +458,13 @@ testvector_FILES = \ + TestVectors/lea.txt TestVectors/sosemanuk.txt \ + TestVectors/mars.txt TestVectors/speck.txt \ + TestVectors/nr.txt TestVectors/tea.txt \ +- TestVectors/ocb.txt TestVectors/threefish.txt \ +- TestVectors/panama.txt TestVectors/ttmac.txt \ +- TestVectors/poly1305aes.txt TestVectors/vmac.txt \ +- TestVectors/poly1305_tls.txt TestVectors/wake.txt \ +- TestVectors/rabbit.txt TestVectors/whrlpool.txt \ +- TestVectors/Readme.txt TestVectors/xchacha.txt \ +- TestVectors/rsa_oaep.txt TestVectors/xts.txt \ +- TestVectors/rsa_pkcs1_1_5.txt ++ TestVectors/panama.txt TestVectors/threefish.txt \ ++ TestVectors/poly1305aes.txt TestVectors/ttmac.txt \ ++ TestVectors/poly1305_tls.txt TestVectors/vmac.txt \ ++ TestVectors/rabbit.txt TestVectors/wake.txt \ ++ TestVectors/Readme.txt TestVectors/whrlpool.txt \ ++ TestVectors/rsa_oaep.txt TestVectors/xchacha.txt \ ++ TestVectors/rsa_pkcs1_1_5.txt TestVectors/xts.txt + + # Create with 'ls TestPrograms/test_*.cxx'. These files do not get installed. + # They exist so the feature tests can be run from the configure directory. diff --git a/package/lean/libcryptopp/src/Makefile.am b/package/lean/libcryptopp/src/Makefile.am deleted file mode 100644 index b830b75be..000000000 --- a/package/lean/libcryptopp/src/Makefile.am +++ /dev/null @@ -1,592 +0,0 @@ -## Makefile.am - Autotools configuration file for Crypto++. -## written and placed in public domain by Jeffrey Walton. -## based on Debian Makefile.am by László Böszörményi. -## -## The GNUmakefile can generate the list of lib headers, lib sources, -## test headers and test sources. Generate the list of files with -## 'make sources'. Remove the SIMD files for libothers_la_SOURCES. -## Thanks to steeldriver on U&L.SE for help with the sed. -## -## make sources | sed 's|cryptlib.cpp cpu.cpp integer.cpp ||g' | \ -## sed -e 's|[[:alnum:]]*_simd.cpp ||g' | \ -## sed -e 's|[[:alnum:]]*_sse.cpp ||g' | \ -## sed -e 's|[[:alnum:]]*_avx.cpp ||g' | \ -## sed -e 's|[[:alnum:]]*_armv4.cpp ||g' | \ -## sed -e 's|ppc_power[[:alnum:]]*.cpp ||g' | \ -## fold -s -w 72 -## -## The command `make sources | sed ... | fold` will create the source file -## list that can be used with `libothers_la_SOURCES` below. -## -## The list of header files can be built with 'make sources', too. -## -## make sources | sed -e 's|[[:alnum:]]*_armv4.h ||g' \ -## fold -s -w 72 -## -## Note: configure.ac deletes GNUmakefile. You can get it back with: -## -## git checkout GNUmakefile -## - -## Automake does not support "specific flags for certain source files" -## natively, so we hack it. The hack include building 20 or so -## libraries and then combining them into an archive or shared object. -## Also see https://lists.gnu.org/archive/html/automake/2017-11/msg00000.html -## https://www.gnu.org/software/automake/manual/html_node/Per_002dObject-Flags.html. -## -## Visit the link below for the original Debian Autotools files -## https://sources.debian.net/src/libcrypto++/5.6.4-8/debian/autotools/ -## - -## TODO: -## -## - Figure out how to include TestPrograms/ in the dist tarball -## TestPrograms/ is unique because it is included in dist tarball but not installed -## -## - Figure out what's going on with DragonFly and dependencies -## - -AUTOMAKE_OPTIONS = foreign -ACLOCAL_AMFLAGS = -I m4 -AM_DEFAULT_SOURCE_EXT = .cpp - -## libcryptopp.la is created from disjoint libraries due to object file -## ordering and per-object file flags requirements. libcryptopp.la is -## named as the primary library, and the object files with special needs -## are listed as EXTRA_LTLIBRARIES. Also see -## https://lists.gnu.org/archive/html/automake/2017-11/msg00000.html. - -lib_LTLIBRARIES = \ - libcryptopp.la - -EXTRA_LTLIBRARIES = \ - libcryptlib.la \ - libcpu.la \ - libinteger.la \ - libaria_simd.la \ - libblake2s_simd.la \ - libblake2b_simd.la \ - libchacha_simd.la \ - libchacha_avx.la \ - libcham_simd.la \ - libcrc_simd.la \ - libdonna_sse.la \ - libgcm_simd.la \ - libgf2n_simd.la \ - libkeccak_simd.la \ - liblea_simd.la \ - libneon_simd.la \ - libppc_simd.la \ - libppc_power7.la \ - libppc_power8.la \ - libppc_power9.la \ - librijndael_simd.la \ - libsha_simd.la \ - libshacal2_simd.la \ - libsimon128_simd.la \ - libspeck128_simd.la \ - libsm4_simd.la \ - libsse_simd.la - -## ARMv7-a AES and SHA by Andy Polyakov -if CRYPTOGAMS_ARM_SOURCES - EXTRA_LTLIBRARIES += libaes_armv4.la - EXTRA_LTLIBRARIES += libsha1_armv4.la - EXTRA_LTLIBRARIES += libsha256_armv4.la - EXTRA_LTLIBRARIES += libsha512_armv4.la -endif - -## The remainder of the source files -EXTRA_LTLIBRARIES += libothers.la - -## libcryptopp_la_SOURCES is empty because we need to create the library -## artifact from disjoint libraries due to object file ordering and -## per-object file flags requriements. Actually, the adhoc.cpp file is -## due to an automake issue of assuming C sources when the list is empty. -## https://lists.gnu.org/archive/html/automake/2017-11/msg00000.html. - -libcryptopp_la_SOURCES = \ - adhoc.cpp - -## Don't use EXTRA_ prefix for libcryptopp_la_LIBADD. It breaks Solaris. - -libcryptopp_la_LIBADD = \ - $(libcryptlib_la_OBJECTS) \ - $(libcpu_la_OBJECTS) \ - $(libinteger_la_OBJECTS) \ - $(libaria_simd_la_OBJECTS) \ - $(libblake2s_simd_la_OBJECTS) \ - $(libblake2b_simd_la_OBJECTS) \ - $(libchacha_simd_la_OBJECTS) \ - $(libchacha_avx_la_OBJECTS) \ - $(libcham_simd_la_OBJECTS) \ - $(libcrc_simd_la_OBJECTS) \ - $(libdonna_sse_la_OBJECTS) \ - $(libgcm_simd_la_OBJECTS) \ - $(libgf2n_simd_la_OBJECTS) \ - $(libkeccak_simd_la_OBJECTS) \ - $(liblea_simd_la_OBJECTS) \ - $(libneon_simd_la_OBJECTS) \ - $(libppc_simd_la_OBJECTS) \ - $(libppc_power7_la_OBJECTS) \ - $(libppc_power8_la_OBJECTS) \ - $(libppc_power9_la_OBJECTS) \ - $(librijndael_simd_la_OBJECTS) \ - $(libsha_simd_la_OBJECTS) \ - $(libshacal2_simd_la_OBJECTS) \ - $(libsimon128_simd_la_OBJECTS) \ - $(libspeck128_simd_la_OBJECTS) \ - $(libsm4_simd_la_OBJECTS) \ - $(libsse_simd_la_OBJECTS) - -## ARMv7-a AES and SHA by Andy Polyakov -if CRYPTOGAMS_ARM_SOURCES - libcryptopp_la_LIBADD += $(libaes_armv4_la_OBJECTS) - libcryptopp_la_LIBADD += $(libsha1_armv4_la_OBJECTS) - libcryptopp_la_LIBADD += $(libsha256_armv4_la_OBJECTS) - libcryptopp_la_LIBADD += $(libsha512_armv4_la_OBJECTS) -endif - -## cpufeatures library on Android -if ANDROID_CPU_FEATURES - libcryptopp_la_LIBADD += $(libcpu_features_la_OBJECTS) -endif - -## The remainder of the object files -libcryptopp_la_LIBADD += $(libothers_la_OBJECTS) - -## Don't use EXTRA_ prefix for libcryptopp_la_DEPENDENCIES. It breaks Solaris. - -libcryptopp_la_DEPENDENCIES = \ - $(libcryptlib_la_OBJECTS) \ - $(libcpu_la_OBJECTS) \ - $(libinteger_la_OBJECTS) \ - $(libaria_simd_la_OBJECTS) \ - $(libblake2s_simd_la_OBJECTS) \ - $(libblake2b_simd_la_OBJECTS) \ - $(libchacha_simd_la_OBJECTS) \ - $(libchacha_avx_la_OBJECTS) \ - $(libcham_simd_la_OBJECTS) \ - $(libcrc_simd_la_OBJECTS) \ - $(libdonna_sse_la_OBJECTS) \ - $(libkeccak_simd_la_OBJECTS) \ - $(liblea_simd_la_OBJECTS) \ - $(libgcm_simd_la_OBJECTS) \ - $(libgf2n_simd_la_OBJECTS) \ - $(libneon_simd_la_OBJECTS) \ - $(libppc_simd_la_OBJECTS) \ - $(libppc_power7_la_OBJECTS) \ - $(libppc_power8_la_OBJECTS) \ - $(libppc_power9_la_OBJECTS) \ - $(librijndael_simd_la_OBJECTS) \ - $(libsha_simd_la_OBJECTS) \ - $(libshacal2_simd_la_OBJECTS) \ - $(libsimon128_simd_la_OBJECTS) \ - $(libspeck128_simd_la_OBJECTS) \ - $(libsm4_simd_la_OBJECTS) \ - $(libsse_simd_la_OBJECTS) - -## ARMv7-a AES and SHA by Andy Polyakov -if CRYPTOGAMS_ARM_SOURCES - libcryptopp_la_DEPENDENCIES += $(libaes_armv4_la_OBJECTS) - libcryptopp_la_DEPENDENCIES += $(libsha1_armv4_la_OBJECTS) - libcryptopp_la_DEPENDENCIES += $(libsha256_armv4_la_OBJECTS) - libcryptopp_la_DEPENDENCIES += $(libsha512_armv4_la_OBJECTS) -endif - -## cpufeatures library on Android -if ANDROID_CPU_FEATURES - libcryptopp_la_DEPENDENCIES += $(libcpu_features_la_OBJECTS) -endif - -## The remainder of the object files -libcryptopp_la_DEPENDENCIES += $(libothers_la_OBJECTS) - -## Man, did Autotools fuck this up royally... -## https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -libcryptopp_la_LDFLAGS = $(AM_LDFLAGS) -release 8.5.0 -version-info 8:5 - -## Source files with special needs -libcryptlib_la_SOURCES = cryptlib.cpp -libcryptlib_la_CXXFLAGS = $(AM_CXXFLAGS) - -libcpu_la_SOURCES = cpu.cpp -libcpu_la_CXXFLAGS = $(AM_CXXFLAGS) - -libinteger_la_SOURCES = integer.cpp -libinteger_la_CXXFLAGS = $(AM_CXXFLAGS) - -libaria_simd_la_SOURCES = aria_simd.cpp -libaria_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_ARIA_FLAG) - -libblake2s_simd_la_SOURCES = blake2s_simd.cpp -libblake2s_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_BLAKE2S_FLAG) - -libblake2b_simd_la_SOURCES = blake2b_simd.cpp -libblake2b_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_BLAKE2B_FLAG) - -libchacha_simd_la_SOURCES = chacha_simd.cpp -libchacha_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_CHACHA_FLAG) - -libchacha_avx_la_SOURCES = chacha_avx.cpp -libchacha_avx_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_CHACHA_AVX2_FLAG) - -libcham_simd_la_SOURCES = cham_simd.cpp -libcham_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_CHAM_FLAG) - -libcrc_simd_la_SOURCES = crc_simd.cpp -libcrc_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_CRC_FLAG) - -libdonna_sse_la_SOURCES = donna_sse.cpp -libdonna_sse_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_DONNA_FLAG) - -libgcm_simd_la_SOURCES = gcm_simd.cpp -libgcm_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_GCM_FLAG) - -libgf2n_simd_la_SOURCES = gf2n_simd.cpp -libgf2n_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_GF2N_FLAG) - -libkeccak_simd_la_SOURCES = keccak_simd.cpp -libkeccak_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_KECCAK_FLAG) - -liblea_simd_la_SOURCES = lea_simd.cpp -liblea_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_LEA_FLAG) - -libneon_simd_la_SOURCES = neon_simd.cpp -libneon_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_NEON_FLAG) - -libppc_simd_la_SOURCES = ppc_simd.cpp -libppc_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_ALTIVEC_FLAG) - -libppc_power7_la_SOURCES = ppc_power7.cpp -libppc_power7_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_POWER7_FLAG) - -libppc_power8_la_SOURCES = ppc_power8.cpp -libppc_power8_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_POWER8_FLAG) - -# Do not use CRYPTOPP_POWER9_FLAG. See https://github.com/weidai11/cryptopp/issues/986 -libppc_power9_la_SOURCES = ppc_power9.cpp -# libppc_power9_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_POWER9_FLAG) -libppc_power9_la_CXXFLAGS = $(AM_CXXFLAGS) - -librijndael_simd_la_SOURCES = rijndael_simd.cpp -librijndael_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_AES_FLAG) - -libsha_simd_la_SOURCES = sha_simd.cpp -libsha_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_SHA_FLAG) - -libshacal2_simd_la_SOURCES = shacal2_simd.cpp -libshacal2_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_SHA_FLAG) - -libsimon128_simd_la_SOURCES = simon128_simd.cpp -libsimon128_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_SIMON128_FLAG) - -libspeck128_simd_la_SOURCES = speck128_simd.cpp -libspeck128_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_SPECK128_FLAG) - -libsm4_simd_la_SOURCES = sm4_simd.cpp -libsm4_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_SM4_FLAG) - -libsse_simd_la_SOURCES = sse_simd.cpp -libsse_simd_la_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTOPP_SSE2_FLAG) - -## ARMv7-a AES and SHA by Andy Polyakov -## Also see https://stackoverflow.com/q/51575580/608639 -if CRYPTOGAMS_ARM_SOURCES - libaes_armv4_la_SOURCES = aes_armv4.S - libsha1_armv4_la_SOURCES = sha1_armv4.S - libsha256_armv4_la_SOURCES = sha256_armv4.S - libsha512_armv4_la_SOURCES = sha512_armv4.S - libaes_armv4_la_CCASFLAGS = $(AM_CXXFLAGS) $(CRYPTOPGAMS_ARMV4_THUMB_FLAG) - libsha1_armv4_la_CCASFLAGS = $(AM_CXXFLAGS) $(CRYPTOPGAMS_ARMV4_FLAG) - libsha256_armv4_la_CCASFLAGS = $(AM_CXXFLAGS) $(CRYPTOPGAMS_ARMV4_FLAG) - libsha512_armv4_la_CCASFLAGS = $(AM_CXXFLAGS) $(CRYPTOPGAMS_ARMV4_FLAG) -endif - -## cpufeatures library on Android -if ANDROID_CPU_FEATURES - libcpu_features_la_SOURCES = cpu-features.c -endif - -# This is the list of remaining sources files that don't need special order -# and don't need special flags. It is formed by removing cryptlib.cpp, -# cpu.cpp, integer.cpp, *_avx.cpp and *_simd.cpp files. It is sorted in -# alphabetical order for deterministic builds. - -# To build this list, see the head notes. -libothers_la_SOURCES = \ - 3way.cpp adler32.cpp algebra.cpp algparam.cpp allocate.cpp arc4.cpp \ - aria.cpp ariatab.cpp asn.cpp authenc.cpp base32.cpp base64.cpp \ - basecode.cpp bfinit.cpp blake2.cpp blowfish.cpp blumshub.cpp \ - camellia.cpp cast.cpp casts.cpp cbcmac.cpp ccm.cpp chacha.cpp \ - chachapoly.cpp cham.cpp channels.cpp cmac.cpp crc.cpp darn.cpp \ - default.cpp des.cpp dessp.cpp dh.cpp dh2.cpp dll.cpp donna_32.cpp \ - donna_64.cpp dsa.cpp eax.cpp ec2n.cpp eccrypto.cpp ecp.cpp elgamal.cpp \ - emsa2.cpp eprecomp.cpp esign.cpp files.cpp filters.cpp fips140.cpp \ - fipstest.cpp gcm.cpp gf256.cpp gf2_32.cpp gf2n.cpp gfpcrypt.cpp \ - gost.cpp gzip.cpp hc128.cpp hc256.cpp hex.cpp hight.cpp hmac.cpp \ - hrtimer.cpp ida.cpp idea.cpp iterhash.cpp kalyna.cpp kalynatab.cpp \ - keccak.cpp keccak_core.cpp lea.cpp luc.cpp mars.cpp marss.cpp md2.cpp \ - md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp \ - oaep.cpp osrng.cpp padlkrng.cpp panama.cpp pkcspad.cpp poly1305.cpp \ - polynomi.cpp pssr.cpp pubkey.cpp queue.cpp rabbit.cpp rabin.cpp \ - randpool.cpp rc2.cpp rc5.cpp rc6.cpp rdrand.cpp rdtables.cpp \ - rijndael.cpp ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp \ - scrypt.cpp seal.cpp seed.cpp serpent.cpp sha.cpp sha3.cpp shacal2.cpp \ - shake.cpp shark.cpp sharkbox.cpp simeck.cpp simon.cpp skipjack.cpp \ - sm3.cpp sm4.cpp sosemanuk.cpp speck.cpp square.cpp squaretb.cpp \ - strciphr.cpp tea.cpp tftables.cpp threefish.cpp tiger.cpp tigertab.cpp \ - ttmac.cpp tweetnacl.cpp twofish.cpp vmac.cpp wake.cpp whrlpool.cpp \ - xed25519.cpp xtr.cpp xtrcrypt.cpp xts.cpp zdeflate.cpp zinflate.cpp \ - zlib.cpp - -# To build this list, see the head notes. -pkginclude_HEADERS = \ - 3way.h adler32.h adv_simd.h aes.h algebra.h algparam.h allocate.h \ - arc4.h argnames.h aria.h arm_simd.h asn.h authenc.h base32.h base64.h \ - basecode.h blake2.h blowfish.h blumshub.h camellia.h cast.h cbcmac.h \ - ccm.h chacha.h chachapoly.h cham.h channels.h cmac.h config.h \ - config_align.h config_asm.h config_cpu.h config_cxx.h config_dll.h \ - config_int.h config_misc.h config_ns.h config_os.h config_ver.h cpu.h \ - crc.h cryptlib.h darn.h default.h des.h dh.h dh2.h dll.h dmac.h donna.h \ - donna_32.h donna_64.h donna_sse.h drbg.h dsa.h eax.h ec2n.h eccrypto.h \ - ecp.h ecpoint.h elgamal.h emsa2.h eprecomp.h esign.h fhmqv.h files.h \ - filters.h fips140.h fltrimpl.h gcm.h gf256.h gf2_32.h gf2n.h gfpcrypt.h \ - gost.h gzip.h hashfwd.h hc128.h hc256.h hex.h hight.h hkdf.h hmac.h \ - hmqv.h hrtimer.h ida.h idea.h integer.h iterhash.h kalyna.h keccak.h \ - lea.h local.h lubyrack.h luc.h mars.h md2.h md4.h md5.h mdc.h \ - mersenne.h misc.h modarith.h modes.h modexppc.h mqueue.h mqv.h \ - naclite.h nbtheory.h nr.h oaep.h oids.h osrng.h ossig.h padlkrng.h \ - panama.h pch.h pkcspad.h poly1305.h polynomi.h ppc_simd.h pssr.h \ - pubkey.h pwdbased.h queue.h rabbit.h rabin.h randpool.h rc2.h rc5.h \ - rc6.h rdrand.h rijndael.h ripemd.h rng.h rsa.h rw.h safer.h salsa.h \ - scrypt.h seal.h secblock.h secblockfwd.h seckey.h seed.h serpent.h \ - serpentp.h sha.h sha3.h shacal2.h shake.h shark.h simeck.h simon.h \ - simple.h siphash.h skipjack.h sm3.h sm4.h smartptr.h sosemanuk.h \ - speck.h square.h stdcpp.h strciphr.h tea.h threefish.h tiger.h trap.h \ - trunhash.h ttmac.h tweetnacl.h twofish.h vmac.h wake.h whrlpool.h \ - words.h xed25519.h xtr.h xtrcrypt.h xts.h zdeflate.h zinflate.h zlib.h - -noinst_HEADERS = \ - local.h \ - bench.h \ - factory.h \ - resource.h \ - validate.h \ - aes_armv4.h \ - sha1_armv4.h \ - sha256_armv4.h \ - sha512_armv4.h - -bin_PROGRAMS = cryptest$(EXEEXT) - -cryptest_CXXFLAGS = $(AM_CXXFLAGS) $(CRYPTEST_CXXFLAGS) -DCRYPTOPP_DATA_DIR='"${pkgdatadir}/"' -cryptest_SOURCES = \ - test.cpp bench1.cpp bench2.cpp bench3.cpp datatest.cpp \ - dlltest.cpp fipsalgt.cpp validat0.cpp validat1.cpp validat2.cpp \ - validat3.cpp validat4.cpp validat5.cpp validat6.cpp validat7.cpp \ - validat8.cpp validat9.cpp validat10.cpp regtest1.cpp regtest2.cpp \ - regtest3.cpp regtest4.cpp - -nodist_cryptest_SOURCES = adhoc.cpp -cryptest_LDADD = $(lib_LTLIBRARIES) - -CLEANFILES = adhoc.cpp - -## Copy the TestVectors/ and TestData/ to ${pkgdatadir}. -## TestPrograms/ is included in the tarball but not installed. -## https://www.gnu.org/software/automake/manual/html_node/Data.html - -# Create with 'ls TestData/*.dat'. These files get installed. -testdata_FILES = \ - TestData/3desval.dat TestData/fhmqv160.dat TestData/rc2val.dat \ - TestData/3wayval.dat TestData/fhmqv256.dat TestData/rc5val.dat \ - TestData/aria.dat TestData/fhmqv384.dat TestData/rc6val.dat \ - TestData/camellia.dat TestData/fhmqv512.dat TestData/rijndael.dat \ - TestData/cast128v.dat TestData/gostval.dat TestData/rsa1024.dat \ - TestData/cast256v.dat TestData/hmqv160.dat TestData/rsa2048a.dat \ - TestData/defdmac1.bin TestData/hmqv256.dat TestData/rsa2048.dat \ - TestData/defdmac2.bin TestData/hmqv384.dat TestData/rsa400pb.dat \ - TestData/descert.dat TestData/hmqv512.dat TestData/rsa400pv.dat \ - TestData/dh1024.dat TestData/ideaval.dat TestData/rsa512a.dat \ - TestData/dh2048.dat TestData/luc1024.dat TestData/rw1024.dat \ - TestData/dlie1024.dat TestData/luc2048.dat TestData/rw2048.dat \ - TestData/dlie2048.dat TestData/lucc1024.dat TestData/saferval.dat \ - TestData/dsa1024b.dat TestData/lucc512.dat TestData/serpentv.dat \ - TestData/dsa1024.dat TestData/lucd1024.dat TestData/shacal2v.dat \ - TestData/dsa512.dat TestData/lucd512.dat TestData/sharkval.dat \ - TestData/ecies_p160.dat TestData/lucs1024.dat TestData/skipjack.dat \ - TestData/ecies_t163.dat TestData/lucs512.dat TestData/squareva.dat \ - TestData/ed25519.dat TestData/marsval.dat TestData/twofishv.dat \ - TestData/ed25519v0.dat TestData/mqv1024.dat TestData/usage.dat \ - TestData/ed25519v1.dat TestData/mqv2048.dat TestData/x25519.dat \ - TestData/elgc1024.dat TestData/nr1024.dat TestData/x25519v0.dat \ - TestData/esig1023.dat TestData/nr2048.dat TestData/x25519v1.dat \ - TestData/esig1536.dat TestData/rabi1024.dat TestData/xtrdh171.dat \ - TestData/esig2046.dat TestData/rabi2048.dat TestData/xtrdh342.dat - -# Create with 'ls TestVectors/*.txt'. These files get installed. -testvector_FILES = \ - TestVectors/aead.txt TestVectors/rsa_pss.txt \ - TestVectors/aes.txt TestVectors/rw.txt \ - TestVectors/all.txt TestVectors/salsa.txt \ - TestVectors/aria.txt TestVectors/seal.txt \ - TestVectors/blake2b.txt TestVectors/seed.txt \ - TestVectors/blake2s.txt TestVectors/sha1_160_fips_180.txt \ - TestVectors/blake2.txt TestVectors/sha1_fips_180.txt \ - TestVectors/camellia.txt TestVectors/sha2_224_fips_180.txt \ - TestVectors/ccm.txt TestVectors/sha2_256_fips_180.txt \ - TestVectors/chacha20poly1305.txt TestVectors/sha2_384_fips_180.txt \ - TestVectors/chacha_tls.txt TestVectors/sha2_512_fips_180.txt \ - TestVectors/chacha.txt TestVectors/sha2_fips_180.txt \ - TestVectors/cham.txt TestVectors/sha2.txt \ - TestVectors/cmac.txt TestVectors/sha3_224_fips_202.txt \ - TestVectors/dlies.txt TestVectors/sha3_256_fips_202.txt \ - TestVectors/dsa_1363.txt TestVectors/sha3_384_fips_202.txt \ - TestVectors/dsa_rfc6979.txt TestVectors/sha3_512_fips_202.txt \ - TestVectors/dsa.txt TestVectors/sha3_fips_202.txt \ - TestVectors/eax.txt TestVectors/sha3.txt \ - TestVectors/esign.txt TestVectors/shacal2.txt \ - TestVectors/gcm.txt TestVectors/shake.txt \ - TestVectors/hc128.txt TestVectors/sha.txt \ - TestVectors/hc256.txt TestVectors/simeck.txt \ - TestVectors/hight.txt TestVectors/simon.txt \ - TestVectors/hkdf.txt TestVectors/siphash.txt \ - TestVectors/hmac.txt TestVectors/skipjack.txt \ - TestVectors/kalyna.txt TestVectors/sm3.txt \ - TestVectors/keccak.txt TestVectors/sm4.txt \ - TestVectors/lea.txt TestVectors/sosemanuk.txt \ - TestVectors/mars.txt TestVectors/speck.txt \ - TestVectors/nr.txt TestVectors/tea.txt \ - TestVectors/panama.txt TestVectors/threefish.txt \ - TestVectors/poly1305aes.txt TestVectors/ttmac.txt \ - TestVectors/poly1305_tls.txt TestVectors/vmac.txt \ - TestVectors/rabbit.txt TestVectors/wake.txt \ - TestVectors/Readme.txt TestVectors/whrlpool.txt \ - TestVectors/rsa_oaep.txt TestVectors/xchacha.txt \ - TestVectors/rsa_pkcs1_1_5.txt TestVectors/xts.txt - -# Create with 'ls TestPrograms/test_*.cxx'. These files do not get installed. -# They exist so the feature tests can be run from the configure directory. -testprogs_FILES= \ - TestPrograms/test_32bit.cxx - TestPrograms/test_64bit.cxx - TestPrograms/test_arm_acle_header.cxx - TestPrograms/test_arm_aes.cxx - TestPrograms/test_arm_asimd.cxx - TestPrograms/test_arm_crc.cxx - TestPrograms/test_arm_neon.cxx - TestPrograms/test_arm_neon_header.cxx - TestPrograms/test_arm_pmull.cxx - TestPrograms/test_arm_sha1.cxx - TestPrograms/test_arm_sha256.cxx - TestPrograms/test_arm_sha3.cxx - TestPrograms/test_arm_sha512.cxx - TestPrograms/test_arm_sm3.cxx - TestPrograms/test_arm_sm4.cxx - TestPrograms/test_asm_mixed.cxx - TestPrograms/test_cxx11_alignas.cxx - TestPrograms/test_cxx11_alignof.cxx - TestPrograms/test_cxx11_assert.cxx - TestPrograms/test_cxx11_atomic.cxx - TestPrograms/test_cxx11_auto.cxx - TestPrograms/test_cxx11_constexpr.cxx - TestPrograms/test_cxx11.cxx - TestPrograms/test_cxx11_deletefn.cxx - TestPrograms/test_cxx11_enumtype.cxx - TestPrograms/test_cxx11_initializer.cxx - TestPrograms/test_cxx11_lambda.cxx - TestPrograms/test_cxx11_noexcept.cxx - TestPrograms/test_cxx11_nullptr.cxx - TestPrograms/test_cxx11_staticinit.cxx - TestPrograms/test_cxx11_sync.cxx - TestPrograms/test_cxx11_vartemplates.cxx - TestPrograms/test_cxx14.cxx - TestPrograms/test_cxx17_assert.cxx - TestPrograms/test_cxx17.cxx - TestPrograms/test_cxx17_exceptions.cxx - TestPrograms/test_cxx98_exception.cxx - TestPrograms/test_cxx.cxx - TestPrograms/test_glibc.cxx - TestPrograms/test_newlib.cxx - TestPrograms/test_ppc_aes.cxx - TestPrograms/test_ppc_altivec.cxx - TestPrograms/test_ppc_power7.cxx - TestPrograms/test_ppc_power8.cxx - TestPrograms/test_ppc_power9.cxx - TestPrograms/test_ppc_sha.cxx - TestPrograms/test_ppc_vmull.cxx - TestPrograms/test_pthreads.cxx - TestPrograms/test_x86_aes.cxx - TestPrograms/test_x86_avx2.cxx - TestPrograms/test_x86_avx512.cxx - TestPrograms/test_x86_avx.cxx - TestPrograms/test_x86_clmul.cxx - TestPrograms/test_x86_cpuid.cxx - TestPrograms/test_x86_rdrand.cxx - TestPrograms/test_x86_rdseed.cxx - TestPrograms/test_x86_sha.cxx - TestPrograms/test_x86_sse2.cxx - TestPrograms/test_x86_sse3.cxx - TestPrograms/test_x86_sse41.cxx - TestPrograms/test_x86_sse42.cxx - TestPrograms/test_x86_ssse3.cxx - TestPrograms/test_x86_via_aes.cxx - TestPrograms/test_x86_via_rng.cxx - TestPrograms/test_x86_via_sha.cxx - -nobase_dist_pkgdata_DATA = \ - $(testdata_FILES) \ - $(testvector_FILES) - -# Can't seem to get this to work, despite the fiddling attempts. -# https://www.gnu.org/software/automake/manual/html_node/Uniform.html and -# https://www.gnu.org/software/automake/manual/html_node/Program-and-Library-Variables.html -#nobase_noinst_data_DATA = \ -# $(testprogs_FILES) - -# Workaround Automake bug. We can't seem to include the TestProgram/ data -# in the tarball without installation using their Uniform Naming Scheme -# https://www.gnu.org/software/automake/manual/html_node/Uniform.html and -# https://www.gnu.org/software/automake/manual/html_node/Program-and-Library-Variables.html -dist-hook: - chmod -R u+w $(distdir) - cp -r TestPrograms/ $(distdir) - rm -f $(distdir)/TestPrograms/dump2def.cxx - -## Automake bug workaround. If libcryptopp_la_SOURCES is an empty list, Automake assumes -## C source files and drives link through the C compiler. We provide the empty adhoc.cpp -## to get things back on course, so adhoc.cpp must always be copied. - -adhoc.cpp: - cp adhoc.cpp.proto adhoc.cpp - touch adhoc.cpp - -## Remove doc directory if present -distclean-local: - -rm -rf html-docs doxyfile.stamp - -## Automake does not properly uninstall the library test data and vectors -uninstall-hook: - -rm -rf ${pkgdatadir} - -rm -rf ${pkghtmldir} - -## Doxygen is available but not built by default -## TODO: copy docs to ${pkghtmldir} if built -if CRYPTOPP_DOXYGEN_AVAILABLE - -## PHONY targets. Automake can only handle one of them... -.PHONY: doc docs html htmldoc checkout reset - -doc docs html htmldoc: - $(DOXYGEN) Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING - -endif - -# Restore GNUmakefile -checkout: - git checkout master -f - -# Restore GNUmakefile -reset: - git reset --hard HEAD diff --git a/package/lean/libcryptopp/src/configure.ac b/package/lean/libcryptopp/src/configure.ac deleted file mode 100644 index 9296bf207..000000000 --- a/package/lean/libcryptopp/src/configure.ac +++ /dev/null @@ -1,2746 +0,0 @@ -## configure.ac - Autotools configuration file for Crypto++. -## written and placed in public domain by Jeffrey Walton. -## based on Debian configure.ac by László Böszörményi. - - -## Visit the link below for the original Debian Autotools files -## http://sources.debian.net/src/libcrypto++/5.6.4-8/debian/autotools/ -## -## To generate the configure file perform the following. The extra steps are -## needed because the Autotools on some machines, like a PowerMac or Solaris, -## are not modern enough for macros like AC_PROG_LIBTOOL and AC_ENABLE_SHARED. -## -## autoupdate && libtoolize && autoreconf -## -## Our Autoconf tests are strict. We use custom AC_COMPILE_IFELSE and -## AC_LINK_IFELSE that rejects a feature test if there are any warnings or -## errors. We needed this because Autotools was mis-detecting features on AIX -## and Solarix using XLC and SunCC. We also needed the custom tests because -## Autoconf does not have a "warnings as errors" option that just works on all -## the compilers we support. - - -## TODO -## -## - Figure out how to make Autoconf stop using the fucking C compiler for tasks. -## The damn tool does not honor AC_PROG_CXX or observe the absence of -## AC_PROG_CC. It also fails to provide a AC_PROG_NO_CC macro. The damn tool -## is no better than Cmake. -## -## - Fix Autotools not treating warnings as errors. Our test programs are clean, -## so they should compile cleanly or the feature is not available. However, -## Autotools lacks a AC_TREAT_WARNINGS_AS_ERRORS-like macro or define. -## -## - Fix Autoconf using the wrong AR and ARFLAGS on platforms like OS X. Also -## see http://lists.gnu.org/archive/html/bug-autoconf/2017-11/msg00002.html. -## -## - Fix Autoconf not honoring LT_INIT. We are trying to enable PIC, static and -## shared by default but Autotools is ignoring [pic-only]. Also see -## https://stackoverflow.com/q/56215237/608639. -## -## - Fix Autoconf not using PIC/PIE for cryptest. The problem is bigger than the -## LT_INIT bug. There is no Uniform Name like bin_LTPROGRAMS to signal PIC/PIE -## should be used. Autoconf is guessing wrong and not using PIC/PIE. -## -## - Fix Autotools 'make dist' failures. If you run 'make dist' on x86_64, then -## the release tarball only works on x86_64. It is like it is pre-configured -## for only the x86_64 platform, and other platform code paths have been -## thrown away. WTF??? -## -## - Fix Autoconf ignoring our config.h.in. This one looks like it is a problem -## without a solution. Also see https://stackoverflow.com/q/48436715/608639. -## (Gave up after https://github.com/weidai11/cryptopp/commit/c51f0ecbfd21. -## Now we can write new config_asm.h, config_cxx.h, and config_misc.h.) -## -## - Figure out how to write new configuration information to config_asm.h, -## config_cxx.h, and config_misc.h. According to the Autoconf manual we -## can use multiple headers. However, it does not seem to work in -## practice. Also see https://stackoverflow.com/q/56193203/608639. -## -## - Stop using local.h, and write the config data into a Crypto++ compatible -## config.h. There's not much to "Crypto++ compatible config.h". We need test -## and write preprocessor macros like CRYPTOPP_BIG_ENDIAN, -## CRYPTOPP_LITTLE_ENDIAN, CRYPTOPP_CXX11, etc. There's just a lot of them. -## This problem now appears to be closely related to the config.h.in problem. -## We can't supply a template and expect Autotools to honor it. Also see -## https://lists.gnu.org/archive/html/autoconf/2018-07/msg00014.html. -## -## - Fix incorrect use of --with-sysroot. Autotools does not seem to honor it -## when it is set. Also see http://stackoverflow.com/q/47226389/608639. -## -## - Fix MSYS2 compile error due to `lt-cryptest.c` and `lt-cryptestcwd.c`. -## They are C files and don't use necessary C++ flags. They also use Posix -## functions but fail to define _XOPEN_SOURCE. I'm guessing this has something -## to do with libtool, but I have no idea how to fix it at the moment. Also -## see http://lists.gnu.org/archive/html/bug-libtool/2017-11/msg00002.html. -## -## - Fix the ARM 32-builds. Running 'cryptest v' results in -## "unexpected reloc type 0x03". GNUmakefile and CMake are OK. I've been -## working on it (on and off) for three days and no closer to finding a -## solution. Autotools is such a broken heaping pile of shit... Also see -## https://sourceware.org/ml/binutils/2019-05/msg00287.html -## -## - Fix static initialization order fiasco tests. We don't know how to craft -## the tests because we don't know how to compile two files at once using -## Autotools. Also see https://stackoverflow.com/q/51662985/608639. -## -## - Fix -xarch for SHA when using SunCC. We don't know the arch value at the -## moment. If things work as expected we will fail the feature test and the -## code paths will be disabled. But we want them enabled once Sun supports -## the SHA extensions. See https://stackoverflow.com/q/45872180/608639. -## -## - Fix LDFLAGS on AIX. Autotools is adding unwanted flags to LDFLAGS and it -## is causing a runtime crash in startup code. See -## https://stackoverflow.com/q/51680113/608639. -## -## - Add ubsan and asan targets for testing. -## -## - Setup test environment with Dash, which appears to be the lamest shell. -## -## - Package Autotools propery, for a regular user's definition of "proper". -## I don't know what the final deliverables or artifacts are supposed to -## look like. We also get warnings and errors due to a missing m4/ directory -## even though we don't use it. Maybe we need to distribute an empty m4/ -## directory to keep the tools quiet. - -############################################################################# - -## This configure.ac proceeds in five parts: -## -## 1. configure.ac preamble -## -## 2. compiler and host detection -## -## 3. configure options, like --disable-asm -## -## 4. CPU feature tests, like SSE, NEON, ARMv8, PowerPC -## -## 5. C++ feature tests, like C++11, alignof and alignas -## -## 6. Misc feature and options -## - -############################################################################# -## PART 1 PART 1 PART 1 PART 1 PART 1 PART 1 PART 1 PART 1 -## ========================================================================== -## configure.ac preamble -############################################################################# - -AC_INIT([Crypto++], [8.3], [http://www.cryptopp.com/wiki/Bug_Report], [cryptopp], [http://www.cryptopp.com]) -AC_CONFIG_SRCDIR([configure.ac]) -AC_CONFIG_HEADERS([local.h]) -AC_CONFIG_FILES([Makefile] [libcryptopp.pc]) -AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_MACRO_DIR([m4]) - -AM_INIT_AUTOMAKE - -AM_PROG_AS -AC_PROG_LIBTOOL - -AC_PROG_CXX -AC_LANG([C++]) -LT_LANG([C++]) - -# Programs we use -AC_PROG_SED -AC_PROG_AWK -AC_PROG_GREP -AC_PROG_EGREP - -# Detect build and host platforms -AC_CANONICAL_HOST -AC_CANONICAL_BUILD - -## Assert this once to avoid surprises -AC_LANG_ASSERT([C++]) - -############################################################################# - -## Our Autoconf tests are strict. We use custom AC_COMPILE_IFELSE and -## AC_LINK_IFELSE that rejects a feature test if there are any warnings or -## errors. We needed this because Autotools was mis-detecting features on -## AIX and Solarix using XLC and SunCC. We also needed the custom tests -## because Autoconf does not have a "warnings as errors" option that just -## works on all the compilers we support. - -AC_DEFUN([XXX_COMPILE_IFELSE], - [AC_COMPILE_IFELSE( - [$1], - [retval=0 - touch conftest.err - if test `cat conftest.err | wc -w` != "0"; then retval=1; fi - ],[retval=1] - ) - AS_IF([test $retval = 0],[$2],[$3])] -) - -AC_DEFUN([XXX_LINK_IFELSE], - [AC_LINK_IFELSE( - [$1], - [retval=0 - touch conftest.err - if test `cat conftest.err | wc -w` != "0"; then retval=1; fi - ],[retval=1] - ) - AS_IF([test $retval = 0],[$2],[$3])] -) - -############################################################################# -## PART 2 PART 2 PART 2 PART 2 PART 2 PART 2 PART 2 PART 2 -## ========================================================================== -## compiler and host detection -############################################################################# - -## These are some variables that help us track platform and compiler. -## It speeds up configuration by adding some intelligence to the -## test selection process. It also avoids failed configurations by -## avoiding some tests that fail but Autotools reports as success. - -IS_AIX_OS=`echo $build | $GREP -i -c 'aix'` -IS_SUN_OS=`uname -s | $GREP -i -c 'SunOS'` -IS_LINUX_OS=`echo "$build" | $GREP -i -c 'linux'` -IS_APPLE_OS=`echo "$build" | $EGREP -i -c 'apple|darwin'` -IS_ANDROID_OS=`echo $build | $GREP -i -c 'android'` -IS_CYGWIN_OS=`echo $build | $GREP -i -c 'cygwin'` -IS_MINGW_OS=`echo $build | $GREP -i -c 'mingw'` - -IS_IA32=`echo $build | $EGREP -i -c 'i.86|x86_64|amd64'` -IS_ARM32=`echo $build | $EGREP -i -c 'arm|armhf|arm7l|eabihf'` -IS_ARMV8=`echo $build | $EGREP -i -c 'aarch32|aarch64'` -IS_PPC=`echo $build | $EGREP -i -c 'ppc|powerpc|powermac'` -IS_SPARC=`echo $build | $EGREP -i -c 'sparc|sparcv8|sparcv9|sparc64'` - -## Debug builds add more goodies to help break things. I like breaking things. -IS_DEBUG=`echo $CPPFLAGS $CXXFLAGS | $GREP -i -c '\-DDEBUG'` - -############################################################################# - -## Determine the compiler's target. GCC '-dumpmachine' is the target, -## so it represents what the compiler is building for (and not what its -## running on). We add '2>/dev/null' because IBM's xlC dumps the man page -## when presented with '-dumpmachine' since it is not a valid option. - -## See if CXX is valid. Autotools just trucks on with an invalid one. - -if test x"$CXX" != "x"; then - COMPILER_VALID=`command -v "$CXX"` - if test x"$COMPILER_VALID" = "x"; then - AC_MSG_FAILURE(["$CXX" is not a valid compiler or is not on-path]) - fi -fi - -## Compiler is valid. Try to detect the target and vendor. -## SunCC is empty, so we just use $build - -COMPILER_TARGET=`"$CXX" "$CXXFLAGS" -dumpmachine 2>/dev/null` -if test x"$COMPILER_TARGET" = "x"; then - COMPILER_TARGET="$build" -fi - -## Determine the compiler's vendor. We need to work around some Autoconf bugs. - -COMPILER_VERSION=`"$CXX" --version 2>/dev/null | head -n 1` - -## IBM xlC test if COMPILER_VERSION is empty -if test x"$COMPILER_VERSION" = "x"; then - COMPILER_VERSION=`"$CXX" -qversion 2>/dev/null | head -n 1` -fi - -## SunCC test if COMPILER_VERSION is empty -if test x"$COMPILER_VERSION" = "x"; then - COMPILER_VERSION=`"$CXX" -V 2>&1 | head -n 1` -fi - -## Microsoft test if COMPILER_VERSION is empty -if test `basename "$CXX"` = "cl.exe"; then - COMPILER_VERSION=`"$CXX" /? 2>&1 | head -n 1` -fi - -IS_GCC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -v 'Clang' | $EGREP -i -c 'GCC|G\+\+'` -IS_MSC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -c 'Microsoft'` -IS_LLVM_COMPILER=`echo $COMPILER_VERSION | $EGREP -i -c 'LLVM|Clang'` -IS_SUN_COMPILER=`echo $COMPILER_VERSION | $EGREP -i -c 'Sun C'` -IS_ICC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -c 'ICC'` -IS_XLC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -c 'IBM XL'` -IS_PORTS_COMPILER=`echo $COMPILER_VERSION | $EGREP -i -c 'MacPorts|Homebrew'` - -## A catch-all for compilers that claim to be GCC compatible. Each should be -## able to handle GCC syntax. It excludes XLC, SunCC and MSVC -if test "$IS_GCC_COMPILER" != "0" || test "$IS_LLVM_COMPILER" != "0" || \ - test "$IS_ICC_COMPILER" != "0"; then - IS_GNUC_COMPILER=1 -else - IS_GNUC_COMPILER=0 -fi - -## Friendly names for reporting -CXXNAME=`basename "$CXX"` -LDNAME=`basename "$LD"` - -## Small fixup -case "$LDNAME" in - "ld "*) LDNAME=ld - ;; -esac - -############################################################################# -## PART 3 PART 3 PART 3 PART 3 PART 3 PART 3 PART 3 PART 3 -## ========================================================================== -## configure options, like --disable-asm -############################################################################# - -AC_ARG_ENABLE([pthreads], - AS_HELP_STRING([--disable-pthreads], [disable pthreads])) -AS_IF([test "x$enable_pthreads" = "xno"], [ - : # AC_DEFINE([CRYPTOPP_DISABLE_PTHREADS], [1], [disable pthreads]) -]) - -# Applies to all platforms -AC_ARG_ENABLE([asm], - AS_HELP_STRING([--disable-asm], [disable all ASM and intrinsics])) -AS_IF([test "x$enable_asm" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [disable all ASM and intrinsics]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASM" -]) - -# X86 defines -AC_ARG_ENABLE([sse2], - AS_HELP_STRING([--disable-sse2], [disable x86 SSE2 instructions])) -AS_IF([test "x$enable_sse2" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SSE2], [1], [disable x86 SSE2 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE2" -]) - -AC_ARG_ENABLE([sse3], - AS_HELP_STRING([--disable-sse3], [disable x86 SSE3 instructions])) -AS_IF([test "x$enable_sse3" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SSE3], [1], [disable x86 SSE3 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE3" -]) - -AC_ARG_ENABLE([ssse3], - AS_HELP_STRING([--disable-ssse3], [disable x86 SSSE3 instructions])) -AS_IF([test "x$enable_ssse3" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SSSE3], [1], [disable x86 SSSE3 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSSE3" -]) - -AC_ARG_ENABLE([sse4], - AS_HELP_STRING([--disable-sse4], [disable x86 SSE4.1 and SSE4.2 instructions])) -AS_IF([test "x$enable_sse4" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SSE4], [1], [disable x86 SSE4.1 and SSE4.2 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE4" -]) - -AC_ARG_ENABLE([clmul], - AS_HELP_STRING([--disable-clmul], [disable x86 CLMUL instructions])) -AS_IF([test "x$enable_clmul" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_CLMUL], [1], [disable x86 CLMUL instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_CLMUL" -]) - -AC_ARG_ENABLE([aes], - AS_HELP_STRING([--disable-aes], [disable x86 AES instructions])) -AS_IF([test "x$enable_aes" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_AES], [1], [disable x86 AES instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AES" -]) - -AC_ARG_ENABLE([sha], - AS_HELP_STRING([--disable-sha], [disable x86 SHA instructions])) -AS_IF([test "x$enable_sha" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA], [1], [disable x86 SHA instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA" -]) - -AC_ARG_ENABLE([avx], - AS_HELP_STRING([--disable-avx], [disable x86 AVX instructions])) -AS_IF([test "x$enable_avx" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_AVX], [1], [disable x86 AVX instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AVX" -]) - -AC_ARG_ENABLE([avx2], - AS_HELP_STRING([--disable-avx2], [disable x86 AVX2 instructions])) -AS_IF([test "x$enable_avx2" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_AVX2], [1], [disable x86 AVX2 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AVX2" -]) - -# ARM-32 defines -AC_ARG_ENABLE([armv7], - AS_HELP_STRING([--disable-armv7], [disable ARM ARMv7 instructions])) -AS_IF([test "x$enable_armv7" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_ARMV7], [1], [disable ARM ARMv7 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARMV7" -]) - -AC_ARG_ENABLE([neon], - AS_HELP_STRING([--disable-neon], [disable ARM NEON instructions])) -AS_IF([test "x$enable_neon" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_NEON], [1], [disable ARM NEON instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_NEON" -]) - -# ARMv8 defines -AC_ARG_ENABLE([asimd], - AS_HELP_STRING([--disable-asimd], [disable ARMv8 ASIMD instructions])) -AS_IF([test "x$enable_asimd" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_ASIMD], [1], [disable ARMv8 ASIMD instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASIMD" -]) - -AC_ARG_ENABLE([crc32], - AS_HELP_STRING([--disable-crc32], [disable ARMv8 CRC32 instructions])) -AS_IF([test "x$enable_crc32" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_CRC32], [1], [disable ARMv8 CRC32 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_CRC32" -]) - -AC_ARG_ENABLE([pmull], - AS_HELP_STRING([--disable-pmull], [disable ARMv8 PMULL instructions])) -AS_IF([test "x$enable_pmull" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_PMULL], [1], [disable ARMv8 PMULL instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_PMULL" -]) - -AC_ARG_ENABLE([aes], - AS_HELP_STRING([--disable-aes], [disable ARMv8 AES instructions])) -AS_IF([test "x$enable_aes" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_AES], [1], [disable ARMv8 AES instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AES" -]) - -AC_ARG_ENABLE([sha1], - AS_HELP_STRING([--disable-sha1], [disable ARMv8 SHA1 instructions])) -AS_IF([test "x$enable_sha1" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA1], [1], [disable ARMv8 SHA1 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA1" -]) - -AC_ARG_ENABLE([sha256], - AS_HELP_STRING([--disable-sha256], [disable ARMv8 SHA256 instructions])) -AS_IF([test "x$enable_sha256" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA256], [1], [disable ARMv8 SHA256 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA256" -]) - -AC_ARG_ENABLE([sha512], - AS_HELP_STRING([--disable-sha512], [disable ARMv8 SHA512 instructions])) -AS_IF([test "x$enable_sha512" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA512], [1], [disable ARMv8 SHA512 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA512" -]) - -AC_ARG_ENABLE([sha3], - AS_HELP_STRING([--disable-sha3], [disable ARMv8 SHA3 instructions])) -AS_IF([test "x$enable_sha3" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA3], [1], [disable ARMv8 SHA3 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA3" -]) - -AC_ARG_ENABLE([sm3], - AS_HELP_STRING([--disable-sm3], [disable ARMv8 SM3 instructions])) -AS_IF([test "x$enable_sm3" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SM3], [1], [disable ARMv8 SM3 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SM3" -]) - -AC_ARG_ENABLE([sm4], - AS_HELP_STRING([--disable-sm4], [disable ARMv8 SM4 instructions])) -AS_IF([test "x$enable_sm4" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SM4], [1], [disable ARMv8 SM4 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SM4" -]) - -# PPC defines -AC_ARG_ENABLE([altivec], - AS_HELP_STRING([--disable-altivec], [disable PPC Altivec instructions])) -AS_IF([test "x$enable_altivec" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_ALTIVEC], [1], [disable PPC Altivec instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ALTIVEC" -]) - -AC_ARG_ENABLE([aes], - AS_HELP_STRING([--disable-aes], [disable PPC AES instructions])) -AS_IF([test "x$enable_aes" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_AES], [1], [disable PPC AES instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AES" -]) - -AC_ARG_ENABLE([vmull], - AS_HELP_STRING([--disable-vmull], [disable PPC VMULL instructions])) -AS_IF([test "x$enable_vmull" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_VMULL], [1], [disable PPC VMULL instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_VMULL" -]) - -AC_ARG_ENABLE([sha256], - AS_HELP_STRING([--disable-sha256], [disable PPC SHA256 instructions])) -AS_IF([test "x$enable_sha256" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA256], [1], [disable PPC SHA256 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA256" -]) - -AC_ARG_ENABLE([sha512], - AS_HELP_STRING([--disable-sha512], [disable PPC SHA512 instructions])) -AS_IF([test "x$enable_sha512" = "xno"], [ - AC_DEFINE([CRYPTOPP_DISABLE_SHA512], [1], [disable PPC SHA512 instructions]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHA512" -]) - -############################################################################# -## PART 4 PART 4 PART 4 PART 4 PART 4 PART 4 PART 4 PART 4 -## ========================================================================== -## CPU feature tests, like SSE, NEON, ARMv8, PowerPC -############################################################################# - -############################################################################# -## Die early on Android - -if test "$IS_ANDROID_OS" != "0"; then - - AC_MSG_CHECKING([if ANDROID_NDK_ROOT is set]) - if test x"$ANDROID_NDK_ROOT" != "x"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - AC_MSG_ERROR([ANDROID_NDK_ROOT is not set. Please set ANDROID_NDK_ROOT]) - fi -fi - -############################################################################# -## Doxygen documentation -## This only provides a 'make html-doc' recipe in the Makefile. -## If Doxygen is available the user still must issue the command. - -AC_CHECK_PROGS([DOXYGEN], [doxygen]) -if test x"$DOXYGEN" = "x"; then - AM_CONDITIONAL([CRYPTOPP_DOXYGEN_AVAILABLE], [false]) -else - AM_CONDITIONAL([CRYPTOPP_DOXYGEN_AVAILABLE], [true]) -fi - -############################################################################# -## Shared and static libraries - -if true; then - - ## Cant use AC_ENABLE_STATIC and AC_ENABLE_SHARED. AIX Autotools is too old. - AC_MSG_RESULT([checking if static libraries should be enabled... yes]) - - ## http://stackoverflow.com/a/21455267/608639 - case $host_os in - msys* | mingw* | cygwin* ) - AC_MSG_RESULT([checking if shared libraries should be enabled... no]) - enable_shared=no; enable_static=yes; - ;; - *) - AC_MSG_RESULT([checking if shared libraries should be enabled... yes]) - enable_shared=yes; enable_static=yes; - ;; - esac -fi - -############################################################################# -## Pthread library - -if true; then - - ## Add to both CXXFLAGS and LDFLAGS if supported. - ## https://stackoverflow.com/q/2127797/608639. - - SAVED_CXXFLAGS="$CXXFLAGS" - SAVED_LDFLAGS="$LDFLAGS" - - CXXFLAGS="-pthread" - LDFLAGS="-pthread" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - LDFLAGS="$SAVED_LDFLAGS" - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Init priorities - -## The tests below should be in two separate source file violating -## init order. One object file should perform the Foo or Bar static -## init, and the second source would have a static object using -## Foo::s_x or Bar::s_x. The problem is, we don't know how to do it. -## Also see https://stackoverflow.com/q/51662985/608639. - -## We can only run one Init Priority test. Otherwise, running both tests -## cause 'CRYPTOPP_INIT_PRIORITY 250' and 'CRYPTOPP_INIT_PRIORITY 0' to be -## written, which results in "warning: CRYPTOPP_INIT_PRIORITY redefined". -## And of course, Autools does not allow us to undefine a macro. - -## GCC-style -if true; then - - SAVED_CXXFLAGS="$CXXFLAGS" - - ## -Wall -Werror are GCC and friends specific. The problem is, - ## Autotools lacks a cross-platform AC_TREAT_WARNINGS_AS_ERRORS. - if test "$IS_MSC_COMPILER" = "0"; then - THIS_CXXFLAGS="-Wall -Werror" - fi - - CXXFLAGS="$THIS_CXXFLAGS" - XXX_PROGRAM="#include - struct Foo { - Foo(int x) : m_x(x) {} - Foo(const Foo& o) : m_x(o.m_x) {} - Foo& operator=(const Foo& o) {m_x=o.m_x; return *this;} - static int s_x; - int m_x; - }; - int Foo::s_x = -1; - static Foo unused __attribute__ ((init_priority (250))) = Foo::s_x; - // This should be in a separate source file violating init order. - // The separate file should have a main() and be linked first. - // static Foo f = Foo::s_x; - // bool success = f.m_x == -1;" - - AC_MSG_CHECKING([if $CXXNAME supports init_priority]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([$XXX_PROGRAM])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([HAVE_GCC_INIT_PRIORITY], [1]) - AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [250], [Enable init_priority]) - else - AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [0], [Disable init_priority]) - fi - - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -## MSC-style -if false; then - - ## The problem is, Autotools lacks a cross-platform - ## AC_TREAT_WARNINGS_AS_ERRORS. Clang, GCC, and friends will see - ## "pragma init_seg" and issue an an unknown pragma warning. - ## Adding -Wall or -Werror will cause MSC and friends to fail on - ## the illegal flag. - if test "$IS_MSC_COMPILER" = "1"; then - THIS_CXXFLAGS="/WX" - else - THIS_CXXFLAGS="-Wall -Werror" - fi - - CXXFLAGS="$THIS_CXXFLAGS" - XXX_PROGRAM="#include - struct Bar { - Bar(int x) : m_x(x) {} - Bar(const Bar& o) : m_x(o.m_x) {} - Bar& operator=(const Bar& o) {m_x=o.m_x; return *this;} - static int s_x; - int m_x; - }; - #pragma init_seg(".CRT$XCU") - int Bar::s_x = -1; - static Bar unused __attribute__ ((init_priority (250))) = Bar::s_x; - // This should be in a separate source file violating init order. - // The separate file should have a main() and be linked first. - // static Bar b = Bar::s_x; - // bool success = b.m_x == -1;" - - AC_MSG_CHECKING([if $CXXNAME supports init_seg]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([$XXX_PROGRAM])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([HAVE_MSC_INIT_PRIORITY], [1]) - AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [250], [Enable init_seg]) - else - AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [0], [Disable init_seg]) - fi - - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Solaris, SunCC and missing optimizations - -OPT_ANY=`echo $CXXFLAGS | $EGREP -c '\-O0|\-O1|\-O2|\-O3|\-O4|\-O5|\-xO0|\-xO1|\-xO2|\-xO3|\-xO4|\-xO5|\-Os|\-Og|\-Ofast'` - -if test "$OPT_ANY" = "0"; then - - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-O2" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - else - - # SunCC - CXXFLAGS="-xO2" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - fi - - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Fix AR on iOS and OS X - -## AR and ARFLAGS usage is currently broke under Autotools. Also see -## http://lists.gnu.org/archive/html/bug-autoconf/2017-11/msg00002.html - -#if test "$IS_APPLE_OS" != "0"; then -# AC_SUBST([AR], ["/usr/bin/libtool"]) -# AC_SUBST([ARFLAGS], ["-static -o"]) -# AC_SUBST([ac_ct_AR], ["/usr/bin/libtool"]) -#fi - -############################################################################# -## Dead code stripping for compilers. Linkers are towards the end of script. -## We have to use XXX_LINK_IFELSE because some compilers don't reject -## -fdata-sections or -ffunction-sections like they should. - -if true; then - - ## Save FLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-fdata-sections" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - CXXFLAGS="-ffunction-sections" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - ## Restore FLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Solaris, GCC and -Wa,--divide - -if test "$IS_SUN_OS" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-Wa,--divide" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Solaris, SunCC compiler options - -if test "$IS_SUN_OS" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-template=no%extdef" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - # https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html - CXXFLAGS="-xregs=no%appl" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## AIX and -qpic=large or -bbigtoc - -if test "$IS_AIX" != "0"; then - - ## Save LDFLAGS - SAVED_LDFLAGS="$LDFLAGS" - - # https://www.ibm.com/developerworks/rational/library/overview-toc-aix/index.html - LDFLAGS="-bbigtoc" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - ## Restore LDFLAGS - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## MacPorts GCC using Clang integrated assembler - -## Modern GCC must use Clang as the assembler. The old Apple -## assembler cannot handle much more than SSE4 or so. We need -## to use -Wa,-q in subsequent tests, if available. - -if test "$IS_APPLE_OS" != "0"; then -if test "$IS_GCC_COMPILER" != "0" && test "$IS_PORTS_COMPILER" != "0"; then - - HAVE_OPT=`echo $CXXFLAGS | $EGREP -i -c '\-Wa,-q'` - if test "$HAVE_OPT" = "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-Wa,-q" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - # We can add -Wa,-q to all files, if needed - if test "$retval" = "0"; then - # AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - WAQ_FLAG="-Wa,-q" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" - fi -fi -fi - -############################################################################# -## Clang integrated assembler and SunCC. - -## Also see https://bugs.llvm.org/show_bug.cgi?id=39895. -if test "$IS_IA32" = "1" && test "x$enable_asm" != "xno"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-msse2 $WAQ_FLAG" - AC_MSG_CHECKING([if $CXXNAME supports mixed ASM]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_asm_mixed.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" != "0"; then - AC_DEFINE([CRYPTOPP_DISABLE_MIXED_ASM], [1], [Disable mixed asm]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_MIXED_ASM" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## IA-32, i386, i586, i686, x86_64, etc. - -## This block handles GCC and friends, including -Wa,-q if needed. -## i86pc and SunCC is handled after this block. -if test "$IS_IA32" = "1" && test "$IS_GNUC_COMPILER" = "1"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - ##### SSE2 ##### - - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-msse2 $WAQ_FLAG" - else - CXXFLAGS="-msse2" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse2.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SSE2_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_DONNA_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_SSE2_AVAILABLE], [1], [Enable SSE2]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [Disable SSE2]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASM" - fi - - ##### SSE3 ##### - - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-msse3 $WAQ_FLAG" - else - CXXFLAGS="-msse3" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_DEFINE([CRYPTOPP_SSE3_AVAILABLE], [1], [Enable SSE3]) - else - AC_DEFINE([CRYPTOPP_DISABLE_SSE3], [1], [Disable SSE3]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE3" - fi - - ##### SSSE3 ##### - - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-mssse3 $WAQ_FLAG" - else - CXXFLAGS="-mssse3" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_ssse3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SSSE3_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_ARIA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHAM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_KECCAK_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_LEA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SIMON128_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SPECK128_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_SSSE3_AVAILABLE], [1], [Enable SSSE3]) - else - AC_DEFINE([CRYPTOPP_DISABLE_SSSE3], [1], [Disable SSSE3]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSSE3" - fi - - ##### SSE4.1 ##### - - ## Old BSD linkers don't support SSE4 or above. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-msse4.1 $WAQ_FLAG" - else - CXXFLAGS="-msse4.1" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse41.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SSE41_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2S_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2B_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_SSE41_AVAILABLE], [1], [Enable SSE4.1]) - else - AC_DEFINE([CRYPTOPP_DISABLE_SSE4], [1], [Disable SSE4.1]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE4" - fi - - ##### SSE4.2 ##### - - ## Old BSD linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-msse4.2 $WAQ_FLAG" - else - CXXFLAGS="-msse4.2" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse42.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SSE42_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CRC_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_SSE42_AVAILABLE], [1], [Enable SSE4.2]) - else - AC_DEFINE([CRYPTOPP_DISABLE_SSE4], [1], [Disable SSE4.2]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE4" - fi - - ##### PCLMUL ##### - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-mpclmul $WAQ_FLAG" - else - CXXFLAGS="-mpclmul" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_clmul.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - # if -mpclmul fails then it is disabled in the next test - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_GF2N_FLAG], [$CXXFLAGS]) - fi - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-mssse3 -mpclmul $WAQ_FLAG" - else - CXXFLAGS="-mssse3 -mpclmul" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_clmul.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_GCM_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_CLMUL_AVAILABLE], [1], [Enable CLMUL]) - else - AC_DEFINE([CRYPTOPP_DISABLE_CLMUL], [1], [Disable CLMUL]) - fi - - ##### SSSE3+AES ##### - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-mssse3 -maes $WAQ_FLAG" - else - CXXFLAGS="-mssse3 -maes" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_aes.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - # if -maes fails then it is disabled in the next test - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SM4_FLAG], [$CXXFLAGS]) - fi - - ##### SSE4.1+AES ##### - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-msse4.1 -maes $WAQ_FLAG" - else - CXXFLAGS="-msse4.1 -maes" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_aes.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_AES_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_AESNI_AVAILABLE], [1], [Enable AESNI]) - else - AC_DEFINE([CRYPTOPP_DISABLE_AESNI], [1], [Disable AESNI]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AESNI" - fi - - ##### AVX ##### - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-mavx $WAQ_FLAG" - else - CXXFLAGS="-mavx" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_avx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_CHACHA_AVX_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_AVX_AVAILABLE], [1], [Enable AVX]) - else - AC_DEFINE([CRYPTOPP_DISABLE_AVX], [1], [Disable AVX]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AVX" - fi - - ##### AVX2 ##### - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-mavx2 $WAQ_FLAG" - else - CXXFLAGS="-mavx2" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_avx2.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_CHACHA_AVX2_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_AVX2_AVAILABLE], [1], [Enable AVX2]) - else - AC_DEFINE([CRYPTOPP_DISABLE_AVX2], [1], [Disable AVX2]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AVX2" - fi - - ##### SHA ##### - - ## Some old compilers, assemblers and linkers don't support it. - if test x"$WAQ_FLAG" != "x"; then - CXXFLAGS="-msse4.2 -msha $WAQ_FLAG" - else - CXXFLAGS="-msse4.2 -msha" - fi - - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sha.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_SHANI_AVAILABLE], [1], [Enable SHANI]) - else - AC_DEFINE([CRYPTOPP_DISABLE_SHANI], [1], [Disable SHANI]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHANI" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -## This block handles i86pc and SunCC. GCC and friends were handled before this block -if test "$IS_IA32" != "0" && test "$IS_SUN_COMPILER" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - ##### SSE2 ##### - - CXXFLAGS="-xarch=sse2" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse2.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - ## GCM AES and SHA should be overwritten with CLMUL, AES and SHA if available. - ## If not available then need -xarch=sse2 due to SSE2, GCM_Xor16_SSE2, etc. - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__SSE2__=1" - AC_SUBST([CRYPTOPP_SSE2_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_GCM_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_AES_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_SSE2_AVAILABLE], [1], [Enable SSE2]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [Disable SSE2]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASM" - fi - - ##### SSE3 ##### - - ## Nothing pivots around SSE3 specifically, but we do use - ## insns from the ISA. Sun requires it as a linker flag. - CXXFLAGS="-xarch=sse3" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__SSE3__=1" - AC_DEFINE([CRYPTOPP_SSE3_AVAILABLE], [1], [Enable SSE3]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_SSE3], [1], [Disable SSE3]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE3" - fi - - ##### SSSE3 ##### - - CXXFLAGS="-xarch=ssse3" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_ssse3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__SSSE3__=1" - AC_SUBST([CRYPTOPP_SSSE3_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_ARIA_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_CHAM_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_KECCAK_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_LEA_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_SIMON128_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_SPECK128_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_SSSE3_AVAILABLE], [1], [Enable SSSE3]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_SSSE3], [1], [Disable SSSE3]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSSE3" - fi - - ##### SSE4.1 ##### - - CXXFLAGS="-xarch=sse4_1" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse41.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__SSE4_1__=1" - AC_SUBST([CRYPTOPP_SSE41_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_SSE41_AVAILABLE], [1], [Enable SSE4.1]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_SSE4], [1], [Disable SSE4.1]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE4" - fi - - ##### SSE4.2 ##### - - CXXFLAGS="-xarch=sse4_2" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse42.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__SSE4_2__=1" - AC_SUBST([CRYPTOPP_SSE42_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_CRC_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_BLAKE2S_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_BLAKE2B_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_SSE42_AVAILABLE], [1], [Enable SSE4.2]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_SSE4], [1], [Disable SSE4.2]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SSE4" - fi - - ##### CLMUL ##### - - CXXFLAGS="-xarch=aes" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_clmul.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__CLMUL__=1" - AC_SUBST([CRYPTOPP_GCM_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_GF2N_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_CLMUL_AVAILABLE], [1], "Enable CLMUL") - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_CLMUL], [1], "Disable CLMUL") - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_CLMUL" - fi - - ##### AES ##### - - CXXFLAGS="-xarch=aes" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_aes.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__AES__=1" - AC_SUBST([CRYPTOPP_AES_FLAG], [$CXXFLAGSX]) - AC_SUBST([CRYPTOPP_SM4_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_AESNI_AVAILABLE], [1], "Enable AESNI") - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_AESNI], [1], "Disable AESNI") - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AESNI" - fi - - ##### AVX ##### - - CXXFLAGS="-xarch=avx" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_avx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__AVX__=1" - AC_DEFINE([CRYPTOPP_AVX_AVAILABLE], [1], [Enable AVX]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_AVX], [1], [Disable AVX]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AVX" - fi - - ##### AVX2 ##### - - CXXFLAGS="-xarch=avx2" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_avx2.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__AVX2__=1" - AC_SUBST([CRYPTOPP_CHACHA_AVX2_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_AVX2_AVAILABLE], [1], [Enable AVX2]) - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_AVX2], [1], [Disable AVX2]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_AVX2" - fi - - ##### RDRAND ##### - - ## https://docs.oracle.com/cd/E77782_01/html/E77792/gqexw.html - CXXFLAGS="-xarch=avx_i" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_rdrand.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - ## It is not clear if we can avoid the linker option for Solaris - ## Also see https://stackoverflow.com/q/51678753/608639 - #if test "$retval" = "0"; then - # CXXFLAGSX="$CXXFLAGS -D__RDRND__=1" - # AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - #fi - - ##### RDSEED ##### - - ## https://docs.oracle.com/cd/E60778_01/html/E60745/bjapr.html - CXXFLAGS="-xarch=avx2_i" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_rdseed.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - ## It is not clear if we can avoid the linker option for Solaris - ## Also see https://stackoverflow.com/q/51678753/608639 - #if test "$retval" = "0"; then - # CXXFLAGSX="$CXXFLAGS -D__RDSEED__=1" - # AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - #fi - - ##### SHA ##### - - ##CXXFLAGS="-xarch=avx2_i" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_x86_sha.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - CXXFLAGSX="$CXXFLAGS -D__SHA__=1" - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGSX]) - AC_DEFINE([CRYPTOPP_SHA_AVAILABLE], [1], "Enable SHANI") - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - else - AC_DEFINE([CRYPTOPP_DISABLE_SHANI], [1], "Disable SHANI") - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_SHANI" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## ARM A-32, including NEON, soft floats and hard floats - -if test "$IS_ARM32" != "0" || test "$IS_ARMV8" != "0"; then - - # https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html - - AC_CHECK_HEADERS(arm_neon.h, - [AC_DEFINE([CRYPTOPP_ARM_NEON_HEADER], [1], [arm_neon.h is available])], - [AC_DEFINE([CRYPTOPP_ARM_NEON_HEADER], [0], [arm_neon.h is not available])] - ) -fi - -if test "$IS_ARM32" != "0" && test "$IS_ANDROID_OS" = "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-march=armv7-a" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - CXXFLAGS="-march=armv7-a -mfpu=neon" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_neon.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_AES_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_ARIA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2S_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2B_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHAM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CRC_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_GCM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_LEA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_NEON_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SM4_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SIMON128_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SPECK64_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SPECK128_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_NEON_AVAILABLE], [1], [Enable NEON]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [Disbale NEON]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASM" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Android and -mfloat-abi=softfp - -if test "$IS_ARM32" != "0" && test "$IS_ANDROID_OS" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_neon.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_AES_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_ARIA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2S_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2B_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHAM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CRC_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_GCM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_LEA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_NEON_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SM4_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SIMON128_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SPECK128_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_NEON_AVAILABLE], [1], [Enable NEON]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [Disbale NEON]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASM" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" - -fi - -############################################################################# -## ARM A-32 and aes_armv4.S - -# Used by Makefile.am to compile aes_armv4.S and sha1_armv4.S. -# Only valid on Linux because ASM is written for GNU AS (GAS). -if test "$IS_ARM32" != "0" && test "$IS_LINUX_OS" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-march=armv7-a -Wa,--noexecstack" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CONDITIONAL([CRYPTOGAMS_ARM_SOURCES], [true]) - AC_SUBST([CRYPTOPGAMS_ARMV4_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPGAMS_ARMV4_THUMB_FLAG], [$CXXFLAGS]) - fi - - # For Clang, aes_armv4.S needs -mthumb - if test "$IS_LLVM_COMPILER" != "0"; then - - CXXFLAGS="-march=armv7-a -mthumb -Wa,--noexecstack" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPGAMS_ARMV4_THUMB_FLAG], [$CXXFLAGS]) - fi - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -else - # Required for other platforms - AM_CONDITIONAL([CRYPTOGAMS_ARM_SOURCES], [false]) -fi - -############################################################################# -## ARM Aarch32 and Aarch64 - -if test "$IS_ARMV8" != "0"; then - - # https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html - - AC_CHECK_HEADERS(arm_acle.h, - [AC_DEFINE([CRYPTOPP_ARM_ACLE_HEADER], [1], [arm_acle.h is available])], - [AC_DEFINE([CRYPTOPP_ARM_ACLE_HEADER], [0], [arm_acle.h is not available])] - ) - -fi - -if test "$IS_ARMV8" != "0"; then - - # https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-march=armv8-a" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_asimd.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_ARIA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_CHAM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2S_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_BLAKE2B_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_LEA_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_NEON_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SIMON128_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_SPECK128_FLAG], [$CXXFLAGS]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [Enable NEON]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ASM" - fi - - CXXFLAGS="-mfix-cortex-a53-835769" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - CXXFLAGS="-mfix-cortex-a53-843419" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $CXXFLAGS" - fi - - CXXFLAGS="-march=armv8-a+crc" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_crc.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_CRC_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_CRC32_AVAILABLE], [1], [Enable ARMv8 CRC32]) - else - AC_DEFINE([CRYPTOPP_DISABLE_CRC32], [1], [Disable ARMv8 CRC32]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_CRC32" - fi - - CXXFLAGS="-march=armv8-a+crypto" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (AES)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_aes.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_AES_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_AES_AVAILABLE], [1], [Enable ARMv8 AES]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ARM_AES], [1], [Disable ARMv8 AES]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_AES" - fi - - CXXFLAGS="-march=armv8-a+crypto" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (PMULL)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_pmull.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_GCM_FLAG], [$CXXFLAGS]) - AC_SUBST([CRYPTOPP_GF2N_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_PMULL_AVAILABLE], [1], [Enable ARMv8 PMULL]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ARM_PMULL], [1], [Disable ARMv8 PMULL]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_PMULL" - fi - - CXXFLAGS="-march=armv8-a+crypto" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (SHA1)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_sha1.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_SHA1_AVAILABLE], [1], [Enable ARMv8 SHA1]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA], [1], [Disable ARMv8 SHA1]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_SHA" - fi - - CXXFLAGS="-march=armv8-a+crypto" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (SHA256)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_sha256.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SHA_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_SHA256_AVAILABLE], [256], [Enable ARMv8 SHA256]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA], [256], [Disable ARMv8 SHA256]) - AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_SHA" - fi - - CXXFLAGS="-march=armv8.3-a+sha3" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (SHA512)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_sha3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SHA512_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_SHA512_AVAILABLE], [1], [Enable ARMv8 SHA512]) - #else - #AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA512], [1], [Disable ARMv8 SHA512]) - #AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_SHA512" - fi - - CXXFLAGS="-march=armv8.3-a+sha3" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (SHA3)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_sha3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SHA3_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_SHA3_AVAILABLE], [1], [Enable ARMv8 SHA3]) - #else - #AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA3], [1], [Disable ARMv8 SHA3]) - #AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_SHA3" - fi - - CXXFLAGS="-march=armv8.3-a+sm4" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (SM3)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_sm3.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SM3_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_SM3_AVAILABLE], [1], [Enable ARMv8 SM3]) - #else - #AC_DEFINE([CRYPTOPP_DISABLE_ARM_SM3], [1], [Disable ARMv8 SM3]) - #AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_SM3" - fi - - CXXFLAGS="-march=armv8.3-a+sm4" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS (SM4)]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_arm_sm4.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_SM4_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_SM4_AVAILABLE], [1], [Enable ARMv8 SM4]) - #else - #AC_DEFINE([CRYPTOPP_DISABLE_ARM_SM4], [1], [Disable ARMv8 SM4]) - #AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_SM4" - fi - - CXXFLAGS="-march=armv8.3-a+rng" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([CRYPTOPP_ARM_RNG_FLAG], [$CXXFLAGS]) - AC_DEFINE([CRYPTOPP_ARM_RNG_AVAILABLE], [1], [Enable ARMv8 RNG]) - #else - #AC_DEFINE([CRYPTOPP_DISABLE_ARM_RNG], [1], [Disable ARMv8 RNG]) - #AM_CXXFLAGS="$AM_CXXFLAGS -DCRYPTOPP_DISABLE_ARM_RNG" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## IBC XL C/C++ compiler, applies to IA-32 and PPC - -if test "$IS_XLC_COMPILER" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - ## -qrtti must be present for some xlC compilers - HAS_RTTI=`echo $CPPFLAGS $CXXFLAGS | $EGREP -i -c '\-qrtti'` - if test "$HAS_RTTI" = "0"; then - - CXXFLAGS="-qrtti" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - fi - - ## -qpic must be present for some xlC compilers - HAS_PIC=`echo $CPPFLAGS $CXXFLAGS | $GREP -i -c '\-qpic'` - if test "$HAS_PIC" = "0"; then - - CXXFLAGS="-qpic" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - fi - - # Promotes optimizations - CXXFLAGS="-qmaxmem=-1" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - # Promotes optimizations - CXXFLAGS="-qthreaded" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - if test "$IS_DEBUG" != "0"; then - - # Finds alias violations - CXXFLAGS="-qalias=noansi" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -# More stupid LLVM games. Clang pretending to be three different compilers. -# https://lists.tetaneutral.net/pipermail/cfarm-users/2018-July/000331.html - -if test "$IS_XLC_COMPILER" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-qxlcompatmacros" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" - -fi - -############################################################################# -## PowerPC and PowerPC-64 - -if test "$IS_PPC" != "0"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - # XLC requires -qaltivec in addition to Arch or CPU option - if test "$IS_XLC_COMPILER" = "1"; then - ALTIVEC_FLAG="-qarch=auto -qaltivec" - POWER7_VSX_FLAG="-qarch=pwr7 -qvsx -qaltivec" - POWER7_PWR_FLAG="-qarch=pwr7 -qaltivec" - POWER8_FLAG="-qarch=pwr8 -qaltivec" - POWER9_FLAG="-qarch=pwr9 -qaltivec" - else - ALTIVEC_FLAG="-maltivec" - POWER7_VSX_FLAG="-mcpu=power7 -mvsx" - POWER7_PWR_FLAG="-mcpu=power7" - POWER8_FLAG="-mcpu=power8" - POWER9_FLAG="-mcpu=power9" - fi - - ##### Altivec ##### - - CXXFLAGS="$ALTIVEC_FLAG" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_ppc_altivec.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - # Assume success, unset on failure - if test "$retval" != "0"; then - AC_SUBST([ALTIVEC_FLAG],[""]) - fi - - ##### POWER7 ##### - - CXXFLAGS="$POWER7_VSX_FLAG" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_ppc_power7.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - # Figure out what is needed for POWER7 - if test "$retval" = "0"; then - AC_SUBST([POWER7_FLAG],[$POWER7_VSX_FLAG]) - else - CXXFLAGS="$POWER7_PWR_FLAG" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_ppc_power7.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_SUBST([POWER7_FLAG],[$POWER7_PWR_FLAG]) - else - AC_SUBST([POWER7_FLAG],[""]) - fi # POWER7_PWR_FLAG - fi # POWER7_VSX_FLAG - - ##### POWER8 ##### - - CXXFLAGS="$POWER8_FLAG" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_ppc_power8.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" != "0"; then - AC_SUBST([POWER8_FLAG],[""]) - fi - - ##### POWER9 ##### - - CXXFLAGS="$POWER9_FLAG" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_ppc_power9.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" != "0"; then - AC_SUBST([POWER9_FLAG],[""]) - fi - - # POWER9 and DARN random number generator. Disabled due to - # https://github.com/weidai11/cryptopp/issues/986 - #if test x"$POWER9_FLAG" != "x"; then - # AC_SUBST([CRYPTOPP_POWER9_FLAG], [$POWER9_FLAG]) - # AC_SUBST([CRYPTOPP_DARN_FLAG], [$POWER9_FLAG]) - #else - # AC_DEFINE([CRYPTOPP_DISABLE_POWER9], [1], [Disable POWER9]) - #fi - - ##### Fixups ##### - - ## POWER8 and in-core crypto. - if test x"$POWER8_FLAG" != "x"; then - AC_SUBST([CRYPTOPP_POWER8_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_BLAKE2B_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_CRC_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_AES_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_GCM_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_GF2N_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_SHA_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_SIMON128_FLAG], [$POWER8_FLAG]) - AC_SUBST([CRYPTOPP_SPECK128_FLAG], [$POWER8_FLAG]) - AC_DEFINE([CRYPTOPP_POWER8_CRC_AVAILABLE], [1], [Enable POWER8 CRC]) - AC_DEFINE([CRYPTOPP_POWER8_AES_AVAILABLE], [1], [Enable POWER8 AES]) - AC_DEFINE([CRYPTOPP_POWER8_PMULL_AVAILABLE], [1], [Enable POWER8 PMULL]) - AC_DEFINE([CRYPTOPP_POWER8_SHA_AVAILABLE], [1], [Enable POWER8 SHA]) - else - AC_DEFINE([CRYPTOPP_DISABLE_POWER8], [1], [Disable POWER8]) - fi - - # POWER7 and VSX - if test x"$POWER7_FLAG" != "x"; then - AC_SUBST([CRYPTOPP_POWER7_FLAG], [$POWER7_FLAG]) - AC_DEFINE([CRYPTOPP_POWER7_AVAILABLE], [1], [Enable POWER7]) - else - AC_DEFINE([CRYPTOPP_DISABLE_POWER7], [1], [Disable POWER7]) - fi - - # Plain old Altivec - if test x"$ALTIVEC_FLAG" != "x"; then - AC_SUBST([CRYPTOPP_ALTIVEC_FLAG], [$ALTIVEC_FLAG]) - AC_SUBST([CRYPTOPP_BLAKE2S_FLAG], [$ALTIVEC_FLAG]) - AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$ALTIVEC_FLAG]) - AC_DEFINE([CRYPTOPP_ALTIVEC_AVAILABLE], [1], [Enable Altivec]) - else - AC_DEFINE([CRYPTOPP_DISABLE_ALTIVEC], [1], [Disable Altivec]) - fi - - # Drop to Altivec if higher Power is not available - if test x"$ALTIVEC_FLAG" != "x"; then - if test x"$CRYPTOPP_GCM_FLAG" = "x"; then - AC_SUBST([CRYPTOPP_GCM_FLAG], [$ALTIVEC_FLAG]) - fi - fi - - # Now set a disable flag - if test x"$ALTIVEC_FLAG" = "x"; then - AM_CXXFLAGS="-DCRYPTOPP_DISABLE_ALTIVEC $AM_CXXFLAGS" - elif test x"$POWER7_FLAG" = "x"; then - AM_CXXFLAGS="-DCRYPTOPP_DISABLE_POWER7 $AM_CXXFLAGS" - elif test x"$POWER8_FLAG" = "x"; then - AM_CXXFLAGS="-DCRYPTOPP_DISABLE_POWER8 $AM_CXXFLAGS" - elif test x"$POWER9_FLAG" = "x"; then - AM_CXXFLAGS="-DCRYPTOPP_DISABLE_POWER9 $AM_CXXFLAGS" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## PART 5 PART 5 PART 5 PART 5 PART 5 PART 5 PART 5 PART 5 -## ========================================================================== -## C++ feature tests, like C++11, alignof and alignas -############################################################################# - -############################################################################# -## Newlib and _XOPEN_SOURCE - -if true; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - ## This test may need to be changed if the Newlib folks provide directions. - ## Also see http://www.sourceware.org/ml/newlib/2017/msg01095.html. - - AC_MSG_CHECKING([whether runtime library is Newlib]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_newlib.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - - CXXFLAGS="-D_XOPEN_SOURCE=600" - AC_MSG_CHECKING([if runtime library supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_DEFINE([_XOPEN_SOURCE], [600], [Enable _XOPEN_SOURCE]) - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## libstdc++ and _GLIBCXX_DEBUG -if test "$IS_DEBUG" = "1"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - AC_MSG_CHECKING([whether runtime library is libstdc++]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_glibc.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - - CXXFLAGS="-D_GLIBCXX_DEBUG" - AC_MSG_CHECKING([if runtime library supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Now test C++ features - -#AH_HEADER= -#AC_CONFIG_COMMANDS_PRE( -# [m4_ifndef([AH_HEADER], [AC_CONFIG_HEADERS([config_cxx.h])]) -#]) - -############################################################################# - -if true; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - AC_MSG_CHECKING([whether runtime library is C++11]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx11.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_DEFINE([CRYPTOPP_CXX11], [1], [C++11 is available]) - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -if true; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - AC_MSG_CHECKING([whether runtime library is C++17]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([`cat TestPrograms/test_cxx17.cxx`])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AC_DEFINE([CRYPTOPP_CXX17], [1], [C++17 is available]) - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## PART 6 PART 6 PART 6 PART 6 PART 6 PART 6 PART 6 PART 6 -## ========================================================================== -## Misc feature and options -############################################################################# - -############################################################################# -## Add -pipe for non-IoT gadgets to speedup compiles. We use 2GB RAM as -## threshold. Anything with less than 2GB will not use -pipe. - -# Unix, Linux and family -MEM_SIZE=`$GREP "MemTotal" /proc/meminfo 2>/dev/null | $AWK '{print int($2/1024/1024); exit;}'` - -# Darwin -if test "$IS_APPLE_OS" != "0"; then - MEM_SIZE=`sysctl -a 2>&1 | $GREP "hw.memsize" 2>/dev/null | $AWK '{print int($3/1024/1024); exit;}'` -fi - -# Solaris -if test "$IS_SUN_OS" != "0"; then - MEM_SIZE=`prtconf 2>/dev/null | $GREP "Memory" | $AWK '{print int($3/1024); exit;}'` -fi - -# AIX -if test "$IS_AIX_OS" != "0"; then - MEM_SIZE=`prtconf -m 2>/dev/null | $GREP "MB" | $AWK '{print int($3/1024); exit;}'` -fi - -if test "$MEM_SIZE" -ge "2"; then - - ## Save CXXFLAGS - SAVED_CXXFLAGS="$CXXFLAGS" - - CXXFLAGS="-pipe" - AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS]) - XXX_COMPILE_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" - fi - - ## Restore CXXFLAGS - CXXFLAGS="$SAVED_CXXFLAGS" -fi - -############################################################################# -## Dead code stripping for linkers. Compilers are towards the head of script. - -if true; then - - ## Save FLAGS - SAVED_LDFLAGS="$LDFLAGS" - - # OS X uses -Wl,-dead_strip - LDFLAGS="-Wl,-dead_strip" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - # Linux uses --gc-sections - LDFLAGS="-Wl,--gc-sections" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - # Solaris uses -z discard-unused - # https://docs.oracle.com/cd/E26502_01/html/E26507/glmth.html - LDFLAGS="-Wl,-z,discard-unused=sections" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - # Solaris uses -z discard-unused - # https://docs.oracle.com/cd/E26502_01/html/E26507/glmth.html - LDFLAGS="-Wl,-z,discard-unused=dependencies" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - ## Restore FLAGS - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## Solaris, map file and libraries - -if test "$IS_SUN_OS" != "0"; then - - ## Save LDFLAGS - SAVED_LDFLAGS="$LDFLAGS" - - ## IA-32 gets a Mapfile for capabilities. Due to libtool stripping - ## -M arguments, we need to escape it with -XCClinker in AM_LDFLAGS. - if test "$IS_IA32" != "0"; then - LDFLAGS="-Mcryptopp.mapfile" - AC_MSG_CHECKING([if $LDNAME supports -Mcryptopp.mapfile]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS -XCClinker -Mcryptopp.mapfile" - fi - fi - - ## Restore LDFLAGS - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## Add --build-id to linker for debug symbols. -## https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html - -if true; then - - SAVED_LDFLAGS="$LDFLAGS" - LDFLAGS="-Wl,--build-id" - - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## Demangle output names if possible for friendlier err messages - -if true; then - - SAVED_LDFLAGS="$LDFLAGS" - LDFLAGS="-Wl,--demangle" - - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## MinGW libraries -## Automake does not follow Make conventions and use AM_LDLIBS. Instead -## it stuffs libraries in the flags which messes up pkg-config *.pc files. - -if test "$IS_MINGW_OS" = "1"; then - - SAVED_LDFLAGS="$LDFLAGS" - - LDFLAGS="-lws2_32" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - ## Restore LDFLAGS - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## OpenMP libraries -## Automake does not follow Make conventions and use AM_LDLIBS. Instead -## it stuffs libraries in the flags which messes up pkg-config *.pc files. - -if true; then - - COUNT1=`echo $CXXFLAGS | $EGREP -c '\-fopenmp'` - COUNT2=`echo $LDFLAGS | $EGREP -c '\-lgomp'` - if test "$COUNT1" != "0" && test "$COUNT2" = "0"; then - - SAVED_LDFLAGS="$LDFLAGS" - - LDFLAGS="-lgomp" - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - LDFLAGS="$SAVED_LDFLAGS" - fi -fi - -############################################################################# -## Add -Wl,--exclude-libs,ALL for GNU linker to stop us from re-exporting -## symbols in other libraries. This keeps our ELF section header smaller. - -if test "$enable_shared" = "yes"; then - - SAVED_LDFLAGS="$LDFLAGS" - LDFLAGS="-Wl,--exclude-libs,ALL" - - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## Add -Wl,--as-needed for linker to avoid linking unneeded libraries. - -if true; then - - SAVED_LDFLAGS="$LDFLAGS" - LDFLAGS="-Wl,--as-needed" - - AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS]) - XXX_LINK_IFELSE( - [AC_LANG_SOURCE([[int main() { return 0; }]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - - if test "$retval" = "0"; then - AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS" - fi - - LDFLAGS="$SAVED_LDFLAGS" -fi - -############################################################################# -## Android cpu-features library - -if test "$IS_ANDROID_OS" != "0"; then - - # ac_srcdir does not work. Autotools blows... - - THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" - AC_CHECK_FILE([$THIS_FILE], - [cp "$THIS_FILE" "./"] - ) - - THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" - AC_CHECK_FILE([$THIS_FILE], - [cp "$THIS_FILE" "./"] - ) - - # And set the flag so Makefile adds the recipes - THIS_FILE="./cpu-features.c" - AC_CHECK_FILE([$THIS_FILE], - [AM_CONDITIONAL([ANDROID_CPU_FEATURES], [true])], - [AM_CONDITIONAL([ANDROID_CPU_FEATURES], [false])] - ) -else - AM_CONDITIONAL([ANDROID_CPU_FEATURES], [false]) -fi - -############################################################################# -## Miscellaneous items - -## Fix CCAS and CCASFLAGS -## Also see https://stackoverflow.com/q/51575580/608639 -AC_SUBST([CCAS], [$CXX]) -AC_SUBST([CCASFLAGS], ["$AM_CXXFLAGS $CXXFLAGS"]) - -## Without this 'make' uses our GNUmakefile, and not Makefile -AC_CONFIG_COMMANDS_PRE([rm -f GNUmakefile 2>/dev/null]) -AC_CONFIG_COMMANDS_PRE([rm -f GNUmakefile-cross 2>/dev/null]) - -## Write the Automake flags we set -AC_SUBST([AM_CXXFLAGS]) -AC_SUBST([AM_LDFLAGS]) - -## Write the output artifacts -AC_OUTPUT - -## Automake bug workaround. If libcryptopp_la_SOURCES is an empty list, Automake assumes -## C source files and drive link through the C compiler. We provide the empty adhoc.cpp -## to get things back on course, so adhoc.cpp must always be copied. - -AC_CONFIG_COMMANDS_POST([cp adhoc.cpp.proto adhoc.cpp]) - -############################################################################# -## Print a summary of information - -echo "" -echo "***********************************************************************" - -echo "Auto-configuration complete. A summary of options are below. If" -echo "something looks wrong then please modify config.h and please report" -echo "it at http://github.com/noloader/cryptopp-autotools." -echo "" - -echo " Build triplet: $build" -echo " Compiler target: $COMPILER_TARGET" -echo "Compiler version: $COMPILER_VERSION" -echo "" - -echo "Static library: $enable_static" -echo "Shared library: $enable_shared" -echo "" - -if test "$IS_ARM32" != "0" || test "$IS_ARMV8" != "0"; then - if test x"$CRYPTOPP_ARM_NEON_HEADER" != "x"; then - echo "CRYPTOPP_ARM_NEON_HEADER: $CRYPTOPP_ARM_NEON_HEADER" - fi - if test x"$CRYPTOPP_ARM_ACLE_HEADER" != "x"; then - echo "CRYPTOPP_ARM_ACLE_HEADER: $CRYPTOPP_ARM_ACLE_HEADER" - fi - echo "" -fi - -if test x"$CRYPTOPP_SSE2_FLAG" != "x"; then - echo "CRYPTOPP_SSE2_FLAG: $CRYPTOPP_SSE2_FLAG" -fi -if test x"$CRYPTOPP_NEON_FLAG" != "x"; then - echo "CRYPTOPP_NEON_FLAG: $CRYPTOPP_NEON_FLAG" -fi -if test x"$CRYPTOPP_ALTIVEC_FLAG" != "x"; then - echo "CRYPTOPP_ALTIVEC_FLAG: $CRYPTOPP_ALTIVEC_FLAG" -fi -if test x"$CRYPTOPP_POWER7_FLAG" != "x"; then - echo "CRYPTOPP_POWER7_FLAG: $CRYPTOPP_POWER7_FLAG" -fi -if test x"$CRYPTOPP_POWER8_FLAG" != "x"; then - echo "CRYPTOPP_POWER8_FLAG: $CRYPTOPP_POWER8_FLAG" -fi -#if test x"$CRYPTOPP_POWER9_FLAG" != "x"; then -# echo "CRYPTOPP_POWER9_FLAG: $CRYPTOPP_POWER9_FLAG" -#fi -if test x"$CRYPTOPP_ARIA_FLAG" != "x"; then - echo "CRYPTOPP_ARIA_FLAG: $CRYPTOPP_ARIA_FLAG" -fi -if test x"$CRYPTOPP_BLAKE2S_FLAG" != "x"; then - echo "CRYPTOPP_BLAKE2S_FLAG: $CRYPTOPP_BLAKE2S_FLAG" -fi -if test x"$CRYPTOPP_BLAKE2B_FLAG" != "x"; then - echo "CRYPTOPP_BLAKE2B_FLAG: $CRYPTOPP_BLAKE2B_FLAG" -fi -if test x"$CRYPTOPP_CHACHA_FLAG" != "x"; then - echo "CRYPTOPP_CHACHA_FLAG: $CRYPTOPP_CHACHA_FLAG" -fi -if test x"$CRYPTOPP_CHACHA_AVX2_FLAG" != "x"; then - echo "CRYPTOPP_CHACHA_AVX2_FLAG: $CRYPTOPP_CHACHA_AVX2_FLAG" -fi -if test x"$CRYPTOPP_CHAM_FLAG" != "x"; then - echo "CRYPTOPP_CHAM_FLAG: $CRYPTOPP_CHAM_FLAG" -fi -if test x"$CRYPTOPP_CRC_FLAG" != "x"; then - echo "CRYPTOPP_CRC_FLAG: $CRYPTOPP_CRC_FLAG" -fi -if test x"$CRYPTOPP_DONNA_FLAG" != "x"; then - echo "CRYPTOPP_DONNA_FLAG: $CRYPTOPP_DONNA_FLAG" -fi -if test x"$CRYPTOPP_LEA_FLAG" != "x"; then - echo "CRYPTOPP_LEA_FLAG: $CRYPTOPP_LEA_FLAG" -fi -if test x"$CRYPTOPP_KECCAK_FLAG" != "x"; then - echo "CRYPTOPP_KECCAK_FLAG: $CRYPTOPP_KECCAK_FLAG" -fi -if test x"$CRYPTOPP_GCM_FLAG" != "x"; then - echo "CRYPTOPP_GCM_FLAG: $CRYPTOPP_GCM_FLAG" -fi -if test x"$CRYPTOPP_GF2N_FLAG" != "x"; then - echo "CRYPTOPP_GF2N_FLAG: $CRYPTOPP_GF2N_FLAG" -fi -if test x"$CRYPTOPP_AES_FLAG" != "x"; then - echo "CRYPTOPP_AES_FLAG: $CRYPTOPP_AES_FLAG" -fi -if test x"$CRYPTOPP_SHA_FLAG" != "x"; then - echo "CRYPTOPP_SHA_FLAG: $CRYPTOPP_SHA_FLAG" -fi -if test x"$CRYPTOPP_SIMON128_FLAG" != "x"; then - echo "CRYPTOPP_SIMON128_FLAG: $CRYPTOPP_SIMON128_FLAG" -fi -if test x"$CRYPTOPP_SPECK128_FLAG" != "x"; then - echo "CRYPTOPP_SPECK128_FLAG: $CRYPTOPP_SPECK128_FLAG" -fi -if test x"$CRYPTOPP_SM4_FLAG" != "x"; then - echo "CRYPTOPP_SM4_FLAG: $CRYPTOPP_SM4_FLAG" -fi -if test x"$CRYPTOPGAMS_ARMV4_FLAG" != "x"; then - echo "CRYPTOPGAMS_ARMV4_FLAG: $CRYPTOPGAMS_ARMV4_FLAG" -fi - -echo "" -echo "Automake flags (can be overridden by user flags):" -echo "AM_CXXFLAGS: $AM_CXXFLAGS" -echo "AM_LDFLAGS: $AM_LDFLAGS" - -echo "" -echo "User flags (overrides Automake flags on conflict):" -echo "CXXFLAGS: $CXXFLAGS" -echo "LDFLAGS: $LDFLAGS" - -OPT_NDEBUG=`echo $CPPFLAGS $CXXFLAGS | $EGREP -c '\-DNDEBUG'` -if test "$OPT_NDEBUG" = "0"; then - echo "" - echo "CPPFLAGS does not include -DNDEBUG. You should consider building" - echo "with NDEBUG defined so an assert does not inadvertently crash your" - echo "program and egress sensitive data to the filesystem or an error" - echo "reporting service like AppPort, Windows Error Reporting, Crash" - echo "Reporter, Test Flight, etc." -fi - -OPT_SYM=`echo $CPPFLAGS $CXXFLAGS | $EGREP -c '\-g'` -if test "$OPT_SYM" = "0"; then - echo "" - echo "CPPFLAGS does not include -g. You should consider building with -g" - echo "to add debug symbols in case you have to analyze a crash." -fi - -OPT_O3=`echo $CXXFLAGS | $EGREP -c '\-O3|\-O4|\-O5|\-xO3|\-xO4|\-xO5|\-Os|\-Ofast'` -if test "$OPT_O3" = "0"; then - echo "" - echo "CXXFLAGS does not include -O3. You should consider building at -O3" - echo "to engage compiler vectorizations and enhance performance." -fi - -echo "***********************************************************************" -echo "" diff --git a/package/lean/libcryptopp/src/libcryptopp.pc.in b/package/lean/libcryptopp/src/libcryptopp.pc.in deleted file mode 100644 index a6c502ee5..000000000 --- a/package/lean/libcryptopp/src/libcryptopp.pc.in +++ /dev/null @@ -1,31 +0,0 @@ -## libcryptopp.pc.in - Autotools package configuration file for Crypto++. -## written and placed in public domain by Jeffrey Walton. -## based on Debian package configuration by László Böszörményi. -## - -## libdir=@libdir@ is not working as expected for Fedora, Solaris, -## and other 64-bit OSes that use library directories like /lib64, -## /usr/lib64, /lib/amd64 and friends. Also see: -## * https://stackoverflow.com/q/47124066/608639 -## * https://stackoverflow.com/q/46847939/608639 and -## * https://bugzilla.redhat.com/show_bug.cgi?id=1510073. - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: @PACKAGE_NAME@ -Description: free C++ class library of cryptographic schemes -Authors: originally written by Wei Dai -Maintainers: the Crypto++ community -URL: @PACKAGE_URL@ -Version: @PACKAGE_VERSION@ -Bug-Report: @PACKAGE_BUGREPORT@ -Requires: - -## These flags are mostly broken. We cannot record user choices, -## and then have user programs use the same flags later. -## https://lists.freedesktop.org/archives/pkg-config/2017-November/001087.html -Cflags: -I${includedir} -Libs: -L${libdir} -lcryptopp diff --git a/package/lean/luci-app-fan/Makefile b/package/lean/luci-app-fan/Makefile deleted file mode 100644 index 6692a89df..000000000 --- a/package/lean/luci-app-fan/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (C) 2016 Openwrt.org -# -# This is free software, licensed under the Apache License, Version 2.0 . -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=LuCI fan control -LUCI_DEPENDS:=+coreutils-stat -LUCI_PKGARCH:=all -PKG_VERSION:=1.0.0-3 -PKG_RELEASE:= -PKG_MAINTAINER:=jjm2473 - -define Package/luci-app-fan/conffiles -/etc/config/luci-fan -endef - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature - diff --git a/package/lean/luci-app-fan/luasrc/controller/admin/luci-fan.lua b/package/lean/luci-app-fan/luasrc/controller/admin/luci-fan.lua deleted file mode 100644 index c710fe2ed..000000000 --- a/package/lean/luci-app-fan/luasrc/controller/admin/luci-fan.lua +++ /dev/null @@ -1,38 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface -Copyright 2023 jjm2473 -]]-- - -module("luci.controller.admin.luci-fan", package.seeall) - -function index() - require "luci.sys" - local appname = "luci-fan" - local defaultpage = nil - if luci.sys.call("/usr/libexec/fan-control get >/dev/null 2>&1") == 0 then - entry({"admin", "system", appname}, cbi("luci-fan"), _("Fan Control"), 60) - else - entry({"admin", "system", appname}).dependent = true - end - entry({"admin", "system", appname, "get_fan_info"}, call("get_fan_info"), nil).leaf = true -end - -function get_fan_info(zone, trip) - require "luci.util" - local words - if zone and trip and string.match(zone, "^thermal_zone%d+$") and string.match(trip, "^%d+$") then - local fs = require "nixio.fs" - words = { - luci.util.trim(fs.readfile("/sys/class/thermal/"..zone.."/temp")), - luci.util.trim(fs.readfile("/sys/class/thermal/"..zone.."/trip_point_"..trip.."_temp")) - } - else - local sys = require "luci.sys" - words = luci.util.split(luci.util.trim(sys.exec("/usr/libexec/fan-control temp 2>/dev/null")), " ") - end - local zone_temp = tonumber(words[1]) / 1000; -- ˚C - local fan_on_temp = tonumber(words[2]) / 1000; -- ˚C - luci.http.status(200, "ok") - luci.http.prepare_content("application/json") - luci.http.write_json({zone_temp=zone_temp, fan_on_temp=fan_on_temp}) -end diff --git a/package/lean/luci-app-fan/luasrc/model/cbi/luci-fan.lua b/package/lean/luci-app-fan/luasrc/model/cbi/luci-fan.lua deleted file mode 100644 index 82530d1d2..000000000 --- a/package/lean/luci-app-fan/luasrc/model/cbi/luci-fan.lua +++ /dev/null @@ -1,93 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface -Copyright 2023 jjm2473 -]]-- - -local m, s, o -require "luci.util" - -local fs = require "nixio.fs" - -local sys = require "luci.sys" - -local words = luci.util.split(luci.util.trim(sys.exec("/usr/libexec/fan-control get 2>/dev/null")), " ") - -if #words < 3 then - return -end - -m = Map("luci-fan", translate("Fan Control"), translate("Control fan start and stop temperature. This plugin can only configure the lowest gear, not necessarily applicable to all devices.")) - -s = m:section(SimpleSection) -s.template = "luci-fan" -s.thermal_zone = words[1] -s.trip_point = words[2] -s.thermal_type = luci.util.trim(fs.readfile("/sys/class/thermal/"..words[1].."/type")) - -s = m:section(TypedSection, "luci-fan", translate("Fan Settings")) -s.addremove = false -s.anonymous = true - -o = s:option(Flag, "enabled", translate("Enabled"), translate("Whether to apply the settings")) -o.default = 0 - -local on_temp = s:option(Value, "on_temp", translate("Fan start temperature") .. " (℃)") -on_temp.datatype = "and(uinteger,min(5))" -on_temp.rmempty = false -on_temp.default = math.floor(tonumber(words[3])/1000) -if #words > 3 then - on_temp.datatype = string.format("and(uinteger,range(5,%u))", math.floor(tonumber(words[4])/1000 - 1)) -end - -o = s:option(Value, "off_temp", translate("Fan stop temperature") .. " (℃)", translate("Optional, MUST be lower than the fan start temperature. Default fan start temperature minus 5 ℃")) -o.datatype = "uinteger" -o.rmempty = true -function o.parse(self, section, novld) - local fvalue = self:formvalue(section) - local fexist = ( fvalue and (#fvalue > 0) ) -- not "nil" and "not empty" - - local vvalue, errtxt = self:validate(fvalue) - if not vvalue then - if novld then -- and "novld" set - return -- then exit without raising an error - end - if fexist then -- and there is a formvalue - self:add_error(section, "invalid", errtxt or self.title .. ": invalid") - return -- so data are invalid - end - end - local rm_opt = ( self.rmempty or self.optional ) - local vexist = ( vvalue and (#vvalue > 0) ) and true or false -- not "nil" and "not empty" - local eq_def = ( vvalue == self.default ) -- equal_default flag - -- (rmempty or optional) and (no data or equal_default) - if rm_opt and (not vexist or eq_def) then - if self:remove(section) then -- remove data from UCI - self.section.changed = true -- and push events - end - return - end - - local cvalue = self:cfgvalue(section) - local eq_cfg = ( vvalue == cvalue ) -- update equal_config flag - -- not forcewrite and no changes, so nothing to write - if not self.forcewrite and eq_cfg then - return - end - - local onvalue = on_temp:validate(on_temp:formvalue(section)) - if onvalue and #onvalue > 0 then - if tonumber(vvalue) >= tonumber(onvalue) then - self:add_error(section, "invalid", translate("Fan stop temperature MUST be lower than fan start temperature")) - return - end - else - return - end - - -- write data to UCI; raise event only on changes - if self:write(section, vvalue) and not eq_cfg then - self.section.changed = true - end -end - -return m diff --git a/package/lean/luci-app-fan/luasrc/view/luci-fan.htm b/package/lean/luci-app-fan/luasrc/view/luci-fan.htm deleted file mode 100644 index fad27e0e4..000000000 --- a/package/lean/luci-app-fan/luasrc/view/luci-fan.htm +++ /dev/null @@ -1,30 +0,0 @@ -
-
-

<%:Status%>

- - - - - - - -
<%:Thermal zone%><%=self.thermal_zone%> (<%:type:%> <%=self.thermal_type%>)
<%:Trip point%>trip_point_<%=self.trip_point%>
<%:Fan start temperature%>
<%:Current temperature%>
-
-
- - \ No newline at end of file diff --git a/package/lean/luci-app-fan/po/templates/luci-fan.pot b/package/lean/luci-app-fan/po/templates/luci-fan.pot deleted file mode 100644 index 737183d82..000000000 --- a/package/lean/luci-app-fan/po/templates/luci-fan.pot +++ /dev/null @@ -1,64 +0,0 @@ -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19 -msgid "" -"Control fan start and stop temperature. This plugin can only configure the " -"lowest gear, not necessarily applicable to all devices." -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:9 -msgid "Current temperature" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31 -msgid "Enabled" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/controller/admin/luci-fan.lua:13 -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19 -msgid "Fan Control" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:27 -msgid "Fan Settings" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:34 -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:8 -msgid "Fan start temperature" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42 -msgid "Fan stop temperature" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:80 -msgid "Fan stop temperature MUST be lower than fan start temperature" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42 -msgid "" -"Optional, MUST be lower than the fan start temperature. Default fan start " -"temperature minus 5 ℃" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:3 -msgid "Status" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6 -msgid "Thermal zone" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:7 -msgid "Trip point" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31 -msgid "Whether to apply the settings" -msgstr "" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6 -msgid "type:" -msgstr "" diff --git a/package/lean/luci-app-fan/po/zh-cn/luci-fan.po b/package/lean/luci-app-fan/po/zh-cn/luci-fan.po deleted file mode 100644 index 8f13951f5..000000000 --- a/package/lean/luci-app-fan/po/zh-cn/luci-fan.po +++ /dev/null @@ -1,68 +0,0 @@ -msgid "" -msgstr "" -"Language: zh_Hans\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19 -msgid "" -"Control fan start and stop temperature. This plugin can only configure the " -"lowest gear, not necessarily applicable to all devices." -msgstr "控制风扇启停温度。此插件仅配置最低档位触发点,不一定适用于所有设备" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:9 -msgid "Current temperature" -msgstr "当前温度" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31 -msgid "Enabled" -msgstr "启用" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/controller/admin/luci-fan.lua:13 -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19 -msgid "Fan Control" -msgstr "风扇控制" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:27 -msgid "Fan Settings" -msgstr "风扇设置" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:34 -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:8 -msgid "Fan start temperature" -msgstr "风扇启动温度" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42 -msgid "Fan stop temperature" -msgstr "风扇停止温度" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:80 -msgid "Fan stop temperature MUST be lower than fan start temperature" -msgstr "风扇停止温度必须小于风扇启动温度" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42 -msgid "" -"Optional, MUST be lower than the fan start temperature. Default fan start " -"temperature minus 5 ℃" -msgstr "可选,必须小于风扇启动温度。默认风扇启动温度减 5 ℃" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:3 -msgid "Status" -msgstr "状态" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6 -msgid "Thermal zone" -msgstr "温感区" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:7 -msgid "Trip point" -msgstr "触发点" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31 -msgid "Whether to apply the settings" -msgstr "是否应用此设置" - -#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6 -msgid "type:" -msgstr "类型:" diff --git a/package/lean/luci-app-fan/root/etc/config/luci-fan b/package/lean/luci-app-fan/root/etc/config/luci-fan deleted file mode 100644 index 5cd7b9f68..000000000 --- a/package/lean/luci-app-fan/root/etc/config/luci-fan +++ /dev/null @@ -1,4 +0,0 @@ -config luci-fan - option enabled 0 -# option on_temp 55 -# option off_temp 50 \ No newline at end of file diff --git a/package/lean/luci-app-fan/root/etc/init.d/luci-fan b/package/lean/luci-app-fan/root/etc/init.d/luci-fan deleted file mode 100755 index 3fbd35dd9..000000000 --- a/package/lean/luci-app-fan/root/etc/init.d/luci-fan +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=20 - -boot() { - /usr/libexec/fan-control init - start -} - -start_instance() { - local enabled - config_get_bool enabled $1 enabled 0 - [[ "$enabled" = 1 ]] || return 0 - - config_get on_temp $1 on_temp - config_get off_temp $1 off_temp - - [[ -n "$on_temp" ]] && on_temp=${on_temp}000 - [[ -n "$off_temp" ]] && off_temp=${off_temp}000 - - /usr/libexec/fan-control set "$on_temp" $off_temp -} - -start() { - config_load luci-fan - config_foreach start_instance luci-fan - return 0 -} diff --git a/package/lean/luci-app-fan/root/etc/uci-defaults/luci-fan b/package/lean/luci-app-fan/root/etc/uci-defaults/luci-fan deleted file mode 100644 index 10eccac23..000000000 --- a/package/lean/luci-app-fan/root/etc/uci-defaults/luci-fan +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -/usr/libexec/fan-control init - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@luci-fan[-1] - add ucitrack luci-fan - set ucitrack.@luci-fan[-1].init=luci-fan - commit ucitrack -EOF - -exit 0 diff --git a/package/lean/luci-app-fan/root/usr/libexec/fan-control b/package/lean/luci-app-fan/root/usr/libexec/fan-control deleted file mode 100755 index f2f86435e..000000000 --- a/package/lean/luci-app-fan/root/usr/libexec/fan-control +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/sh -# author: jjm2473 - -SAVE=/tmp/run/fanTP -ACTION=${1} -shift - -# print: zone trip_point current_target_temp [max_target_temp] -# ex. thermal_zone0 0 50000 60000 -function getFanTP() { - local zone cdev trip temp mintemp mintrip minzone maxtemp - [[ -d /sys/class/thermal ]] || return 1 - cd /sys/class/thermal - for zone in thermal_zone* ; do - cd "$zone" - for cdev in `ls | grep 'cdev[0-9]\+$'`; do - [[ -d "$cdev" ]] || continue - grep -Fiq fan "$cdev/type" || continue - trip=`cat ${cdev}_trip_point` - grep -Fwq active trip_point_${trip}_type || continue - [[ "`stat -c '%#a' trip_point_${trip}_temp || echo 0444`" = "0644" ]] || continue - temp=`cat trip_point_${trip}_temp` - if [[ -z "$mintemp" ]] || [[ "$temp" -lt "$mintemp" ]]; then - if [[ -n "$mintemp" ]]; then - if [[ "$zone" = "$minzone" ]]; then - maxtemp=$mintemp - else - maxtemp= - fi - fi - mintemp=$temp - mintrip=$trip - minzone=$zone - elif [[ -z "$maxtemp" ]] || [[ "$temp" -lt "$maxtemp" ]]; then - maxtemp=$temp - fi - done - cd /sys/class/thermal - done - if [[ -n "$mintemp" ]]; then - echo "$minzone" "$mintrip" "$mintemp" $maxtemp - return 0 - else - return 1 - fi -} - -function getFanTP_C() { - if [[ -f "$SAVE" ]]; then - if [[ -s "$SAVE" ]]; then - cat "$SAVE" - return 0 - else - return 1 - fi - fi - ( getFanTP ) | tee "$SAVE" - [[ -s "$SAVE" ]] -} - -function getFanTP_U() { - set $(getFanTP_C) - [[ -n "$1" && -n "$2" ]] || return 1 - local onTemp=`cat "/sys/class/thermal/${1}/trip_point_${2}_temp"` - echo "$1" "$2" "$onTemp" $4 - return 0 -} - -function initFanTP() { - [[ -f "$SAVE" ]] || ( getFanTP >"$SAVE" ) -} - -# param: ON_TEMP [OFF_TEMP] -# OFF_TEMP = ON_TEMP - 5000 if not set -# ex. 60000 55000 -function setFanTP() { - local ON_TEMP=$1 - local OFF_TEMP=$2 - [[ -n "$ON_TEMP" ]] || { - echo "ON_TEMP must be present" >&2 - return 1 - } - if [[ -z "$OFF_TEMP" ]]; then - [[ "$ON_TEMP" -gt 5000 ]] || { - echo "ON_TEMP must greater than 5000 when OFF_TEMP not present" >&2 - return 1 - } - OFF_TEMP=$(( $ON_TEMP - 5000 )) - fi - [[ "$ON_TEMP" -gt "$OFF_TEMP" ]] || { - echo "ON_TEMP must greater than OFF_TEMP" >&2 - return 1 - } - local HYST=$(( $ON_TEMP - $OFF_TEMP )) - - set $(getFanTP_C) - [[ -n "$1" && -n "$2" ]] || return 1 - [[ -d "/sys/class/thermal/${1}" ]] || return 1 - - [[ -n "$4" ]] && [[ "$ON_TEMP" -ge "$4" ]] && { - ON_TEMP=$(( $4 - 5000 )) - echo "WARN: ON_TEMP greater than next TP $4, fixed to $ON_TEMP" >&2 - } - echo "$ON_TEMP" > "/sys/class/thermal/${1}/trip_point_${2}_temp" - echo "$HYST" > "/sys/class/thermal/${1}/trip_point_${2}_hyst" -} - -# print: current thermal sensor value and fan on temp -function getTemp() { - set $(getFanTP_C) - [[ -n "$1" && -n "$2" ]] || return 1 - [[ -f "/sys/class/thermal/$1/temp" ]] || return 1 - local temp=`cat "/sys/class/thermal/$1/temp"` - local tpt=`cat "/sys/class/thermal/$1/trip_point_${2}_temp"` - echo "$temp $tpt" -} - -usage() { - echo "usage: $0 sub-command" - echo "where sub-command is one of:" - echo " get Get Fan setting" - echo " set ON_TEMP [OFF_TEMP] Set Fan setting" - echo " temp Get current thermal temp and Fan on temp" - echo " init init, internal used" -} - -case ${ACTION} in - "get") - getFanTP_U - ;; - "set") - setFanTP "$@" - ;; - "temp") - getTemp - ;; - "init") - initFanTP - ;; - *) - usage - exit 1 - ;; -esac - diff --git a/package/lean/luci-app-leigod-acc/Makefile b/package/lean/luci-app-leigod-acc/Makefile new file mode 100644 index 000000000..1e29281fd --- /dev/null +++ b/package/lean/luci-app-leigod-acc/Makefile @@ -0,0 +1,18 @@ +# +# Copyright (C) 2008-2014 The LuCI Team +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=Luci for Leigod Game Accelerater +LUCI_PKGARCH:=all +LUCI_DEPENDS:=+libpcap +iptables +kmod-ipt-nat +iptables-mod-tproxy +kmod-ipt-tproxy +kmod-tun +kmod-netem +tc-full +kmod-ipt-ipset +ipset +curl +miniupnpd +conntrack +conntrackd +leigod-acc +PKG_VERSION:=1 +PKG_RELEASE:=3 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/package/lean/luci-app-leigod-acc/luasrc/controller/acc.lua b/package/lean/luci-app-leigod-acc/luasrc/controller/acc.lua new file mode 100644 index 000000000..e4b9a4e77 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/controller/acc.lua @@ -0,0 +1,101 @@ +module("luci.controller.acc", package.seeall) + +function index() + require("luci.i18n") + entry({ "admin", "services", "acc" }, alias("admin", "services", "acc", "service"), translate("Leigod Acc"), 50) + entry({ "admin", "services", "acc", "service" }, cbi("leigod/service"), translate("Leigod Service"), 30).i18n = "acc" + entry({ "admin", "services", "acc", "device" }, cbi("leigod/device"), translate("Leigod Device"), 50).i18n = "acc" + entry({ "admin", "services", "acc", "app" }, cbi("leigod/app"), translate("Leigod App"), 60).i18n = "acc" + entry({ "admin", "services", "acc", "notice" }, cbi("leigod/notice"), translate("Leigod Notice"), 80).i18n = "acc" + entry({ "admin", "services", "acc", "status" }, call("get_acc_status")).leaf = true + entry({ "admin", "services", "acc", "start_acc_service" }, call("start_acc_service")) + entry({ "admin", "services", "acc", "stop_acc_service" }, call("stop_acc_service")) +end + +-- get_acc_status get acc status +function get_acc_status() + -- util module + local util = require "luci.util" + local uci = require "luci.model.uci".cursor() + local translate = luci.i18n.translate + -- init result + local resp = {} + -- init state + resp.service = translate("Acc Service Disabled") + resp.state = {} + -- check if exist + local exist = util.exec("ps | grep acc-gw | grep -v grep") + -- check if program is running + if exist ~= "" then + resp.service = translate("Acc Service Enabled") + end + -- get uci + local results = uci:get_all("accelerator") + for _, typ in pairs({ "Phone", "PC", "Game", "Unknown" }) do + local state = uci:get("accelerator", typ, "state") + -- check state + local state_text = "None" + if state == nil or state == '0' then + elseif state == '1' then + state_text = translate("Acc Catalog Started") + elseif state == '2' then + state_text = translate("Acc Catalog Stopped") + elseif state == '3' then + state_text = translate("Acc Catalog Paused") + end + -- store text + resp.state[translate(typ .. "_Catalog")] = state_text + end + luci.http.prepare_content("application/json") + luci.http.write_json(resp) +end + +-- start_acc_service +function start_acc_service() + -- util module + local util = require "luci.util" + util.exec("/etc/init.d/acc enable") + util.exec("/etc/init.d/acc restart") + local resp = {} + resp.result = "OK" + luci.http.prepare_content("application/json") + luci.http.write_json(resp) +end + +-- stop_acc_service +function stop_acc_service() + -- util module + local util = require "luci.util" + util.exec("/etc/init.d/acc stop") + util.exec("/etc/init.d/acc disable") + local resp = {} + resp.result = "OK" + luci.http.prepare_content("application/json") + luci.http.write_json(resp) +end + +-- schedule_pause +function schedule_pause() + local util = require "luci.util" + local uci = require "luci.model.uci".cursor() + local schedule_enabled = uci:get("accelerator", "system", "schedule_enabled") or "0" + local pause_time = uci:get("accelerator", "system", "pause_time") or "01:00" + local username = uci:get("accelerator", "system", "username") or "" + local password = uci:get("accelerator", "system", "password") or "" + + -- Remove existing cron jobs related to leigod_helper.sh + util.exec("sed -i '/usr/sbin/leigod/leigod_helper.sh/d' /etc/crontabs/root") + + if schedule_enabled == "1" then + -- Set the new cron job + local hour, minute = pause_time:match("(%d+):(%d+)") + local cron_time = string.format("%d %d * * * USERNAME=%s PASSWORD=%s /usr/sbin/leigod/leigod_helper.sh", tonumber(minute), tonumber(hour), username, password) + util.exec(string.format('echo "%s" >> /etc/crontabs/root', cron_time)) + util.exec("/etc/init.d/cron restart") + end + + local resp = {} + resp.result = "OK" + luci.http.prepare_content("application/json") + luci.http.write_json(resp) +end \ No newline at end of file diff --git a/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/app.lua b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/app.lua new file mode 100644 index 000000000..05fb606e5 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/app.lua @@ -0,0 +1,7 @@ +require("luci.util") + +mp = Map("accelerator") + +mp:section(SimpleSection).template = "leigod/app" + +return mp \ No newline at end of file diff --git a/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/device.lua b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/device.lua new file mode 100644 index 000000000..dc534f4b3 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/device.lua @@ -0,0 +1,157 @@ +local uci = require "luci.model.uci".cursor() +local util = require "luci.util" +local fs = require "nixio.fs" +local pairs = pairs +local io = io + +-- config +m = Map("accelerator") +m.title = translate("Leigod Device Config") +m.description = translate("Control Device Config") + +-- get neigh info +neigh = m:section(NamedSection, "base", "system", translate("Neigh Device")) +neigh_tab = neigh:option(ListValue, "neigh", translate("acc interface")) +local sys_dir = util.exec("ls /sys/class/net") +if sys_dir ~= nil then + neigh_tab:value("br-lan") + for ifc in string.gmatch(sys_dir, "[^\n]+") do + neigh_tab:value(ifc) + end +end + +-- range all device +device = m:section(NamedSection, "device", "hardware", translate("Device Info")) +device:tab("none_catalog", translate("None_Catalog")) +device:tab("phone_catalog", translate("Phone_Catalog")) +device:tab("pc_catalog", translate("PC_Catalog")) +device:tab("game_catalog", translate("Game_Catalog")) +device:tab("vr_catalog", translate("VR_Catalog")) +device:tab("unknown_catalog", translate("Unknown_Catalog")) + + +local dhcp_map = {} +-- check dhcp file +if fs.access("/tmp/dhcp.leases") then + for line in io.lines("/tmp/dhcp.leases") do + -- check if read empty line + if line == "" then + break + end + -- split line + local valueSl = string.gmatch(line, "[^ ]+") + -- read time + valueSl() + -- read mac + local mac = valueSl() + -- get ip + local ip = valueSl() + -- get host name + local hostname = valueSl() + -- key + local key = string.gsub(mac, ":", "") + -- store key + dhcp_map[key] = { + ["key"] = key, + ["mac"] = mac, + ["ip"] = ip, + ["name"] = hostname + } + end +end + +ifc = uci:get("accelerator", "base", "neigh") +if ifc == nil then + ifc = "br-lan" +end + +local arp_map = {} +-- check if arp exist +if fs.access("/proc/net/arp") then + -- read all item from arp + for line in io.lines("/proc/net/arp") do + -- check if line is not exist + if line == "" then + break + end + -- split item + local valueSl = string.gmatch(line, "[^ ]+") + -- get ip + local ip = valueSl() + -- get type + valueSl() + -- get flag + local flag = valueSl() + -- get mac + local mac = valueSl() + -- get mask + valueSl() + -- get device + local dev = valueSl() + -- get key + local key = string.gsub(mac, ":", "") + -- check if device and flag state + if dev == ifc and flag == "0x2" then + -- get current name + local name = mac + if dhcp_map[key] ~= nil and dhcp_map[key] ~= "*" then + name = dhcp_map[key].name + end + arp_map[key] = { + ["key"] = key, + ["mac"] = mac, + ["ip"] = ip, + ["name"] = name + } + end + end +end + +-- get device config +for key, item in pairs(arp_map) do + local typ = uci:get("accelerator", "device", key) + -- get device catalog from type + local catalog = "none_catalog" + -- default to unknown device + if typ == nil then + typ = 9 + else + typ = tonumber(typ) + end + + if typ == nil then + catalog = "unknown_catalog" + elseif typ >= 1 and typ <= 3 then + catalog = "game_catalog" + elseif typ >= 4 and typ <= 6 then + catalog = "pc_catalog" + elseif typ >= 7 and typ <= 8 then + catalog = "phone_catalog" + elseif typ >= 20 and typ <= 21 then + catalog = "vr_catalog" + else + catalog = "unknown_catalog" + end + -- device type + device_typ = device:taboption(catalog, ListValue, key, item.name) + device_typ:value("0", "None") + device_typ:value("1", "XBox") + device_typ:value("2", "Switch") + device_typ:value("3", "Play Station") + device_typ:value("4", "Steam Deck") + device_typ:value("5", "Windows") + device_typ:value("6", "MacBook") + device_typ:value("7", "Android") + device_typ:value("8", "iPhone") + device_typ:value("20", "Oculus") + device_typ:value("21", "HTC Vive") + device_typ:value("22", "Pico") + device_typ:value("9", "Unknown") +end + +-- set +device.write = function() + util.exec("/etc/init.d/acc restart") +end + +return m \ No newline at end of file diff --git a/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/notice.lua b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/notice.lua new file mode 100644 index 000000000..8aafc2dd7 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/notice.lua @@ -0,0 +1,10 @@ +local uci = require "luci.model.uci".cursor() + +-- config +m = Map("accelerator") +m.title = translate("Leigod Notice") +m.description = translate("Leigod Accelerator Usage") + +m:section(SimpleSection).template = "leigod/notice" + +return m diff --git a/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/service.lua b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/service.lua new file mode 100644 index 000000000..2810cf052 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/model/cbi/leigod/service.lua @@ -0,0 +1,46 @@ +local uci = require "luci.model.uci".cursor() + +-- config +m = Map("accelerator") +m.title = translate("Leigod Accelerator Config") +m.description = translate("Control Accelerator Config") + +s = m:section(TypedSection, "system") +s.addremove = false +s.anonymous = true + +enable = s:option(Flag,"enabled" ,translate("Enable")) +enable.rmempty = false +enable.default = 0 + +tun = s:option(Flag,"tun" ,translate("Tunnel Mode")) +tun.rmempty = false +tun.default = 0 +tun.description = translate("Turning Leigod into Tunnel mode can make some proxy plugins available") + +schedule_enabled = s:option(Flag, "schedule_enabled", translate("Scheduled Pause")) +schedule_enabled.rmempty = false +schedule_enabled.default = 0 +schedule_enabled.description = translate("夜猫子选项") + +pause_time = s:option(ListValue, "pause_time", translate("Pause Time")) +pause_time:depends("schedule_enabled", 1) +for i = 0, 23 do + pause_time:value(string.format("%02d:00", i), string.format("%02d:00", i)) +end +pause_time.rmempty = false +pause_time.description = translate("选择好时间雷神加速器会定时暂停,请避开你的游戏时间以免影响游戏体验") + + +username = s:option(Value, "username", translate("Phone Number")) +username:depends("schedule_enabled", 1) +username.rmempty = false + +password = s:option(Value, "password", translate("Leigod Password")) +password:depends("schedule_enabled", 1) +password.password = true +password.rmempty = false + +m:section(SimpleSection).template = "leigod/service" + +return m \ No newline at end of file diff --git a/package/lean/luci-app-leigod-acc/luasrc/view/leigod/app.htm b/package/lean/luci-app-leigod-acc/luasrc/view/leigod/app.htm new file mode 100644 index 000000000..530743a07 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/view/leigod/app.htm @@ -0,0 +1,6 @@ + +
+

+ +

+
\ No newline at end of file diff --git a/package/lean/luci-app-leigod-acc/luasrc/view/leigod/notice.htm b/package/lean/luci-app-leigod-acc/luasrc/view/leigod/notice.htm new file mode 100644 index 000000000..b1b49d44e --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/view/leigod/notice.htm @@ -0,0 +1,74 @@ +
+ <%:Declare%> + 此插件为 LEDE/QWRT 官方合作版插件, 需要配合雷神手机APP使用 +

+ <%:Upgrade Info%> +

+ 2024-8-1
+ 支持LEDE/QWRT性能优化
+ 2024-7-25
+ 支持非桥接模式下的旁路由
+ 2024-6-5
+ 扩充ipset容量, 以支持大容量代理ip库
+ 2024-1-22
+ 新增自动选择低延迟线路
+ 新增下载不限速(switch除外)
+ 设备名为*时, 显示mac地址
+


+ 2023-11-28
+ 新增对mips设备的支持
+ 新增对旁路由的支持
+ 解决翻译异常的问题
+ 设备管理页面可以显示未识别设备
+

+ <%:Install Dependence%> +

+ 插件运行需要借助一些依赖才能运行, 一般第三方固件默认已经集成了大部分的依赖,
+ 如果使用的是openwrt官方的固件, 则需要确保依赖安装好了, 以下列出依赖包和注意事项
+ libpcap
+ iptables
+ kmod-ipt-nat
+ iptables-mod-tproxy
+ kmod-ipt-tproxy
+ kmod-netem(非必须, 针对于一些icmp测速的游戏使用, 只影响界面显示, 实际游戏效果不影响)
+ tc-full(非必须, 同kmod-netem)
+ kmod-ipt-ipset
+ ipset
+ curl(谨慎更新, 某些三方固件升级curl, 会导致curl出现问题)
+

+ <%:Bridge Mode%> +

+ 加速插件无法探知当前插件应该使用什么模式,
+ 当前默认使用网桥作为流量转发的设备,
+ 如果使用旁路由模式或者docker时, 此时默认设备不是网桥,
+ 此时需要手动调整接口,
+ 改变接口的地址在 设备管理->路由设备, 选择对应的设备
+

+ <%:Acc Mode%> +

+ 当前雷神路由器支持两种加速模式, tproxy 和 tun
+ 当前默认采用的是tproxy模式, 原因在于tproxy有更好的性能
+ tun模式暂时屏蔽, 后续luci会完善一键切换模式 +

+ <%:Acc Usage%> +

+ 当前雷神加速插件是根据设备类型进行加速的, 也就是说, 如果加速了相应的类型后, 理论上只要连接该路由器的设备都将获得加速效果
+ 当前支持的设备类型有以下几种:
+ 手机: Android iPhone
+ 电脑: Windows MacOS SteamDeck
+ 主机: XBox Switch PlayStation
+ 未识别: Others
+ 可以在设备管理中, 插件自己的设备是否被成功识别成对应的设备, 如果不是, 可以选择对应的设备, 这样设备就能成功加速了
+

+

+ 一些特殊的说明:
+ 关于ios设备, 最好是在安装插件之前, 先忘记网络, 等安装完插件后, 再重新连接网络
+ 关于android设备, 需要关闭dhcpv6后, 手机重连网络, 以下给出一个 /etc/config/dhcp 的配置
+ config dhcp 'lan'
+ ... 此处是一些其他配置
+ ra 'disable'
+ dhcpv6 'disable'
+ list ra_flags 'none'
+ ... 此处是一些其他配置
+

+
diff --git a/package/lean/luci-app-leigod-acc/luasrc/view/leigod/service.htm b/package/lean/luci-app-leigod-acc/luasrc/view/leigod/service.htm new file mode 100644 index 000000000..7eca3745f --- /dev/null +++ b/package/lean/luci-app-leigod-acc/luasrc/view/leigod/service.htm @@ -0,0 +1,61 @@ + + + +
+ <%:Acc Catalog State%> + + + + + +
<%:Acc_Catalog%><%:Acc_Catalog_Status%>
+
+ + + diff --git a/package/lean/luci-app-leigod-acc/po/zh-cn/leigo-acc.po b/package/lean/luci-app-leigod-acc/po/zh-cn/leigo-acc.po new file mode 100644 index 000000000..caeff7728 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/po/zh-cn/leigo-acc.po @@ -0,0 +1,126 @@ + +msgid "Leigod Acc" +msgstr "雷神加速器" + +msgid "Leigod Service" +msgstr "服务控制" + +msgid "Leigod Device" +msgstr "设备管理" + +msgid "Leigod App" +msgstr "雷神移动端APP" + +msgid "Leigod Notice" +msgstr "加速公告" + +msgid "Leigod Accelerator Config" +msgstr "雷神加速器 - 专线加速游戏,按分钟计费可暂停,玩多久算多久,时长永久有效" + +msgid "Control Accelerator Config" +msgstr "加速时长6端通用 (Windows端 | Mac端 | NN | 手机端 | 主机端 | 路由器)" + +msgid "Acc_Service_Name" +msgstr "服务名称" + +msgid "Acc_Service_Status" +msgstr "启动状态" + +msgid "Acc_Service_Operate" +msgstr "加速设置" + +msgid "Acc Catalog State" +msgstr "加速状态" + +msgid "Acc_Catalog" +msgstr "加速设备" + +msgid "Acc_Catalog_Status" +msgstr "加速状态" + +msgid "Declare" +msgstr "说明" + +msgid "Upgrade Info" +msgstr "更新内容" + +msgid "Install Dependence" +msgstr "安装依赖" + +msgid "Bridge Mode" +msgstr "旁路由模式" + +msgid "Acc Mode" +msgstr "加速模式" + +msgid "Acc Usage" +msgstr "使用说明" + +msgid "Leigod Accelerator Usage" +msgstr "雷神加速插件使用" + +msgid "Leigod Device Config" +msgstr "设备管理配置" + +msgid "Control Device Config" +msgstr "控制和改变设备类型" + +msgid "Neigh Device" +msgstr "路由设置" + +msgid "acc interface" +msgstr "代理接口" + +msgid "Device Info" +msgstr "设备信息" + +msgid "None_Catalog" +msgstr "未分类设备" + +msgid "Phone_Catalog" +msgstr "手机设备" + +msgid "None_Catalog" +msgstr "未分类设备" + +msgid "Tunnel Mode" +msgstr "TUN 模式" + +msgid "PC_Catalog" +msgstr "PC 设备" + +msgid "Game_Catalog" +msgstr "游戏机" + +msgid "VR_Catalog" +msgstr "VR 设备" + +msgid "Unknown_Catalog" +msgstr "未识别设备" + +msgid "acc_service" +msgstr "雷神加速器服务" + +msgid "Acc_Service" +msgstr "雷神加速器服务" + +msgid "Stop Acc Service" +msgstr "停止加速服务" + +msgid "Start Acc Service" +msgstr "启动加速服务" + +msgid "Acc Service Disabled" +msgstr "加速服务已被禁用" + +msgid "Acc Service Enabled" +msgstr "已启动" + +msgid "Acc Catalog Started" +msgstr "该设备类别加速已启用" + +msgid "Acc Catalog Stopped" +msgstr "该设备类别加速已停止" + +msgid "Acc Catalog Paused" +msgstr "该设备类别加速已暂停" diff --git a/package/lean/luci-app-leigod-acc/root/etc/config/accelerator b/package/lean/luci-app-leigod-acc/root/etc/config/accelerator new file mode 100644 index 000000000..270c193c1 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/root/etc/config/accelerator @@ -0,0 +1,24 @@ + +config system 'base' + option url 'https://opapi.nn.com/speed/router/plug/check' + option heart 'https://opapi.nn.com/speed/router/heartbeat' + option base_url 'https://opapi.nn.com/speed' + option enabled '0' + option tun '0' + option schedule_enabled '0' + option pause_time '01:00' + option username '' + option password '' + +config bind 'bind' + +config hardware 'device' + +config acceleration 'Phone' + +config acceleration 'PC' + +config acceleration 'Game' + +config acceleration 'Unknown' + diff --git a/package/lean/luci-app-leigod-acc/root/etc/init.d/acc b/package/lean/luci-app-leigod-acc/root/etc/init.d/acc new file mode 100755 index 000000000..f10dce812 --- /dev/null +++ b/package/lean/luci-app-leigod-acc/root/etc/init.d/acc @@ -0,0 +1,166 @@ +#!/bin/sh /etc/rc.common + +# start prio +START=50 +# use proc to start service +USE_PROCD=1 +# package name +PACKAGE_NAME="acc.ipk" +# binary dir +sbin_dir="/usr/sbin/leigod" +# binary name +binary_prefix="acc-gw.linux" + + +# download acceleration binary +download_acc_binary() { + echo "begin to download file... ..." + # create download + local url="http://119.3.40.126/${PACKAGE_NAME}" + echo "download path: ${url}" + local path="/tmp/${PACKAGE_NAME}" + local code=$(curl --connect-timeout 2 -L -s -k -o "${path}" -w "%{http_code}" "${url}") + for i in $(seq 1 2) + do + if [ "$?" != "0" -o "${code}" != "200" -o ! -f "${path}" ]; then + echo "download failed: ${code}" + rm -f ${path} + sleep 5 + continue + fi + echo "download success" + break + done + + echo "download file success... ..." +} + +# mkdir acc dir +mk_acc_dir() { + echo "begin to mkdir... ..." + # should make sure dir exist + local cmd="mkdir -p ${BINARY_DIR}" + echo "exec mkdir dir: ${cmd}" + local code=`$cmd` + echo "mkdir success... ..." +} + +# decompress file +decompress_file() { + echo "begin to decompress file... ..." + # compress file path + local path="/tmp/${PACKAGE_NAME}" + # decompress command + local cmd="tar -zxvf ${path} -C ${BINARY_DIR}" + local code=`${cmd}` + echo "decompress file success... ..." +} + +# install ipk +install_package() { + echo "begin to overwrite package" + # local cmd = "opkg install /tmp/${PACKAGE_NAME} --force-overwrite" + # `$cmd` + echo "overwrite finish, begin to start" +} + +# main +prepare_env() { + # mkdir + mk_acc_dir + # download file + download_acc_binary + # decompress file + install_package +} + +main() { + prepare_env +} + +# get_device_arch, +# current support arch: arm64 arm x86_64 mips +get_device_arch() { + arch=$(uname -m) + if [ $? != "0" ]; then + echo "arch cant be get" + return -1 + fi + # fix arch + if [ ${arch} == "x86_64" ]; then + echo "match x86_64 -> amd64" + arch="amd64" + elif [ ${arch} == "aarch64" ]; then + echo "match aarch64 -> arm64" + arch="arm64" + elif [ ${arch} == "mips" ]; then + echo "match mips -> mipsle" + arch="mipsle" + elif [ ${arch} == "armv7l" ]; then + echo "match armv7l -> arm" + arch="arm" + fi + return 0 +} + +# get_xiaomi_name check if is xiaomi +get_xiaomi_name() { + local name=$(uci get misc.hardware.displayName) + if [[ $? == "0" && ${name} != "" ]]; then + echo "router is xiaomi series, name: ${name}" + sbin_dir="/userdisk/appdata/leigod" + init_dir="/userdisk/appdata/leigod" + args="--mode tun" + is_xiaomi=true + return 0 + fi + local name=$(uci get misc.hardware.model) + if [[ $? == "0" && ${name} != "" ]]; then + echo "router is xiaomi series, name: ${name}" + sbin_dir="/userdisk/appdata/leigod" + init_dir="/userdisk/appdata/leigod" + args="--mode tun" + is_xiaomi=true + return 0 + fi + echo "router is not xiaomi, use general openwrt" + sbin_dir="/usr/sbin/leigod" + init_dir="/etc/init.d" + return 0 +} + +# run service as daemon +start_service_daemon() { + # open once instance + procd_open_instance + # run binary + local cmd="${sbin_dir}/${binary_prefix}.${arch} ${args}" + echo "start service: ${cmd}" + procd_set_param command ${cmd} + # auto start when failed + procd_set_param respawn + # close instance + procd_close_instance + # start check update + # update_plugin & +} + + +# proc start service +start_service() { + + config_load "accelerator" + + local enabled + config_get_bool enabled base enabled 0 + + local tun + config_get_bool tun base tun 0 + + [ "${enabled}" -gt 0 ] || return + [ "${tun}" -eq 1 ] && args="--mode tun" + + get_device_arch + start_service_daemon +} + diff --git a/package/lean/luci-app-leigod-acc/root/etc/uci-defaults/99-accelerator-config b/package/lean/luci-app-leigod-acc/root/etc/uci-defaults/99-accelerator-config new file mode 100755 index 000000000..a71fd006c --- /dev/null +++ b/package/lean/luci-app-leigod-acc/root/etc/uci-defaults/99-accelerator-config @@ -0,0 +1,29 @@ +#!/bin/sh + +# check if file exist +if [ ! -f /etc/config/accelerator ]; then + echo "file not exist, should create..." + touch /etc/config/accelerator + uci set accelerator.base=system + uci set accelerator.device=hardware + uci set accelerator.Phone=acceleration + uci set accelerator.PC=acceleration + uci set accelerator.Game=acceleration + uci set accelerator.Unknown=acceleration + uci commit accelerator +fi + +uci set accelerator.base.url='https://opapi.nn.com/speed/router/plug/check' +uci set accelerator.base.heart='https://opapi.nn.com/speed/router/heartbeat' +uci set accelerator.base.base_url='https://opapi.nn.com/speed' +uci commit accelerator + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@accelerator[-1] + add ucitrack accelerator + set ucitrack.@accelerator[-1].init=acc + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/package/lean/luci-app-leigod-acc/root/www/leigodapp.png b/package/lean/luci-app-leigod-acc/root/www/leigodapp.png new file mode 100644 index 000000000..dcf939e29 Binary files /dev/null and b/package/lean/luci-app-leigod-acc/root/www/leigodapp.png differ diff --git a/package/lean/luci-app-leigod-acc/root/www/leigodbind.png b/package/lean/luci-app-leigod-acc/root/www/leigodbind.png new file mode 100644 index 000000000..8d973fdab Binary files /dev/null and b/package/lean/luci-app-leigod-acc/root/www/leigodbind.png differ diff --git a/target/linux/x86/Makefile b/target/linux/x86/Makefile index eca96afaf..e3f18e4f0 100644 --- a/target/linux/x86/Makefile +++ b/target/linux/x86/Makefile @@ -17,7 +17,7 @@ KERNELNAME:=bzImage include $(INCLUDE_DIR)/target.mk -DEFAULT_PACKAGES += partx-utils mkf2fs e2fsprogs kmod-button-hotplug kmod-usb-hid kmod-mmc kmod-sdhci kmod-fs-f2fs intel-microcode cfdisk usbutils pciutils \ +DEFAULT_PACKAGES += partx-utils mkf2fs e2fsprogs kmod-button-hotplug kmod-usb-hid kmod-mmc kmod-sdhci kmod-fs-f2fs amd64-microcode intel-microcode cfdisk usbutils pciutils \ kmod-alx kmod-e1000e kmod-igb kmod-igc kmod-igbvf kmod-iavf kmod-bnx2x kmod-pcnet32 kmod-tulip kmod-via-velocity kmod-vmxnet3 kmod-i40e kmod-i40evf \ kmod-sound-hda-core kmod-sound-hda-codec-realtek kmod-sound-hda-codec-via kmod-sound-via82xx kmod-sound-hda-intel kmod-sound-hda-codec-hdmi kmod-sound-i8x0 \ kmod-usb-net kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8150 kmod-usb-net-aqc111 kmod-mlx4-core kmod-mlx5-core kmod-drm-i915 kmod-drm-amdgpu kmod-usb-audio \