Skip to content
Snippets Groups Projects
Commit 2f66319a authored by René Kijewski's avatar René Kijewski
Browse files

make: OSX: don't fail for empty .a archives

Fixes issue #1333.
parent 33ad7c94
No related branches found
No related tags found
No related merge requests found
*.a binary
......@@ -54,6 +54,11 @@ include $(RIOTBOARD)/$(BOARD)/Makefile.include
include $(RIOTCPU)/$(CPU)/Makefile.include
include $(RIOTBASE)/Makefile.dep
# OSX fails to create empty archives. Provide a wrapper to catch that error.
ifneq (0, $(shell mkdir -p $(BINDIR); $(AR) -rc $(BINDIR)empty-archive.a 2> /dev/null; echo $$?))
AR := $(RIOTBASE)/dist/ar-wrapper $(AR)
endif
# Test if there where dependencies against a module in DISABLE_MODULE.
ifneq (, $(filter $(DISABLE_MODULE), $(USEMODULE)))
$(error "Required modules were disabled using DISABLE_MODULE: $(sort $(filter $(DISABLE_MODULE), $(USEMODULE)))")
......
#!/bin/sh
# This wrapper takes the arguments: <ar> <operation> <archive> <files...>
# <ar> can be any ar implementation.
# <operations>, <archive> and <files...> are the normal arguments to <ar>.
#
# OS X's ar implementation has the problem, that it refuses to create empty archives.
# This wrapper will copy a provided empty .a file to <archive> if it was told to.
# If <operations> contains "r", and there are no <files...> given.
if [ "${2#*r}" != "$2" ] && [ "$#" -eq 3 ]; then
# If <archive> exists, do nothing, otherwise copy an empty archive.
[ -e "$3" ] || cp "${0%ar-wrapper}/empty.a" "$3"
else
# Otherwise act like this wrapper was not present.
"$@"
fi
# Return the exit code of the last invocation ("[", "cp", or <ar>).
exit $?
dist/empty.a 0 → 100644
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment