Adjusting wpa_ctrl.c for use in/by external programs

Jouni Malinen j
Sat Feb 21 07:47:04 PST 2015


On Wed, Jan 28, 2015 at 11:45:20AM +0100, Rafa? Mi?ecki wrote:
> Documentation just says optimistic "External programs (...) should
> link in wpa_ctrl.c":
> http://w1.fi/hostapd/devel/ctrl_iface_page.html
> Easier said than done.

It was likely a bit easier at the time this comment was added, but yes,
this does involve getting some more files included in the current
design.

> 2) Make wpa_ctrl a separated library. A bit harder to achieve (one
> would need to known hostapd Makefile-s magic), but cleaner in the
> final result. Maybe a bit of overhead for such a small library, I
> don't know.

It is not really that complex to do that. I'll add a
wpa_supplicant/Makefile target to allow this to be generated:

[PATCH] Add wpa_supplicant Makefile target libwpa_ctrl.a

"make -C wpa_supplicant libwpa_ctrl.a" can now be used to build a static
library that can be linked with external programs using wpa_ctrl.h. This
makes it easier to create a separate library package that does not
depend in any other hostap.git file other than src/common/wpa_ctrl.h and
the libwpa_ctrl.a built with this new make target.

Signed-off-by: Jouni Malinen <j at w1.fi>
---
 wpa_supplicant/Makefile | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index 95fbe78..f2e82f8 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -105,6 +105,7 @@ OBJS += ../src/utils/trace.o
 OBJS_p += ../src/utils/trace.o
 OBJS_c += ../src/utils/trace.o
 OBJS_priv += ../src/utils/trace.o
+LIBCTRL += ../src/utils/trace.o
 LDFLAGS += -rdynamic
 CFLAGS += -funwind-tables
 ifdef CONFIG_WPA_TRACE_BFD
@@ -1636,6 +1637,15 @@ wpa_cli: $(OBJS_c)
 	$(Q)$(LDO) $(LDFLAGS) -o wpa_cli $(OBJS_c) $(LIBS_c)
 	@$(E) "  LD " $@
 
+LIBCTRL += ../src/common/wpa_ctrl.o
+LIBCTRL += ../src/utils/os_$(CONFIG_OS).o
+LIBCTRL += ../src/utils/wpa_debug.o
+
+libwpa_ctrl.a: $(LIBCTRL)
+	$(Q)rm -f $@
+	$(Q)$(AR) cr $@ $?
+	@$(E) "  AR " $@
+
 link_test: $(OBJS) $(OBJS_h) tests/link_test.o
 	$(Q)$(LDO) $(LDFLAGS) -o link_test $(OBJS) $(OBJS_h) tests/link_test.o $(LIBS)
 	@$(E) "  LD " $@
@@ -1755,5 +1765,6 @@ clean:
 	rm -f nfc_pw_token
 	rm -f lcov.info
 	rm -rf lcov-html
+	rm -f libwpa_ctrl.a
 
 -include $(OBJS:%.o=%.d)

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list