Makefile may use wrong archiver (ar) when cross-compiling
Related to https://github.com/NixOS/nixpkgs/pull/63999.
When cross compiling apparmor-parser
, Makefile
will use ar
for creating the static library. However, ar
produces libraries on the build platform. The right ar
could be prefixed with the target platform triples.
A proposed fix could be made with the following patch:
--- a/parser/libapparmor_re/Makefile 2018-10-14 07:38:06.000000000 +0800
+++ b/parser/libapparmor_re/Makefile 2019-06-28 16:16:33.741916660 +0800
@@ -10,6 +10,7 @@
TARGET=libapparmor_re.a
+AR ?= ar
CFLAGS ?= -g -Wall -O2 ${EXTRA_CFLAGS} -std=gnu++0x
CXXFLAGS := ${CFLAGS} ${INCLUDE_APPARMOR}
@@ -22,7 +23,7 @@
UNITTESTS = tst_parse
libapparmor_re.a: parse.o expr-tree.o hfa.o chfa.o aare_rules.o
- ar ${ARFLAGS} $@ $^
+ ${AR} ${ARFLAGS} $@ $^
expr-tree.o: expr-tree.cc expr-tree.h