Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: unify git checkout #5138

Merged
merged 13 commits into from
Mar 23, 2016
34 changes: 4 additions & 30 deletions pkg/Makefile.git
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
PKG_NAME= # name of the package
PKG_URL= # source url of the package e.g. a git repository
PKG_URL= # source url of the package's git repository
PKG_VERSION= # version of the package to use e.g. a git commit/ref

ifneq ($(RIOTBOARD),)
include $(RIOTBOARD)/Makefile.base
include $(RIOTBOARD)/$(BOARD)/Makefile.include
endif
.PHONY: all

.PHONY: all clean patch distclean

all: patch
all: download
$(MAKE) -C $(CURDIR)/$(PKG_NAME)

patch: $(CURDIR)/$(PKG_NAME)/Makefile
# Dependancy might be changed accordingly though we think the Makefile
# will be the first thing you want to change
#
# Here might not happen anything besides dependancy checks

$(CURDIR)/$(PKG_NAME)/Makefile: $(CURDIR)/$(PKG_NAME)
# Here you apply your patch.
$(foreach patch,$(shell ls [0-9][0-9][0-9][0-9]*.patch),cd "$<" && git am "$(patch)" || { git am --abort; exit 1; };)

$(PKG_NAME):
# Get PKG_VERSION of package from PKG_URL
git clone $(PKG_URL) $(PKG_NAME) && cd $(PKG_NAME) && git reset --hard $(PKG_VERSION)

clean::
# Reset package to checkout state.
cd $(CURDIR)/$(PKG_NAME) || true && \
git clean -x -f && \
git reset --hard $(PKG_VERSION)

distclean::
rm -rf $(CURDIR)/$(PKG_NAME)
include $(RIOTBASE)/pkg/pkg.mk
1 change: 0 additions & 1 deletion pkg/ccn-lite/.gitignore

This file was deleted.

30 changes: 7 additions & 23 deletions pkg/ccn-lite/Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
PKG_NAME=ccn-lite
PKG_URL=https://github.com/OlegHahm/ccn-lite/
PKG_VERSION=39b1406c11de9de364220909488eebabe7e81613
PKG_DIR=$(CURDIR)/$(PKG_NAME)

.PHONY: all clean distclean
.PHONY: all

export RIOT_CFLAGS = ${CFLAGS} ${INCLUDES}

all: $(PKG_DIR)/Makefile
"$(MAKE)" -BC $(PKG_DIR)/src lib-ccn-lite.a
"$(MAKE)" -BC $(PKG_DIR)/src lib-ccn-lite-utils.a
cp $(PKG_DIR)/src/lib-ccn-lite.a ${BINDIR}/ccn-lite.a
cp $(PKG_DIR)/src/lib-ccn-lite-utils.a ${BINDIR}/ccn-lite-utils.a
all: download
"$(MAKE)" -BC $(PKG_BUILDDIR)/src lib-ccn-lite.a
"$(MAKE)" -BC $(PKG_BUILDDIR)/src lib-ccn-lite-utils.a
cp $(PKG_BUILDDIR)/src/lib-ccn-lite.a ${BINDIR}/ccn-lite.a
cp $(PKG_BUILDDIR)/src/lib-ccn-lite-utils.a ${BINDIR}/ccn-lite-utils.a

$(PKG_DIR)/Makefile: $(PKG_DIR)/.git/config

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || $(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_DIR)"

clean::
@echo "Cleaning up CCN-Lite package..."
@cd "$(PKG_DIR)" 2> /dev/null > /dev/null && \
git clean -x -f && \
git reset --hard "$(PKG_VERSION)"

distclean::
rm -rf "$(PKG_DIR)"

