llvm-ar behaves weidly when creating thin archive. This only manifests itself when using arduino sketches as these are built from the "bin" directory. Specifically, given a directory "m" and an object in "m/obj.o " an invocation with CWD==m: ``` llvm-ar rcTs ../m.a obj.o ``` Will create a maformed archive. Binutils does not have any issue with this. The following command, executed with CWD==m/.. works: ``` llvm-ar rcTs m.a m/obj.o ``` The trick used in this commit is to put the source files in a different directory than the object files and compile from there.
36 lines
1.5 KiB
Makefile
36 lines
1.5 KiB
Makefile
# Compile together the Arduino sketches of the application
|
|
# They are declared a as new module $(SKETCH_MODULE) in $(SKETCH_MODULE_DIR)
|
|
|
|
ifndef SKETCH_MODULE
|
|
$(error SKETCH_MODULE undefined. It should be defined to the sketches module name)
|
|
endif
|
|
ifndef SKETCH_MODULE_DIR
|
|
$(error SKETCH_MODULE_DIR undefined. It should be defined to the sketches module directory)
|
|
endif
|
|
ifndef SKETCHES
|
|
$(error SKETCHES undefined. It should be defined to the list of sketches files)
|
|
endif
|
|
|
|
SNIPDIR = $(RIOTBASE)/sys/arduino
|
|
SKETCHES_ALL = $(SNIPDIR)/pre.snip $(SKETCHES) $(SNIPDIR)/post.snip
|
|
SKETCH_CPP ?= arduino_sketches.cpp
|
|
SKETCH_GENERATED_FILES = $(SKETCH_MODULE_DIR)/Makefile $(SKETCH_MODULE_DIR)/$(SKETCH_CPP)
|
|
|
|
# Building the module files
|
|
# Do not use $^ in receipes as Makefile is also a prerequisite
|
|
$(SKETCH_MODULE_DIR)/Makefile: $(SKETCH_MODULE_DIR)/$(SKETCH_CPP)
|
|
$(Q)echo 'MODULE = $(SKETCH_MODULE)' > $@
|
|
$(Q)echo 'SRCXX = $(SKETCH_CPP)' >> $@
|
|
$(Q)echo 'include $$(RIOTBASE)/Makefile.base' >> $@
|
|
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(SKETCHES_ALL)
|
|
@mkdir -p $(@D)
|
|
$(Q)cat $(SKETCHES_ALL) > $@
|
|
|
|
# Make everything rebuild if current makefile changes
|
|
_ARDUINO_SKETCHES_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
|
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(_ARDUINO_SKETCHES_MAKEFILE)
|
|
$(SKETCH_MODULE_DIR)/Makefile: $(_ARDUINO_SKETCHES_MAKEFILE)
|
|
|
|
# HACK Rebuild cpp files everytime in case one of the `SKETCHES` is deleted
|
|
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): FORCE
|