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