]> git.vomp.tv Git - jsonserver.git/blob - Makefile
JSON: Switch from StyledWriter to StreamWriterBuilder
[jsonserver.git] / Makefile
1 # Dependencies:
2 # libjsoncpp-dev libconfig++-dev libspdlog-dev
3
4 #
5 # Makefile for a Video Disk Recorder plugin
6 #
7 # $Id$
8
9 # The official name of this plugin.
10 # This name will be used in the '-P...' option of VDR to load the plugin.
11 # By default the main source file also carries this name.
12
13 PLUGIN = jsonserver
14
15 ### The version number of this plugin (taken from the main source file):
16
17 VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
18
19 ### The directory environment:
20
21 # Use package data if installed...otherwise assume we're under the VDR source directory:
22 PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:../../.." pkg-config --variable=$(1) vdr))
23 LIBDIR = $(call PKGCFG,libdir)
24 LOCDIR = $(call PKGCFG,locdir)
25 PLGCFG = $(call PKGCFG,plgcfg)
26 #
27 TMPDIR ?= /tmp
28
29 ### The compiler options:
30
31 export CFLAGS   = $(call PKGCFG,cflags)
32 export CXXFLAGS = $(call PKGCFG,cxxflags)
33
34 ### The version number of VDR's plugin API:
35
36 APIVERSION = $(call PKGCFG,apiversion)
37
38 ### Allow user defined options to overwrite defaults:
39
40 -include $(PLGCFG)
41
42 ### The name of the distribution archive:
43
44 ARCHIVE = $(PLUGIN)-$(VERSION)
45 PACKAGE = vdr-$(ARCHIVE)
46
47 ### The name of the shared object file:
48
49 SOFILE = libvdr-$(PLUGIN).so
50
51 ### Includes and Defines (add further entries here):
52
53 INCLUDES +=
54
55 DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
56
57 ### The object files (add further files here):
58
59 OBJS = $(PLUGIN).o httpdclient.o vdrclient.o
60
61 ### The main target:
62
63 all: $(SOFILE) i18n
64
65 ### Implicit rules:
66
67 %.o: %.c
68         @echo CC $@
69         $(Q)$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
70
71 ### Dependencies:
72
73 MAKEDEP = $(CXX) -MM -MG
74 DEPFILE = .dependencies
75 $(DEPFILE): Makefile
76         @$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
77
78 -include $(DEPFILE)
79
80 ### Internationalization (I18N):
81
82 PODIR     = po
83 I18Npo    = $(wildcard $(PODIR)/*.po)
84 I18Nmo    = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
85 I18Nmsgs  = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
86 I18Npot   = $(PODIR)/$(PLUGIN).pot
87
88 %.mo: %.po
89         @echo MO $@
90         $(Q)msgfmt -c -o $@ $<
91
92 $(I18Npot): $(wildcard *.c)
93         @echo GT $@
94         $(Q)xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ `ls $^`
95
96 %.po: $(I18Npot)
97         @echo PO $@
98         $(Q)msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
99         @touch $@
100
101 $(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
102         install -D -m644 $< $@
103
104 .PHONY: i18n
105 i18n: $(I18Nmo) $(I18Npot)
106
107 install-i18n: $(I18Nmsgs)
108
109 ### Targets:
110
111 $(SOFILE): $(OBJS)
112         @echo LD $@
113         $(Q)$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -ljsoncpp -lconfig++ -lmicrohttpd -lfmt -o $@
114
115 install-lib: $(SOFILE)
116         install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
117
118 install: install-lib install-i18n
119
120 dist: $(I18Npo) clean
121         @-rm -rf $(TMPDIR)/$(ARCHIVE)
122         @mkdir $(TMPDIR)/$(ARCHIVE)
123         @cp -a * $(TMPDIR)/$(ARCHIVE)
124         @tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
125         @-rm -rf $(TMPDIR)/$(ARCHIVE)
126         @echo Distribution package created as $(PACKAGE).tgz
127
128 clean:
129         @-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
130         @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~