Makefile
author nathan
Mon, 28 Jan 2008 17:21:58 +0100
branchtrunk
changeset 21 bc68e23ad6d5
parent 20 bc64e11172f5
child 23 3c10fdd8ccce
permissions -rw-r--r--
rework version generation
nathan@0
     1
#
nathan@0
     2
# PremiereEpg plugin to VDR
nathan@0
     3
#
nathan@21
     4
# (C) 2005-2008 Stefan Huelswitt <s.huelswitt@gmx.de>
nathan@0
     5
#
nathan@0
     6
# This code is free software; you can redistribute it and/or
nathan@0
     7
# modify it under the terms of the GNU General Public License
nathan@0
     8
# as published by the Free Software Foundation; either version 2
nathan@0
     9
# of the License, or (at your option) any later version.
nathan@0
    10
#
nathan@0
    11
# This code is distributed in the hope that it will be useful,
nathan@0
    12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
nathan@0
    13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nathan@0
    14
# GNU General Public License for more details.
nathan@0
    15
#
nathan@0
    16
# You should have received a copy of the GNU General Public License
nathan@0
    17
# along with this program; if not, write to the Free Software
nathan@0
    18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
nathan@0
    19
# Or, point your browser to http://www.gnu.org/copyleft/gpl.html
nathan@0
    20
nathan@0
    21
# The official name of this plugin.
nathan@0
    22
# This name will be used in the '-P...' option of VDR to load the plugin.
nathan@0
    23
# By default the main source file also carries this name.
nathan@0
    24
#
nathan@0
    25
PLUGIN = premiereepg
nathan@0
    26
nathan@20
    27
### The version number of this plugin:
nathan@0
    28
nathan@21
    29
HGARCHIVE = .hg_archival.txt
nathan@20
    30
RELEASE := $(shell grep 'define PLUGIN_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
nathan@21
    31
RELSTR  := $(shell if test -d .hg; then \
nathan@21
    32
                     echo -n "-"; (hg identify 2>/dev/null || echo -n "Unknown") | sed -e 's/ .*//'; \
nathan@21
    33
                   elif test -r $(HGARCHIVE); then \
nathan@21
    34
                     echo -n "-"; grep "^node" $(HGARCHIVE) | awk '{ printf "%.12s",$$2 }'; \
nathan@21
    35
                   fi)
nathan@21
    36
VERSION := $(RELEASE)$(RELSTR)
nathan@0
    37
nathan@0
    38
### The C++ compiler and options:
nathan@0
    39
nathan@0
    40
CXX      ?= g++
nathan@8
    41
CXXFLAGS ?= -O2 -fPIC -Wall -Woverloaded-virtual
nathan@0
    42
nathan@0
    43
### The directory environment:
nathan@0
    44
nathan@0
    45
VDRDIR = ../../..
nathan@0
    46
LIBDIR = ../../lib
nathan@0
    47
TMPDIR = /tmp
nathan@0
    48
nathan@0
    49
### Allow user defined options to overwrite defaults:
nathan@0
    50
nathan@0
    51
-include $(VDRDIR)/Make.config
nathan@20
    52
-include Make.config
nathan@0
    53
nathan@0
    54
### The version number of VDR (taken from VDR's "config.h"):
nathan@0
    55
nathan@20
    56
VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
nathan@20
    57
APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
nathan@10
    58
ifeq ($(strip $(APIVERSION)),)
nathan@10
    59
   APIVERSION = $(VDRVERSION)
nathan@10
    60
endif
nathan@0
    61
nathan@0
    62
### The name of the distribution archive:
nathan@0
    63
nathan@21
    64
ARCHIVE = $(PLUGIN)-$(RELEASE)
nathan@0
    65
PACKAGE = vdr-$(ARCHIVE)
nathan@0
    66
nathan@0
    67
### Includes and Defines (add further entries here):
nathan@0
    68
nathan@10
    69
INCLUDES += -I$(VDRDIR)/include
nathan@0
    70
nathan@0
    71
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
nathan@0
    72
nathan@0
    73
### The object files (add further files here):
nathan@0
    74
nathan@20
    75
OBJS = $(PLUGIN).o version.o
nathan@0
    76
nathan@2
    77
ifdef DBG
nathan@2
    78
CXXFLAGS += -g
nathan@2
    79
endif
nathan@2
    80
nathan@14
    81
### Internationalization (I18N):
nathan@0
    82
nathan@14
    83
PODIR     = po
nathan@14
    84
I18Npot   = $(PODIR)/$(PLUGIN).pot
nathan@14
    85
I18Nmsgs  = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo,$(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))))
nathan@14
    86
