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
     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 I18Nmsgs  = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo,$(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))))
    86 LOCALEDIR = $(VDRDIR)/locale
    87 
    88 ### Targets:
    89 
    90 TARGETS = libvdr-$(PLUGIN).so
    91 ifneq ($(shell grep -l 'Phrases' $(VDRDIR)/i18n.c),$(VDRDIR)/i18n.c)
    92 TARGETS += i18n
    93 endif
    94 
    95 all: $(TARGETS)
    96 .PHONY: i18n
    97 
    98 # Dependencies:
    99 
   100 MAKEDEP = $(CXX) -MM -MG
   101 DEPFILE = .dependencies
   102 DEPFILES = $(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c))
   103 $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
   104 	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
   105 
   106 -include $(DEPFILE)
   107 
   108 # Rules
   109 
   110 %.o: %.c
   111 	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
   112 
   113 libvdr-$(PLUGIN).so: $(OBJS)
   114 	$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
   115 	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
   116 
   117 $(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c $(SYSDIR))
   118 	xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<s.huelswitt@gmx.de>' -o $@ $^
   119 
   120 %.po: $(I18Npot)
   121 	msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
   122 	@touch $@
   123 
   124 %.mo: %.po
   125 	msgfmt -c -o $@ $<
   126 
   127 $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
   128 	@mkdir -p $(dir $@)
   129 	cp $< $@
   130 
   131 i18n: $(I18Nmsgs)
   132 
   133 version.c: FORCE
   134 	@echo >$@.new "/* this file will be overwritten without warning */"; \
   135 	 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
   136 	 diff $@.new $@ >$@.diff 2>&1; \
   137 	 if test -s $@.diff; then mv -f $@.new $@; fi; \
   138 	 rm -f $@.new $@.diff;
   139 
   140 dist: clean
   141 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   142 	@mkdir $(TMPDIR)/$(ARCHIVE)
   143 	@cp -a * $(TMPDIR)/$(ARCHIVE)
   144 	@tar czf $(PACKAGE).tar.gz -C $(TMPDIR) $(ARCHIVE)
   145 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   146 	@echo Distribution package created as $(PACKAGE).tar.gz
   147 
   148 clean:
   149 	@-rm -f $(OBJS) $(DEPFILE) *.so *.tar.gz core* *~
   150 	@-rm -f version.c
   151 	@-rm -f $(PODIR)/*.mo
   152 
   153 FORCE: