Просмотр исходного кода

ncd: detect non-presence of linux/rfkill.h and don't build rfkill support if it's not present

ambrop7 15 лет назад
Родитель
Сommit
edb867376c
3 измененных файлов с 19 добавлено и 2 удалено
  1. 6 0
      CMakeLists.txt
  2. 9 2
      ncd/CMakeLists.txt
  3. 4 0
      ncd/modules/modules.h

+ 6 - 0
CMakeLists.txt

@@ -72,6 +72,12 @@ else ()
             message(FATAL_ERROR "epoll is required")
         endif ()
         add_definitions(-DBADVPN_USE_EPOLL)
+
+        check_include_files(linux/rfkill.h HAVE_LINUX_RFKILL_H)
+        if (HAVE_LINUX_RFKILL_H)
+            add_definitions(-DBADVPN_USE_LINUX_RFKILL)
+            set(BADVPN_USE_LINUX_RFKILL 1)
+        endif ()
     elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
         add_definitions(-DBADVPN_FREEBSD)
 

+ 9 - 2
ncd/CMakeLists.txt

@@ -1,10 +1,17 @@
+set(NCD_ADDITIONAL_SOURCES)
+if (BADVPN_USE_LINUX_RFKILL)
+    list(APPEND NCD_ADDITIONAL_SOURCES
+        NCDRfkillMonitor.c
+        modules/net_backend_rfkill.c
+    )
+endif ()
+
 add_executable(badvpn-ncd
     ncd.c
     NCDValue.c
     NCDModule.c
     NCDIfConfig.c
     NCDInterfaceMonitor.c
-    NCDRfkillMonitor.c
     modules/command_template.c
     modules/var.c
     modules/list.c
@@ -22,13 +29,13 @@ add_executable(badvpn-ncd
     modules/net_backend_waitlink.c
     modules/net_backend_badvpn.c
     modules/net_backend_wpa_supplicant.c
-    modules/net_backend_rfkill.c
     modules/net_up.c
     modules/net_dns.c
     modules/net_iptables.c
     modules/net_ipv4_addr.c
     modules/net_ipv4_route.c
     modules/net_ipv4_dhcp.c
+    ${NCD_ADDITIONAL_SOURCES}
 )
 target_link_libraries(badvpn-ncd system dhcpclient ncdconfig process)
 

+ 4 - 0
ncd/modules/modules.h

@@ -43,7 +43,9 @@ extern const struct NCDModuleGroup ncdmodule_net_backend_waitdevice;
 extern const struct NCDModuleGroup ncdmodule_net_backend_waitlink;
 extern const struct NCDModuleGroup ncdmodule_net_backend_badvpn;
 extern const struct NCDModuleGroup ncdmodule_net_backend_wpa_supplicant;
+#ifdef BADVPN_USE_LINUX_RFKILL
 extern const struct NCDModuleGroup ncdmodule_net_backend_rfkill;
+#endif
 extern const struct NCDModuleGroup ncdmodule_net_up;
 extern const struct NCDModuleGroup ncdmodule_net_dns;
 extern const struct NCDModuleGroup ncdmodule_net_iptables;
@@ -68,7 +70,9 @@ static const struct NCDModuleGroup *ncd_modules[] = {
     &ncdmodule_net_backend_waitlink,
     &ncdmodule_net_backend_badvpn,
     &ncdmodule_net_backend_wpa_supplicant,
+#ifdef BADVPN_USE_LINUX_RFKILL
     &ncdmodule_net_backend_rfkill,
+#endif
     &ncdmodule_net_up,
     &ncdmodule_net_dns,
     &ncdmodule_net_iptables,