From 5906f18a81597e6e9b132a1d14baf57f1b4b0f0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= <rene.kijewski@fu-berlin.de>
Date: Tue, 28 Jan 2014 17:58:39 +0100
Subject: [PATCH] Add USEPKG variable for Makefiles

Currently pkg/USING says one should use
`EXTERNAL+=$(RIOTBASE)/pkg/<pkg_name>` to enable PKG modules.
Using this line the PKG will be compiled but not linked.

This change adds a USEPKG variable to be used like
`USEPKG += <pkg_name>`, which looks less clumsy and gets the PKG linked
in the binary.
---
 Makefile.include | 5 +++--
 pkg/USING        | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.include b/Makefile.include
index 3209ca8c80..59f5b57308 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -49,6 +49,7 @@ include $(RIOTBASE)/Makefile.dep
 # your binaries to link
 BASELIBS += $(BINDIR)$(BOARD)_base.a
 BASELIBS += $(BINDIR)${PROJECT}.a
+BASELIBS += $(USEPKG:%=${BINDIR}%.a)
 
 .PHONY: all clean flash doc term
 
@@ -57,7 +58,7 @@ all: $(BINDIR)$(PROJECT).a
 	@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)."
 	"$(MAKE)" -C $(RIOTBOARD)/$(BOARD)
 	"$(MAKE)" -C $(RIOTBASE)
-	@for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i ; done ;
+	@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i ; done ;
 ifeq ($(BUILDOSXNATIVE),1)
 	$(AD)$(LINK) $(UNDEF) -o $(BINDIR)$(PROJECT).elf $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
 else
@@ -91,7 +92,7 @@ $(BINDIR)$(PROJECT)/%.o: %.c $(PROJDEPS)
 clean:
 	"$(MAKE)" -C $(RIOTBOARD)/$(BOARD) clean
 	"$(MAKE)" -C $(RIOTBASE) clean
-	@for i in $(EXTERNAL_MODULES) ; do "$(MAKE)" -C $$i clean ; done ;
+	@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i clean ; done ;
 	rm -rf $(BINDIR)
 
 flash: all
diff --git a/pkg/USING b/pkg/USING
index c19ec531b6..06964f2813 100644
--- a/pkg/USING
+++ b/pkg/USING
@@ -2,4 +2,4 @@ Packages are included to your project as external modules. Thus you only have
 to add the following line to your project (and update your INCLUDE path
 accordingly):
 
-EXTERNAL+=$(RIOTBASE)/pkg/<pkg_name>
+USEPKG += <pkg_name>
-- 
GitLab