310-add-static-linking-option.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --- a/common.mk
  2. +++ b/common.mk
  3. @@ -2,6 +2,16 @@ CC := $(CROSS)gcc
  4. AR := $(CROSS)ar
  5. RANLIB := $(CROSS)ranlib
  6. +ifeq ($(STATIC),1)
  7. + define static_link
  8. + -Wl,-Bstatic $(1) -Wl,-Bdynamic
  9. + endef
  10. +else
  11. + define static_link
  12. + $(1)
  13. + endef
  14. +endif
  15. +
  16. # Stolen from Linux build system
  17. comma = ,
  18. try-run = $(shell set -e; ($(1)) >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
  19. --- a/Makefile
  20. +++ b/Makefile
  21. @@ -89,10 +89,10 @@ obj-mkfs.jffs2 = compr_rtime.o compr_zli
  22. compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o \
  23. compr.o rbtree.o
  24. LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
  25. -LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS)
  26. +LDLIBS_mkfs.jffs2 = $(call static_link,-lz $(LZOLDLIBS))
  27. LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
  28. -LDLIBS_jffs2reader = -lz $(LZOLDLIBS)
  29. +LDLIBS_jffs2reader = $(call static_link,-lz $(LZOLDLIBS))
  30. $(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
  31. @@ -114,7 +114,7 @@ else
  32. LZOLDLIBS = -llzo2
  33. endif
  34. -LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid
  35. +LDLIBS_mkfs.ubifs = $(call static_link,-lz $(LZOLDLIBS)) -lm $(call static_link,-luuid)
  36. $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a)
  37. #