Makefile.include:
@true
include $(RIOTBASE)/pkg/pkg.mk
2 changes: 1 addition & 1 deletion pkg/ccn-lite/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INCLUDES += -I$(RIOTPKG)/ccn-lite -I$(RIOTPKG)/ccn-lite/ccn-lite/src
INCLUDES += -I$(RIOTPKG)/ccn-lite -I$(BINDIR)/pkg/ccn-lite/src
INCLUDES += -I$(RIOTBASE)/sys/posix/include
1 change: 0 additions & 1 deletion pkg/cmsis-dsp/.gitignore

This file was deleted.

23 changes: 4 additions & 19 deletions pkg/cmsis-dsp/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
PKG_NAME=cmsis-dsp
PKG_URL=https://github.com/gebart/CMSIS-DSP.git
PKG_VERSION=v1.4.5a-riot1
PKG_DIR=$(CURDIR)/$(PKG_NAME)

ifneq ($(RIOTBASE),)
include $(RIOTBASE)/Makefile.base
endif

.PHONY: all clean patch distclean
.PHONY: all

all: $(PKG_DIR)/Makefile
$(MAKE) -C $(CURDIR)/$(PKG_NAME)
all: download
$(MAKE) -C $(PKG_BUILDDIR)

$(PKG_DIR)/Makefile: $(PKG_DIR)/.git/config
@

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || $(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_DIR)"

clean::
@echo "Cleaning up $(PKG_NAME) package..."
@-cd "$(PKG_DIR)" 2> /dev/null > /dev/null && \
git clean -x -f && \
git am --abort && \
git reset --hard "$(PKG_VERSION)"

distclean::
rm -rf "$(PKG_DIR)"
include $(RIOTBASE)/pkg/pkg.mk
2 changes: 1 addition & 1 deletion pkg/cmsis-dsp/Makefile.include
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INCLUDES += -I$(RIOTPKG)/cmsis-dsp/cmsis-dsp/include
INCLUDES += -I$(BINDIR)/pkg/cmsis-dsp/include
1 change: 0 additions & 1 deletion pkg/libcoap/.gitignore

This file was deleted.

30 changes: 4 additions & 26 deletions pkg/libcoap/Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
PKG_NAME=libcoap
PKG_URL=https://github.com/obgm/libcoap
PKG_VERSION=ef41ce5d02d64cec0751882ae8fd95f6c32bc018
PKG_DIR=$(CURDIR)/$(PKG_NAME)

ifneq ($(RIOTBASE),)
INCLUDES += -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net/include \
-I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include
endif

.PHONY: all clean patch reset
.PHONY: all

all: patch
"$(MAKE)" -C $(PKG_DIR)
all: download
"$(MAKE)" -C $(PKG_BUILDDIR)

patch: $(PKG_DIR)/Makefile

