libs/iwinfo: conditionally compile wl.o or madwifi support, make it depend on $(CRAP)
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 15 Nov 2009 15:53:35 +0000 (15:53 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 15 Nov 2009 15:53:35 +0000 (15:53 +0000)
libs/iwinfo/Makefile
libs/iwinfo/src/iwinfo.h
libs/iwinfo/src/iwinfo_lualib.c
libs/iwinfo/src/iwinfo_lualib.h

index 573dcae5a512e0bbdca402bc52090ae546d0f1c8..f9ce36abf422c2eae7606900ac8e77aaf80b0fda 100644 (file)
@@ -7,10 +7,10 @@ include standalone.mk
 endif
 
 IWINFO_LDFLAGS    =
-IWINFO_CFLAGS     = -fstrict-aliasing
+IWINFO_CFLAGS     = -fstrict-aliasing $(if $(CRAP),-DUSE_WL,-DUSE_MADWIFI)
 IWINFO_SO         = iwinfo.so
 IWINFO_LUA        = iwinfo.lua
-IWINFO_OBJ        = src/iwinfo_wl.o src/iwinfo_madwifi.o \
+IWINFO_OBJ        = $(if $(CRAP),src/iwinfo_wl.o,src/iwinfo_madwifi.o) \
        src/iwinfo_wext.o src/iwinfo_wext_scan.o src/iwinfo_lualib.o
 
 %.o: %.c
index f15e38327f7b5cf958766e0650f3d23658b21a3f..cbb9b69a3064ea0a4af4c35736de87e313743d56 100644 (file)
 #include <net/if.h>
 #include <errno.h>
 
+#include "iwinfo_wext.h"
+
+#ifdef USE_WL
 #include "iwinfo_wl.h"
+#endif
+
+#ifdef USE_MADWIFI
 #include "iwinfo_madwifi.h"
-#include "iwinfo_wext.h"
+#endif
 
 
 #define IWINFO_BUFSIZE 24 * 1024
index 61ad5d325fbade37e5a9552a285230ce2acec022..5509f4b6ae212fd8ff1c19c46ea1227bbe61840a 100644 (file)
@@ -23,13 +23,19 @@ static int iwinfo_L_type(lua_State *L)
 {
        const char *ifname = luaL_checkstring(L, 1);
 
+#ifdef USE_MADWIFI
        if( madwifi_probe(ifname) )
                lua_pushstring(L, "madwifi");
+       else
+#endif
 
-       else if( wl_probe(ifname) )
+#ifdef USE_WL
+       if( wl_probe(ifname) )
                lua_pushstring(L, "wl");
+       else
+#endif
 
-       else if( wext_probe(ifname) )
+       if( wext_probe(ifname) )
                lua_pushstring(L, "wext");
 
        else
@@ -244,6 +250,7 @@ static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int
        return 1;
 }
 
+#ifdef USE_WL
 /* Broadcom */
 LUA_WRAP_INT(wl,channel)
 LUA_WRAP_INT(wl,frequency)
@@ -261,7 +268,9 @@ LUA_WRAP_LIST(wl,assoclist)
 LUA_WRAP_LIST(wl,txpwrlist)
 LUA_WRAP_LIST(wl,scanlist)
 LUA_WRAP_LIST(wl,freqlist)
+#endif
 
+#ifdef USE_MADWIFI
 /* Madwifi */
 LUA_WRAP_INT(madwifi,channel)
 LUA_WRAP_INT(madwifi,frequency)
@@ -279,6 +288,7 @@ LUA_WRAP_LIST(madwifi,assoclist)
 LUA_WRAP_LIST(madwifi,txpwrlist)
 LUA_WRAP_LIST(madwifi,scanlist)
 LUA_WRAP_LIST(madwifi,freqlist)
+#endif
 
 /* Wext */
 LUA_WRAP_INT(wext,channel)
@@ -298,6 +308,7 @@ LUA_WRAP_LIST(wext,txpwrlist)
 LUA_WRAP_LIST(wext,scanlist)
 LUA_WRAP_LIST(wext,freqlist)
 
+#ifdef USE_WL
 /* Broadcom table */
 static const luaL_reg R_wl[] = {
        LUA_REG(wl,channel),
@@ -318,7 +329,9 @@ static const luaL_reg R_wl[] = {
        LUA_REG(wl,mbssid_support),
        { NULL, NULL }
 };
+#endif
 
+#ifdef USE_MADWIFI
 /* Madwifi table */
 static const luaL_reg R_madwifi[] = {
        LUA_REG(madwifi,channel),
@@ -339,6 +352,7 @@ static const luaL_reg R_madwifi[] = {
        LUA_REG(madwifi,mbssid_support),
        { NULL, NULL }
 };
+#endif
 
 /* Wext table */
 static const luaL_reg R_wext[] = {
@@ -371,17 +385,21 @@ static const luaL_reg R_common[] = {
 LUALIB_API int luaopen_iwinfo(lua_State *L) {
        luaL_register(L, IWINFO_META, R_common);
 
+#ifdef USE_WL
        luaL_newmetatable(L, IWINFO_WL_META);
        luaL_register(L, NULL, R_wl);
        lua_pushvalue(L, -1);
        lua_setfield(L, -2, "__index");
        lua_setfield(L, -2, "wl");
+#endif
 
+#ifdef USE_MADWIFI
        luaL_newmetatable(L, IWINFO_MADWIFI_META);
        luaL_register(L, NULL, R_madwifi);
        lua_pushvalue(L, -1);
        lua_setfield(L, -2, "__index");
        lua_setfield(L, -2, "madwifi");
+#endif
 
        luaL_newmetatable(L, IWINFO_WEXT_META);
        luaL_register(L, NULL, R_wext);
index bf7568a653560216d4a42911367a9c33610aee2d..72697983ff464d81f60d9e745fb6ebb83c314a65 100644 (file)
 
 
 #define IWINFO_META                    "iwinfo"
+#define IWINFO_WEXT_META       "iwinfo.wext"
+
+#ifdef USE_WL
 #define IWINFO_WL_META         "iwinfo.wl"
+#endif
+
+#ifdef USE_MADWIFI
 #define IWINFO_MADWIFI_META    "iwinfo.madwifi"
-#define IWINFO_WEXT_META       "iwinfo.wext"
+#endif
+
 
 #define LUA_REG(type,op) \
        { #op, iwinfo_L_##type##_##op }