LOCALEDIR = $(VDRDIR)/locale
nathan@0
    87
nathan@21
    88
### Targets:
nathan@21
    89
nathan@21
    90
TARGETS = libvdr-$(PLUGIN).so
nathan@21
    91
ifneq ($(shell grep -l 'Phrases' $(VDRDIR)/i18n.c),$(VDRDIR)/i18n.c)
nathan@21
    92
TARGETS += i18n
nathan@21
    93
endif
nathan@21
    94
nathan@21
    95
all: $(TARGETS)
nathan@21
    96
.PHONY: i18n
nathan@21
    97
nathan@0
    98
# Dependencies:
nathan@0
    99
nathan@0
   100
MAKEDEP = $(CXX) -MM -MG
nathan@0
   101
DEPFILE = .dependencies
nathan@20
   102
DEPFILES = $(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c))
nathan@20
   103
$(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
nathan@20
   104
	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
nathan@0
   105
nathan@0
   106
-include $(DEPFILE)
nathan@0
   107
nathan@21
   108
# Rules
nathan@14
   109
nathan@14
   110
%.o: %.c
nathan@14
   111
	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
nathan@0
   112
nathan@0
   113
libvdr-$(PLUGIN).so: $(OBJS)
nathan@0
   114
	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
nathan@10
   115
	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
nathan@0
   116
nathan@14
   117
$(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c $(SYSDIR))
nathan@19
   118
	xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<s.huelswitt@gmx.de>' -o $@ $^
nathan@14
   119
nathan@14
   120
%.po: $(I18Npot)
nathan@19
   121
	msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
nathan@14
   122
	@touch $@
nathan@14
   123
nathan@14
   124
%.mo: %.po
nathan@14
   125
	msgfmt -c -o $@ $<
nathan@14
   126
nathan@14
   127
$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
nathan@14
   128
	@mkdir -p $(dir $@)
nathan@14
   129
	cp $< $@
nathan@14
   130
nathan@14
   131
i18n: $(I18Nmsgs)
nathan@14
   132
nathan@20
   133
version.c: FORCE
nathan@20
   134
	@echo >$@.new "/* this file will be overwritten without warning */"; \
nathan@20
   135
	 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
nathan@20
   136
	 diff $@.new $@ >$@.diff 2>&1; \
nathan@20
   137
	 if test -s $@.diff; then mv -f $@.new $@; fi; \
nathan@20
   138
	 rm -f $@.new $@.diff;
nathan@20
   139
nathan@0
   140
dist: clean
nathan@0
   141
	@-rm -rf $(TMPDIR)/$(ARCHIVE)
nathan@0
   142
	@mkdir $(TMPDIR)/$(ARCHIVE)
nathan@0
   143
	@cp -a * $(TMPDIR)/$(ARCHIVE)
nathan@4
   144
	@tar czf $(PACKAGE).tar.gz -C $(TMPDIR) $(ARCHIVE)
nathan@0
   145
	@-rm -rf $(TMPDIR)/$(ARCHIVE)
nathan@2
   146
	@echo Distribution package created as $(PACKAGE).tar.gz
nathan@0
   147
nathan@0
   148
clean:
nathan@2
   149
	@-rm -f $(OBJS) $(DEPFILE) *.so *.tar.gz core* *~
nathan@20
   150
	@-rm -f version.c
nathan@20
   151
	@-rm -f $(PODIR)/*.mo
nathan@20
   152
nathan@20
   153
FORCE: