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