Clean up shared library compile/link options

- Allow overriding of shared library compile time flags for platforms whic
  need it
- Include -fPIC in the link flags variable instead of including it raw
  in the target rule
- Cosmetic formatting tweaks

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2017-05-19 16:11:48 +10:00
parent 21a2bc896e
commit 51f56dedf8
1 changed files with 8 additions and 6 deletions

View File

@ -18,7 +18,7 @@ CONFIG_LOCALVERSION =
CPPFLAGS = -I libfdt -I .
WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
CFLAGS = -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS)
BISON = bison
LEX = flex
@ -37,10 +37,12 @@ HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
ifeq ($(HOSTOS),darwin)
SHAREDLIB_EXT = dylib
SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl,
SHAREDLIB_CFLAGS = -fPIC
SHAREDLIB_LDFLAGS = -fPIC -dynamiclib -Wl,-install_name -Wl,
else
SHAREDLIB_EXT = so
SHAREDLIB_LINK_OPTIONS=-shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,
SHAREDLIB_CFLAGS = -fPIC
SHAREDLIB_LDFLAGS = -fPIC -shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,
endif
#
@ -330,7 +332,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
$(LIBFDT_lib):
@$(VECHO) LD $@
$(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
$(CC) $(LDFLAGS) $(SHAREDLIB_LDFLAGS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
%.lex.c: %.l
@$(VECHO) LEX $@