summaryrefslogtreecommitdiff
path: root/Make.rules
diff options
context:
space:
mode:
Diffstat (limited to 'Make.rules')
-rw-r--r--Make.rules22
1 files changed, 20 insertions, 2 deletions
diff --git a/Make.rules b/Make.rules
index 3bdf267..9fd4862 100644
--- a/Make.rules
+++ b/Make.rules
@@ -70,7 +70,7 @@ INSTALL := install
INSTALLDIR := $(INSTALL) -d
CFLAGS ?= -g -O2
-CFLAGS_ALL := -Werror -Wall -Wstrict-prototypes -D_GNU_SOURCE -std=gnu99
+CFLAGS_ALL := -Werror -Wall -Wstrict-prototypes -D_GNU_SOURCE -std=gnu99 -fPIC
CFLAGS_ALL += $(CFLAGS)
LDFLAGS ?= -g
@@ -197,6 +197,24 @@ $(obj)/%.o: $(src)/%.c FORCE
$(call if_changed_rule,cc_o_c)
#####
+# Link shared libraries
+#
+__shlibs := $(addprefix $(obj)/,$(sort $(shlibs-y)))
+shobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(shlibs-y),$($(m)-objs))))
+
+# link shared library
+quiet_cmd_shlib = LD -shared $@
+ cmd_shlib = $(CC) $(ld_flags) -shared -o $@ \
+ $(addprefix $(obj)/,$($(@F)-objs)) \
+ $(LIBS) $(LIBS_$(@F))
+
+$(__shlibs): override local-target-prereqs=$(addprefix $(obj)/,$($(*F)-objs))
+
+$(__shlibs): $(obj)/%: $(shobjs) FORCE
+ $(call if_changed,shlib)
+
+targets += $(__shlibs) $(shobjs)
+#####
# Link programs
# Link an executable based on list of .o files, all plain c
@@ -256,7 +274,7 @@ ifeq ($(toplevelrun),yes)
\( -name '*.[oas]' -o -name '.*.cmd' -o -name '.*.d' \) \
-type f -print | xargs rm -f
endif
- $(Q)rm -rf $(addprefix $(obj)/,$(sort $(progs-y) $(progs-n) $(progs-)))
+ $(Q)rm -rf $(addprefix $(obj)/,$(sort $(progs-y) $(progs-n) $(progs-) $(shlibs-y) $(shlibs-n) $(shlibs-)))
ifeq ($(origin VERSION),command line)
DIST_VERSION=$(VERSION)