summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>2012-12-29 20:28:54 +0100
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>2012-12-29 20:28:54 +0100
commit164386ca42aea42d4643a0209c1a14799bfcfb6c (patch)
treef380fe7d06f44e9adf25be197cfaa4a9d04bc66c
parent4cfd728122f5197b4cf828ce9c9c445186926238 (diff)
downloadvdr-plugin-inputdev-164386ca42aea42d4643a0209c1a14799bfcfb6c.tar.gz
vdr-plugin-inputdev-164386ca42aea42d4643a0209c1a14799bfcfb6c.tar.bz2
refactored build system and renamed c++ sources to .cc
-rw-r--r--.gitignore3
-rw-r--r--Makefile128
-rw-r--r--inputdev.cc (renamed from inputdev.c)0
-rw-r--r--plugin.cc (renamed from plugin.c)0
4 files changed, 85 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index f5c0f08..d644a99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
+*.d
*.o
*.so
*.so.1.*
/.dependencies
+/vdr-inputdev
+/vdr-inputdev-*.tar*
diff --git a/Makefile b/Makefile
index 7088cfc..008833d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,20 +3,44 @@ VERSION = 0.0.1
### The C++ compiler and options:
-PKG_CONFIG = pkg-config
-SYSTEMD_CFLAGS = $(shell ${PKG_CONFIG} --cflags libsystemd-daemon || echo "libsystemd_missing")
-SYSTEMD_LIBS = $(shell ${PKG_CONFIG} --libs libsystemd-daemon || echo "libsystemd_missing")
-
-SOCKET_PATH = /var/run/vdr/inputdev
-
-AM_CFLAGS = -DSOCKET_PATH=\"${SOCKET_PATH}\"
-AM_CXXFLAGS = -DPACKAGE_VERSION=\"${VERSION}\" -DSOCKET_PATH=\"${SOCKET_PATH}\" ${SYSTEMD_CFLAGS}
-AM_CXXFLAGS += -D_FORTIFY_SOURCE=2 -Wall -Werror
-
-LIBS = ${SYSTEMD_LIBS}
-
-CXX ?= g++
-CXXFLAGS ?= -g -O3 -Wall -Werror=overloaded-virtual -Wno-parentheses
+CXX ?= $(CC)
+TAR ?= tar
+XZ ?= xz
+GZIP ?= gzip
+MSGFMT ?= msgfmt
+MSGMERGE ?= msgmerge
+XGETTEXT ?= xgettext
+PKG_CONFIG ?= pkg-config
+
+SYSTEMD_CFLAGS = $(shell ${PKG_CONFIG} --cflags libsystemd-daemon || echo "libsystemd_missing")
+SYSTEMD_LIBS = $(shell ${PKG_CONFIG} --libs libsystemd-daemon || echo "libsystemd_missing")
+
+TAR_FLAGS = --owner root --group root --mode a+rX,go-w
+
+AM_CPPFLAGS = -DPACKAGE_VERSION=\"${VERSION}\" -DSOCKET_PATH=\"${SOCKET_PATH}\" \
+ -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
+
+ifneq ($(USE_SYSTEMD),)
+AM_CPPFLAGS += -DVDR_USE_SYSTEMD
+AM_CXXFLAGS += ${SYSTEMD_CFLAGS}
+LIBS += ${SYSTEMD_LIBS}
+endif
+
+plugin_SOURCES = \
+ inputdev.cc \
+ inputdev.h \
+ plugin.cc \
+
+helper_SOURCES = \
+ udevhelper.c
+
+extra_SOURCES = \
+ Makefile \
+ README.txt \
+ contrib/96-vdrkeymap.rules \
+ contrib/hama-mce \
+ contrib/tt6400-ir \
+ contrib/x10-wti
### The directory environment:
@@ -24,6 +48,8 @@ VDRDIR ?= ../../..
LIBDIR ?= ../../lib
TMPDIR ?= /tmp
+SOCKET_PATH = /var/run/vdr/inputdev
+
### Allow user defined options to overwrite defaults:
include $(VDRDIR)/Make.global
@@ -36,35 +62,49 @@ APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDI
### The name of the distribution archive:
ARCHIVE = $(PLUGIN)-$(VERSION)
-PACKAGE = vdr-$(ARCHIVE)
+PACKAGE = vdr-$(ARCHIVE).tar
-### Includes and Defines (add further entries here):
+### The object files (add further files here):
-INCLUDES += -I$(VDRDIR)/include
+_all_sources = $(plugin_SOURCES) $(helper_SOURCES) $(extra_SOURCES)
-DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
+_objects = \
+ $(patsubst %.c,%.o,$(filter %.c,$(plugin_SOURCES))) \
+ $(patsubst %.cc,%.o,$(filter %.cc,$(plugin_SOURCES)))
-### The object files (add further files here):
+plugin_OBJS = $(call _objects,$(plugin_SOURCES))
+helper_OBJS = $(call _objects,$(helper_SOURCES))
-OBJS = plugin.o inputdev.o
+OBJS = $(plugin_OBJS) $(helper_OBJS)
### The main target:
all: libvdr-$(PLUGIN).so vdr-inputdev i18n
### Implicit rules:
+_buildflags = $(foreach k,CPP $1 LD, $(AM_$kFLAGS) $($kFLAGS) $($kFLAGS_$@))
%.o: %.c
- $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
+ $(CC) $(call _buildflags,C) -MMD -MP -c $< -o $@
-### Dependencies:
+%.o: %.cc
+ $(CC) $(call _buildflags,CXX) -MMD -MP -c $< -o $@
-MAKEDEP = $(CXX) -MM -MG
-DEPFILE = .dependencies
-$(DEPFILE): Makefile
- @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
+%.xz: %
+ @rm -f $@.tmp $@
+ $(XZ) -c < $< >$@.tmp
+ @mv $@.tmp $@
--include $(DEPFILE)
+%.gz: %
+ @rm -f $@.tmp $@
+ $(GZIP) -c < $< >$@.tmp
+ @mv $@.tmp $@
+
+%.mo: %.po
+ $(MSGFMT) -c -o $@ $<
+
+
+-include $(OBJS:%.o=%.d)
### Internationalization (I18N):
@@ -74,14 +114,11 @@ I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Npot = $(PODIR)/$(PLUGIN).pot
-%.mo: %.po
- msgfmt -c -o $@ $<
-
-$(I18Npot): $(wildcard *.c)
- xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ $^
+$(I18Npot): $(wildcard *.c *.cc)
+ $(XGETTEXT) -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ $^
%.po: $(I18Npot)
- msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
+ $(MSGMERGE) -U --no-wrap --no-location --backup=none -q $@ $<
@touch $@
$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
@@ -92,21 +129,20 @@ $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
i18n: $(I18Nmsgs) $(I18Npot)
### Targets:
+vdr-inputdev: $(helper_SOURCES)
+ $(CC) $(call _buildflags,C) $^ -o $@
-vdr-inputdev: udevhelper.c
- $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) $^ -o $@
-
-libvdr-$(PLUGIN).so: $(OBJS)
- $(CXX) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
+libvdr-$(PLUGIN).so: $(plugin_OBJS)
+ $(CXX) $(AM_LDFLAGS) $(LDFLAGS) $(LDFLAGS_$@) -shared -o $@ $^ $(LIBS)
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
-dist: $(I18Npo) clean
- @-rm -rf $(TMPDIR)/$(ARCHIVE)
- @mkdir $(TMPDIR)/$(ARCHIVE)
- @cp -a * $(TMPDIR)/$(ARCHIVE)
- @tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
- @-rm -rf $(TMPDIR)/$(ARCHIVE)
- @echo Distribution package created as $(PACKAGE).tgz
+dist: $(PACKAGE).xz $(PACKAGE).gz
+
+_tar_transform = --transform='s!^!$(ARCHIVE)/!'
+
+$(PACKAGE): $(I18Npo) $(_all_sources)
+ $(TAR) cf $@ $(TAR_FLAGS) $(_tar_transform) $(sort $^)
clean:
- @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot
+ @rm -f $(OBJS) libvdr*.so libvdr*.so.* *.d *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot
+ @rm -f vdr-inputdev
diff --git a/inputdev.c b/inputdev.cc
index e31fb8a..e31fb8a 100644
--- a/inputdev.c
+++ b/inputdev.cc
diff --git a/plugin.c b/plugin.cc
index 8e769b0..8e769b0 100644
--- a/plugin.c
+++ b/plugin.cc