From 84cffaa0a07971bd10fce4ccdace775139604920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Tue, 28 Jan 2014 21:12:55 +0100 Subject: [PATCH] Use include path convention for PKGs Packages have to define a Makefile.include target in pkg/%/Makefile. pkg/%/Makefile.include will be loaded after all other dependencies. --- Makefile.include | 19 ++++++++++++++++--- pkg/libcoap/Makefile | 3 +++ pkg/libcoap/Makefile.include | 1 + pkg/libcoap/include/coap.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 pkg/libcoap/Makefile.include create mode 100644 pkg/libcoap/include/coap.h diff --git a/Makefile.include b/Makefile.include index 59f5b57308..6bc01de23b 100644 --- a/Makefile.include +++ b/Makefile.include @@ -78,21 +78,34 @@ SRC = $(wildcard *.c) # string array of all names replaced .c with .o OBJ = $(SRC:%.c=${BINDIR}${PROJECT}/%.o) -$(BINDIR)$(PROJECT).a: $(OBJ) +$(BINDIR)$(PROJECT).a: $(OBJ) $(AD)$(AR) -rc $(BINDIR)$(PROJECT).a $(OBJ) +# include Makefile.includes for packages in $(USEPKG) +$(RIOTBASE)/pkg/%/Makefile.include:: + $(AD)"$(MAKE)" -C $(RIOTBASE)/pkg/$* Makefile.include + +.PHONY: $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include) + +-include $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include) + # pull in dependency info for *existing* .o files -include $(OBJ:.o=.d) -$(BINDIR)$(PROJECT)/%.o: %.c $(PROJDEPS) +$(BINDIR)$(PROJECT)/%.o: %.c $(PROJDEPS) $(USEPKG:%=${BINDIR}%.a) + @mkdir -p ${BINDIR} @echo; echo "Compiling.... $*.c"; echo @test -d $(BINDIR)$(PROJECT) || mkdir -p $(BINDIR)$(PROJECT) $(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$(PROJECT)/$*.o +$(USEPKG:%=${BINDIR}%.a):: + @mkdir -p ${BINDIR} + "$(MAKE)" -C $(RIOTBASE)/pkg/$(patsubst ${BINDIR}%.a,%,$@) + clean: + @for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i clean ; done ; "$(MAKE)" -C $(RIOTBOARD)/$(BOARD) clean "$(MAKE)" -C $(RIOTBASE) clean - @for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i clean ; done ; rm -rf $(BINDIR) flash: all diff --git a/pkg/libcoap/Makefile b/pkg/libcoap/Makefile index 089d1c2230..9a91f013bd 100644 --- a/pkg/libcoap/Makefile +++ b/pkg/libcoap/Makefile @@ -32,3 +32,6 @@ clean:: distclean:: rm -rf $(CURDIR)/$(PKG_NAME) + +Makefile.include: + @true diff --git a/pkg/libcoap/Makefile.include b/pkg/libcoap/Makefile.include new file mode 100644 index 0000000000..0fbf281463 --- /dev/null +++ b/pkg/libcoap/Makefile.include @@ -0,0 +1 @@ +INCLUDES += -I $(RIOTBASE)/pkg/libcoap/include diff --git a/pkg/libcoap/include/coap.h b/pkg/libcoap/include/coap.h new file mode 100644 index 0000000000..b61cbd780f --- /dev/null +++ b/pkg/libcoap/include/coap.h @@ -0,0 +1 @@ +#include "../libcoap/coap.h"