$(PKG_DIR)/Makefile: $(PKG_DIR)/.git/config
cd "$(PKG_DIR)" && git am --ignore-whitespace "$(CURDIR)"/*.patch

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || $(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_DIR)"

clean::
@echo "Cleaning up libcoap package..."
@cd "$(PKG_DIR)" 2> /dev/null > /dev/null && \
git clean -x -f && \
git am --abort && \
git reset --hard "$(PKG_VERSION)" && \
$(MAKE) patch || true


distclean::
rm -rf "$(PKG_DIR)"

Makefile.include:
@true
include $(RIOTBASE)/pkg/pkg.mk
2 changes: 1 addition & 1 deletion pkg/libcoap/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INCLUDES += -I$(RIOTPKG)/libcoap/libcoap \
INCLUDES += -I$(BINDIR)/pkg/libcoap \
-I$(RIOTBASE)/sys/posix/include \
-I$(RIOTBASE)/sys/net/include
1 change: 0 additions & 1 deletion pkg/micro-ecc/.gitignore

This file was deleted.

29 changes: 3 additions & 26 deletions pkg/micro-ecc/Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
PKG_NAME=micro-ecc
PKG_URL=https://github.com/kmackay/micro-ecc.git
PKG_VERSION=b6c0cdbe7d20af48b0c2a909a66ff00b093d1542
PKG_DIR=$(CURDIR)
PKG_BUILDDIR=$(BINDIR)/pkg/$(PKG_NAME)

ifneq ($(RIOTBASE),)
INCLUDES += -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net/include \
-I$(RIOTBASE)/sys/posix/include
endif

MODULE:=$(shell basename $(CURDIR))
.PHONY: all

.PHONY: all clean patch reset

all: patch
all: download
make -C $(PKG_BUILDDIR)
make $(BINDIR)$(MODULE).a

patch: $(PKG_BUILDDIR)/Makefile

$(PKG_BUILDDIR)/Makefile: $(PKG_BUILDDIR)
cd $(PKG_BUILDDIR) && \
for patch in $(PKG_DIR)/[0-9][0-9][0-9][0-9]*.patch; do git am "$${patch}" || { git am --abort; exit 1; }; done
touch $(PKG_BUILDDIR)/Makefile

$(PKG_BUILDDIR):
mkdir -p $(BINDIR)/pkg && \
$(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_BUILDDIR)"

clean::
rm -Rf $(PKG_BUILDDIR)

distclean::
rm -rf $(PKG_BUILDDIR)

#$(BINDIR)$(MODULE).a: $(BINDIR)micro-ecc_*.a
# mkdir -p $(BINDIR)$(MODULE); cd $(BINDIR)$(MODULE); for var in $?; do ar -x $$var; done; ar -r -c -s $(BINDIR)$(MODULE).a *.o
include $(RIOTBASE)/pkg/pkg.mk
1 change: 0 additions & 1 deletion pkg/microcoap/.gitignore

This file was deleted.

30 changes: 4 additions & 26 deletions pkg/microcoap/Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
PKG_NAME=microcoap
PKG_URL=git://github.com/1248/microcoap.git
PKG_VERSION=9cb1dcda2182a8dca8483b230cda8b591a924c82
PKG_DIR=$(CURDIR)/$(PKG_NAME)

ifneq ($(RIOTBASE),)
INCLUDES += -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net/include \
-I$(RIOTBASE)/sys/posix/include
endif

.PHONY: all clean patch reset
.PHONY: all

all: patch
"$(MAKE)" -C $(PKG_DIR)
all: download
"$(MAKE)" -C $(PKG_BUILDDIR)

patch: $(PKG_DIR)/Makefile

$(PKG_DIR)/Makefile: $(PKG_DIR)/.git/config
cd "$(PKG_DIR)" && git am --ignore-whitespace "$(CURDIR)"/*.patch

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || $(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_DIR)"

clean::
@echo "Cleaning up $(PKG_NAME) package..."
@cd "$(PKG_DIR)" 2> /dev/null > /dev/null && \
git clean -x -f && \
git am --abort && \
git reset --hard "$(PKG_VERSION)" && \
$(MAKE) patch || true


distclean::
rm -rf "$(PKG_DIR)"

Makefile.include:
@true
include $(RIOTBASE)/pkg/pkg.mk
2 changes: 1 addition & 1 deletion pkg/microcoap/Makefile.include
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INCLUDES += -I$(RIOTPKG)/microcoap/microcoap
INCLUDES += -I$(BINDIR)/pkg/microcoap
1 change: 0 additions & 1 deletion pkg/oonf_api/.gitignore

This file was deleted.

31 changes: 5 additions & 26 deletions pkg/oonf_api/Makefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
PKG_NAME=oonf_api
PKG_URL=https://github.com/OLSR/OONF.git
PKG_VERSION=v0.3.0
PKG_DIR=$(CURDIR)/$(PKG_NAME)

ifneq ($(RIOTBASE),)
INCLUDES += -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net/include \
-I$(RIOTBASE)/sys/posix/include
endif

MODULE:=$(shell basename $(CURDIR))
MODULE:=$(PKG_NAME)

.PHONY: all clean patch reset
.PHONY: all

all: patch
"$(MAKE)" -C $(PKG_DIR)
all: download
"$(MAKE)" -C $(PKG_BUILDDIR)
"$(MAKE)" $(BINDIR)$(MODULE).a

patch: $(PKG_DIR)/Makefile

$(PKG_DIR)/Makefile: $(PKG_DIR)/.git/config
cd "$(PKG_DIR)" && git am --ignore-whitespace "$(CURDIR)"/*.patch

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || $(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_DIR)"

clean::
@echo "Cleaning up oonf_api package..."
@cd "$(PKG_DIR)" 2> /dev/null > /dev/null && \
git clean -x -f && \
git am --abort && \
git reset --hard "$(PKG_VERSION)" && \
$(MAKE) patch || true

distclean::
rm -rf $(PKG_DIR)

$(BINDIR)$(MODULE).a: $(BINDIR)oonf_*.a
mkdir -p $(BINDIR)$(MODULE); cd $(BINDIR)$(MODULE); for var in $?; do ar -x $$var; done; ar -r -c -s $(BINDIR)$(MODULE).a *.o

Makefile.include:
@true
include $(RIOTBASE)/pkg/pkg.mk
2 changes: 1 addition & 1 deletion pkg/oonf_api/Makefile.include
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INCLUDES += -I$(RIOTPKG)/oonf_api/oonf_api/src-api
INCLUDES += -I$(BINDIR)/pkg/oonf_api/src-api
1 change: 0 additions & 1 deletion pkg/openwsn/.gitignore

This file was deleted.

27 changes: 3 additions & 24 deletions pkg/openwsn/Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
PKG_NAME=openwsn
PKG_URL=https://github.com/openwsn-berkeley/openwsn-fw.git
PKG_VERSION=ff25e5d0ae5d344ed793a724d60532fb917bf1f8
PKG_DIR=$(CURDIR)/$(PKG_NAME)

.PHONY: all clean patch reset
.PHONY: all

all: patch
all: download
"$(MAKE)" -C $(PKG_DIR)

patch: $(PKG_DIR)/Makefile

$(PKG_DIR)/Makefile: $(PKG_DIR)/.git/config
cd "$(PKG_DIR)" && git am --ignore-whitespace $(CURDIR)/*.patch

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || $(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_DIR)"

clean::
@echo "Cleaning up OpenWSN package..."
@cd "$(PKG_DIR)" 2> /dev/null > /dev/null && \
git clean -x -f && \
git am --abort ; \
git reset --hard "$(PKG_VERSION)" && \
$(MAKE) patch || true

distclean::
rm -rf "$(PKG_DIR)"

Makefile.include:
@true
include $(RIOTBASE)/pkg/pkg.mk
22 changes: 22 additions & 0 deletions pkg/pkg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Include this file if your Package needs to be checked out by git
#
PKG_DIR?=$(CURDIR)
PKG_BUILDDIR?=$(BINDIR)/pkg/$(PKG_NAME)

download: $(PKG_BUILDDIR)/.downloaded

$(PKG_BUILDDIR)/.downloaded:
mkdir -p $(PKG_BUILDDIR)
$(GITCACHE) clone "$(PKG_URL)" "$(PKG_VERSION)" "$(PKG_BUILDDIR)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not every package must be a git repository. I would prefer to call the file pkg.git.mk or something like that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I called it "pkg.mk" because we will extend it, and then either some logic will decide wether a pkg is "git", or the targets can be called "git-checkout", or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@authmillenon you fine with this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

if test -d "$(PKG_DIR)"/patches; then \
git -C "$(PKG_BUILDDIR)" am --ignore-whitespace "$(PKG_DIR)"/patches/*.patch; \
fi
touch $(PKG_BUILDDIR)/.downloaded

clean::
@echo "Cleaning package $(PKG_NAME)..."
rm -rf "$(PKG_BUILDDIR)"

distclean::
rm -rf "$(PKG_BUILDDIR)"
1 change: 0 additions & 1 deletion pkg/relic/.gitignore

This file was deleted.

Loading