From 8b6739a16cf7be260c36d15ac970889eb8823181 Mon Sep 17 00:00:00 2001 From: CN_SZTL <22235437+1715173329@users.noreply.github.com> Date: Thu, 17 Jun 2021 00:57:53 +0800 Subject: [PATCH] build: format OpenWrt Makefile and fix CMakeLists (#23) * style: format OpenWrt Makefile Signed-off-by: Tianling Shen * fix: remove obsolete targets in CMakeLists Fixes: 661334b48ed2b3 ("chore: remove reference") Signed-off-by: Tianling Shen * fix: remove compile warnings Signed-off-by: Tianling Shen --- CMakeLists.txt | 12 ++---------- Makefile | 23 ++++++++--------------- src/ua2f.c | 2 +- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97431c2..10ba991 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,15 +6,7 @@ set(CMAKE_C_STANDARD 11) include_directories("/usr/local/include") add_executable(ua2f src/ua2f.c) -add_executable(test test/test.c) -add_executable(nf-queue ref/nf-queue.c) -add_executable(clocktest test/clocktest.c) -add_executable(nfct-event ref/nfct-event.c) -add_executable(nfq test/nfq.c) target_link_libraries(ua2f mnl netfilter_queue ipset) -target_link_libraries(nfct-event mnl netfilter_conntrack) -target_link_libraries(nf-queue mnl netfilter_queue ipset) -target_link_libraries(test mnl netfilter_queue ipset) -target_link_libraries(clocktest mnl netfilter_queue) -target_link_libraries(nfq mnl netfilter_queue) + +install(TARGETS ua2f RUNTIME DESTINATION bin) diff --git a/Makefile b/Makefile index 6764102..f2952ac 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,10 @@ include $(TOPDIR)/rules.mk PKG_NAME:=UA2F PKG_VERSION:=3.7 +PKG_RELEASE:=11 -PKG_RELEASE:=10 - - -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) - -TARGET_LDFLAGS+=-lmnl -lnetfilter_queue -lipset +PKG_LICENSE:=GPL-3.0-only +PKG_LICENSE_FILE:=LICENSE include $(INCLUDE_DIR)/package.mk @@ -18,27 +15,23 @@ define Package/ua2f SUBMENU:=Routing and Redirection TITLE:=Change User-Agent to Fwords URL:=https://github.com/Zxilly/UA2F - DEPENDS:=+libmnl +libnetfilter-queue +iptables-mod-nfqueue +libipset + DEPENDS:=+iptables-mod-nfqueue +libipset +libnetfilter-conntrack +libnetfilter-queue endef define Package/ua2f/description Change User-agent to Fwords to prevent being checked by Dr.Com. endef -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - cp ./src/* $(PKG_BUILD_DIR) - $(Build/Patch) -endef +EXTRA_LDFLAGS += -lmnl -lnetfilter_queue -lipset define Build/Compile - $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/ua2f.o -c $(PKG_BUILD_DIR)/ua2f.c - $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/ua2f.o + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(EXTRA_LDFLAGS) \ + $(PKG_BUILD_DIR)/src/ua2f.c -o $(PKG_BUILD_DIR)/src/ua2f endef define Package/ua2f/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/ua2f $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/ua2f $(1)/usr/bin/ $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./init/ua2f $(1)/etc/init.d/ua2f endef diff --git a/src/ua2f.c b/src/ua2f.c index c0bc29e..a575424 100644 --- a/src/ua2f.c +++ b/src/ua2f.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include