aboutsummaryrefslogtreecommitdiffstats
path: root/src/so.mk
diff options
context:
space:
mode:
Diffstat (limited to 'src/so.mk')
-rw-r--r--src/so.mk32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/so.mk b/src/so.mk
new file mode 100644
index 000000000..10c43ad21
--- /dev/null
+++ b/src/so.mk
@@ -0,0 +1,32 @@
1# Common definitions for making shared objects.
2#
3# Note: $(ROOT)/config.mk must be included before this file.
4#
5# The includer should probably define SO and TARGET and may also want to define
6# MOD_HDRS, MOD_SRCS, MOD_OBJS, TOCLEAN and TODISTCLEAN.
7
8HDRS := $(sort $(wildcard *.h)) $(MOD_HDRS)
9SRCS := $(sort $(wildcard *.c)) $(MOD_SRCS)
10OBJS := $(SRCS:.c=.o) $(MOD_OBJS)
11
12CFLAGS += \
13 -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' \
14 -fstack-protector-all -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security \
15 -fPIC
16
17LDFLAGS += -pie -fPIE -Wl,-z,relro -Wl,-z,now
18
19.PHONY: all
20all: $(TARGET)
21
22%.o : %.c $(HDRS) $(ROOT)/config.mk
23 $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
24
25$(SO): $(OBJS) $(ROOT)/config.mk
26 $(CC) $(LDFLAGS) -shared -fPIC -z relro -o $@ $(OBJS) -ldl
27
28.PHONY: clean
29clean:; rm -fr $(OBJS) $(SO) *.plist $(TOCLEAN)
30
31.PHONY: distclean
32distclean: clean; rm -fr $(TODISTCLEAN)