make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
PKG_NAME = my_pkg # name of the package
|
|
|
|
PKG_URL = http://example.com/downloads # source url of the package e.g. a git repository
|
|
|
|
PKG_VERSION = v1.2.3 # version of the package to use e.g. a git commit/ref
|
|
|
|
PKG_EXT = zip # extension of this package
|
2020-01-06 00:29:55 +01:00
|
|
|
PKG_LICENSE = MIT # license of the package
|
2013-11-18 12:30:01 +01:00
|
|
|
|
2014-10-01 21:51:46 +02:00
|
|
|
ifneq ($(RIOTBASE),)
|
|
|
|
include $(RIOTBASE)/Makefile.base
|
|
|
|
endif
|
|
|
|
|
2014-07-22 23:59:22 +02:00
|
|
|
.PHONY: all clean patch distclean
|
2013-11-18 12:30:01 +01:00
|
|
|
|
|
|
|
all: patch
|
2014-07-22 23:59:22 +02:00
|
|
|
$(MAKE) -C $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION)
|
2013-11-18 12:30:01 +01:00
|
|
|
|
|
|
|
patch: $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION)/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)-$(PKG_VERSION)/Makefile: $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION)/
|
|
|
|
# Here you apply your patch.
|
|
|
|
cd $< && patch ../patch.txt
|
|
|
|
|
|
|
|
$(CURDIR)/$(PKG_NAME)-$(PKG_VERSION)/: $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION).$(PKG_EXT)
|
make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
# Here you unpack the file.
|
|
|
|
# This example assumes the common pattern that the archive contains its data in a subfolder with the same name as itself.
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)$(UNZIP_HERE) $<
|
2013-11-18 12:30:01 +01:00
|
|
|
|
|
|
|
$(CURDIR)/$(PKG_NAME)-$(PKG_VERSION).$(PKG_EXT):
|
|
|
|
# Get PKG_VERSION of package from PKG_URL
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)$(DOWNLOAD_TO_FILE) $@ $(PKG_URL)/$(PKG_NAME)-$(PKG_VERSION).$(PKG_EXT)
|
2013-11-18 12:30:01 +01:00
|
|
|
|
|
|
|
clean::
|
|
|
|
# Reset package to checkout state.
|
|
|
|
rm -rf $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION) && \
|
2014-07-22 23:59:22 +02:00
|
|
|
$(MAKE) $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION)/Makefile
|
2013-11-18 12:30:01 +01:00
|
|
|
|
2014-07-22 23:59:22 +02:00
|
|
|
distclean::
|
2013-11-18 12:30:01 +01:00
|
|
|
rm -rf $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION) $(CURDIR)/$(PKG_NAME)-$(PKG_VERSION).$(PKG_EXT)
|