diff --git a/src/ap/Makefile b/src/ap/Makefile
index 09d54924c..9d67fb58b 100644
--- a/src/ap/Makefile
+++ b/src/ap/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libap.a
-
 include ../lib.rules
 
 install:
@@ -67,5 +65,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libap.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/common/Makefile b/src/common/Makefile
index 19573ebd3..a731c9230 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libcommon.a
-
 include ../lib.rules
 
 install:
@@ -21,5 +19,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libcommon.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/crypto/Makefile b/src/crypto/Makefile
index b8accd81c..b0e13bd1d 100644
--- a/src/crypto/Makefile
+++ b/src/crypto/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libcrypto.a
-
 include ../lib.rules
 
 install:
@@ -68,5 +66,3 @@ endif
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libcrypto.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/eap_common/Makefile b/src/eap_common/Makefile
index b50a4b731..c85d01de7 100644
--- a/src/eap_common/Makefile
+++ b/src/eap_common/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libeap_common.a
-
 include ../lib.rules
 
 install:
@@ -25,5 +23,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libeap_common.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/eap_peer/Makefile b/src/eap_peer/Makefile
index d7a0372ad..1ce905d8c 100644
--- a/src/eap_peer/Makefile
+++ b/src/eap_peer/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libeap_peer.a
-
 include ../lib.rules
 
 install:
@@ -17,5 +15,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libeap_peer.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/eap_server/Makefile b/src/eap_server/Makefile
index b4261ec39..c68565c07 100644
--- a/src/eap_server/Makefile
+++ b/src/eap_server/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libeap_server.a
-
 include ../lib.rules
 
 install:
@@ -15,5 +13,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libeap_server.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/eapol_auth/Makefile b/src/eapol_auth/Makefile
index aa597eda4..328e18f50 100644
--- a/src/eapol_auth/Makefile
+++ b/src/eapol_auth/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libeapol_auth.a
-
 include ../lib.rules
 
 install:
@@ -10,5 +8,3 @@ LIB_OBJS = eapol_auth_sm.o eapol_auth_dump.o
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libeapol_auth.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/eapol_supp/Makefile b/src/eapol_supp/Makefile
index 453e49e6b..108e66c4c 100644
--- a/src/eapol_supp/Makefile
+++ b/src/eapol_supp/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libeapol_supp.a
-
 include ../lib.rules
 
 install:
@@ -12,5 +10,3 @@ LIB_OBJS = eapol_supp_sm.o
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libeapol_supp.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/l2_packet/Makefile b/src/l2_packet/Makefile
index 870d652bc..5c69413f3 100644
--- a/src/l2_packet/Makefile
+++ b/src/l2_packet/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libl2_packet.a
-
 include ../lib.rules
 
 install:
@@ -10,5 +8,3 @@ LIB_OBJS = l2_packet_linux.o
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libl2_packet.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/lib.rules b/src/lib.rules
index 81b895967..99b7bd026 100644
--- a/src/lib.rules
+++ b/src/lib.rules
@@ -1,3 +1,6 @@
+_LIBMK := $(lastword $(wordlist 1,$(shell expr $(words $(MAKEFILE_LIST)) - 1),$(MAKEFILE_LIST)))
+_LIBNAME := $(notdir $(patsubst %/,%,$(dir $(abspath $(_LIBMK)))))
+ALL := $(OUT)lib$(_LIBNAME).a
 LIB_RULES := $(lastword $(MAKEFILE_LIST))
 include $(dir $(LIB_RULES))build.rules
 
@@ -9,5 +12,10 @@ endif
 CFLAGS += $(FUZZ_CFLAGS)
 CFLAGS += -I.. -I../utils
 
+.SECONDEXPANSION:
+$(ALL): $$(LIB_OBJS)
+	@$(E) "  AR  $(notdir $@)"
+	$(Q)$(AR) crT $@ $?
+
 clean:
 	$(Q)rm -f *~ *.o *.d *.gcno *.gcda *.gcov $(ALL)
diff --git a/src/p2p/Makefile b/src/p2p/Makefile
index 00e1908f0..0289dec5e 100644
--- a/src/p2p/Makefile
+++ b/src/p2p/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libp2p.a
-
 include ../lib.rules
 
 install:
@@ -23,5 +21,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libp2p.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/radius/Makefile b/src/radius/Makefile
index 5cefa390f..8d25400e9 100644
--- a/src/radius/Makefile
+++ b/src/radius/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libradius.a
-
 include ../lib.rules
 
 install:
@@ -16,5 +14,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libradius.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/rsn_supp/Makefile b/src/rsn_supp/Makefile
index f5f5cad17..25accf795 100644
--- a/src/rsn_supp/Makefile
+++ b/src/rsn_supp/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)librsn_supp.a
-
 include ../lib.rules
 
 install:
@@ -21,5 +19,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)librsn_supp.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/tls/Makefile b/src/tls/Makefile
index 5483345e5..0e79902ef 100644
--- a/src/tls/Makefile
+++ b/src/tls/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libtls.a
-
 include ../lib.rules
 
 install:
@@ -33,5 +31,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libtls.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/utils/Makefile b/src/utils/Makefile
index 91aba3846..fc7f4323d 100644
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libutils.a
-
 include ../lib.rules
 
 install:
@@ -36,5 +34,3 @@ LIB_OBJS += edit.o
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libutils.a: $(LIB_OBJS)
-	$(AR) crT $@ $?
diff --git a/src/wps/Makefile b/src/wps/Makefile
index 791069527..d7660fdd4 100644
--- a/src/wps/Makefile
+++ b/src/wps/Makefile
@@ -1,5 +1,3 @@
-ALL=$(OUT)libwps.a
-
 include ../lib.rules
 
 install:
@@ -35,5 +33,3 @@ LIB_OBJS= \
 
 _OBJS_VAR := LIB_OBJS
 include ../objs.mk
-$(OUT)libwps.a: $(LIB_OBJS)
-	$(AR) crT $@ $?