1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/oonf_api/Makefile
Juan Carrano 55eccb689f pkg/oonf_api: Use MRI script to combine archives.
The OONF package is combining multiple ".a" file into a single archive. The
way it was being done involved creating and changing directories, unpacking
the original archives and repacking them into a combined one.

Theis has a couple of issues:

- It is untidy and wasteful.
- It breaks when thin archives are enabled, as a thin archive cannot be
  unpacked.

This commit uses a MRI script to do the combining step. It works both with
and without thin archives and is cleaner overall.

An issue that remains to be soved is that make is calling itself to create the
archive, as the PARTIAL_ARCHIVES are not known before hand. This is hacky. It
can be solved but it is a subject for another PR.
2019-09-02 16:50:35 +02:00

44 lines
864 B
Makefile

PKG_NAME=oonf_api
PKG_URL=https://github.com/OLSR/OONF.git
PKG_VERSION=v0.3.0
PKG_LICENSE=BSD-3-Clause
MODULE:=$(PKG_NAME)
# GCC 7.x fails on (intentional) fallthrough, thus disable implicit-fallthrough.
CFLAGS += -Wno-implicit-fallthrough
COMBINED_ARCHIVE = $(BINDIR)/$(MODULE).a
.PHONY: all
all:
"$(MAKE)" -C $(PKG_BUILDDIR)
"$(MAKE)" $(COMBINED_ARCHIVE)
PARTIAL_ARCHIVES = $(wildcard $(BINDIR)/oonf_*.a)
$(COMBINED_ARCHIVE): $(BINDIR)/$(MODULE).mri $(PARTIAL_ARCHIVES)
ar -M < $<
define ADDLIB_TEMPLATE
addlib $1
endef
define MRI_TEMPLATE
create $1
$(foreach a,$2,$(call ADDLIB_TEMPLATE,$a))
save
end
endef
$(BINDIR)/$(MODULE).mri:
$(file >$@,$(call MRI_TEMPLATE,$(COMBINED_ARCHIVE),$(PARTIAL_ARCHIVES)))
@true
include $(RIOTBASE)/pkg/pkg.mk
ifneq (,$(filter -Wformat-nonliteral -Wformat=2, $(CFLAGS)))
CFLAGS += -Wno-format-nonliteral
endif