Makefile: Fix-up new static library to allow linking to work
I made two mistakes in the previous CL:
* All code needs to be compiled with PIC in order to enable linking
* The static library needs to be libmosys.a such that -lmosys will find
the library.
BUG=chromium:788213
TEST=FEATURES=test USE=static emerge-reef mosys
BRANCH=none
Change-Id: Id8b1cd4fa0e7d40b819468700effac0b5f6d6f69
Reviewed-on: https://chromium-review.googlesource.com/789799
Commit-Ready: Jason Clinton <jclinton@chromium.org>
Tested-by: Jason Clinton <jclinton@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: C Shapiro <shapiroc@google.com>
diff --git a/.gitignore b/.gitignore
index 2a43919..f78d5c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@
include/config
include/generated
mosys
+mosys_s
+libmosys.a
diff --git a/Makefile b/Makefile
index 5eaa975..dc5f737 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
NAME="Mosys"
PROGRAM=mosys
PROGRAM_STATIC=$(PROGRAM)_s
-PROGRAM_LIB=mosys.a
+PROGRAM_LIB=lib$(PROGRAM).a
TARGETS=$(PROGRAM) $(PROGRAM_STATIC) $(PROGRAM_LIB)
# Mosys will use the following version format: core.major.minor-revision
@@ -302,7 +302,8 @@
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes \
-Werror-implicit-function-declaration \
- -Werror=format-security
+ -Werror=format-security \
+ -fPIC
KBUILD_AFLAGS := -D__ASSEMBLY__
@@ -594,7 +595,8 @@
$(LINUXINCLUDE) -o $@ $(PROGRAM).c $? -static $(LIBS_LIBFDT) $(LDLIBS)
$(PROGRAM_LIB): $(vmlinux-all)
- $(Q)$(AR) crus $@ $?
+ $(Q)$(LD) -r -o mosys.o $?
+ $(Q)$(AR) crus $@ mosys.o
simple_tests: $(vmlinux-all)
$(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CC_LDFLAGS) $(MOSYS_MACROS) \