-
Notifications
You must be signed in to change notification settings - Fork 128
/
Makefile
99 lines (75 loc) · 3.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
####### Compiler options
override CFLAGS += -I$(LIBPE) -I"../../include" -W -Wall -Wextra -std=c99 -pedantic -fPIC
override CPPFLAGS += -D_GNU_SOURCE
PLUGINS = csv html text xml json
VERSION = 1.0
plugins_BUILDDIR = ../$(pev_BUILDDIR)/plugins
csv_srcdir = $(CURDIR)
csv_SRCS = csv.c
csv_OBJS = $(addprefix ${plugins_BUILDDIR}/, $(addsuffix .o, $(basename ${csv_SRCS})))
csv_LIBNAME = csv_plugin
html_srcdir = $(CURDIR)
html_SRCS = html.c
html_OBJS = $(addprefix ${plugins_BUILDDIR}/, $(addsuffix .o, $(basename ${html_SRCS})))
html_LIBNAME = html_plugin
text_srcdir = $(CURDIR)
text_SRCS = text.c
text_OBJS = $(addprefix ${plugins_BUILDDIR}/, $(addsuffix .o, $(basename ${text_SRCS})))
text_LIBNAME = text_plugin
xml_srcdir = $(CURDIR)
xml_SRCS = xml.c
xml_OBJS = $(addprefix ${plugins_BUILDDIR}/, $(addsuffix .o, $(basename ${xml_SRCS})))
xml_LIBNAME = xml_plugin
json_srcdir = $(CURDIR)
json_SRCS = json.c
json_OBJS = $(addprefix ${plugins_BUILDDIR}/, $(addsuffix .o, $(basename ${json_SRCS})))
json_LIBNAME = json_plugin
####### Build rules
.PHONY: plugins
plugins: $(PLUGINS)
csv: LIBNAME = $(csv_LIBNAME)
csv: $(csv_OBJS)
html: LIBNAME = $(html_LIBNAME)
html: $(html_OBJS)
text: LIBNAME = $(text_LIBNAME)
text: $(text_OBJS)
xml: LIBNAME = $(xml_LIBNAME)
xml: $(xml_OBJS)
json: LIBNAME = $(json_LIBNAME)
json: $(json_OBJS)
$(PLUGINS):
ifeq ($(PLATFORM_OS), Linux)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), NetBSD)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), FreeBSD)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), OpenBSD)
$(LINK) -shared -Wl,-soname,$(LIBNAME).so.1 $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).so $^
else ifeq ($(PLATFORM_OS), Darwin)
$(LINK) -headerpad_max_install_names -dynamiclib \
-undefined dynamic_lookup -fno-common \
-flat_namespace -install_name $(LIBNAME).$(VERSION).dylib \
-current_version $(VERSION) -compatibility_version $(VERSION) \
$(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).dylib $^
else ifeq ($(PLATFORM_OS), CYGWIN)
$(LINK) -shared $(LDFLAGS) -o ${plugins_BUILDDIR}/$(LIBNAME).dll $^
endif
$(plugins_BUILDDIR)/%.o: %.c
@$(CHK_DIR_EXISTS) $(dir $@) || $(MKDIR) $(dir $@)
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $^
clean:
$(RM_DIR) ${plugins_BUILDDIR}
###
install: installdirs
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(csv_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(html_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(text_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(xml_LIBNAME).* $(DESTDIR)$(pluginsdir)
$(INSTALL_PROGRAM) $(INSTALL_FLAGS) -m 755 $(plugins_BUILDDIR)/$(json_LIBNAME).* $(DESTDIR)$(pluginsdir)
install-strip: INSTALL_FLAGS += -s
install-strip: install
installdirs:
@$(CHK_DIR_EXISTS) $(DESTDIR)$(pluginsdir) || $(MKDIR) $(DESTDIR)$(pluginsdir)
uninstall:
$(RM_DIR) $(DESTDIR)$(pluginsdir)