Makefile
author nathan
Tue, 03 Feb 2009 12:28:53 +0800
branchtrunk
changeset 21 e47abd1f520f
parent 14 1d78b544c9de
child 22 93aaf15c145a
permissions -rw-r--r--
use blocking IO for OSS output
     1 #
     2 # MP3/MPlayer plugin to VDR
     3 #
     4 # (C) 2001-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 # You can change the compile options here or create a Make.config
    22 # in the VDR directory an set them there.
    23 
    24 ### uncomment one of these lines, if you don't want one of the plugins
    25 #WITHOUT_MP3=1
    26 #WITHOUT_MPLAYER=1
    27 
    28 ### uncomment the following line, if you don't have libsndfile installed
    29 #WITHOUT_LIBSNDFILE=1
    30 
    31 ### uncomment the following line, if you don't have libvorbisfile installed
    32 #WITHOUT_LIBVORBISFILE=1
    33 
    34 ### uncomment the following line, if you want OSS sound output
    35 #WITH_OSS_OUTPUT=1
    36 
    37 ### uncomment the following line, if you want to include debug symbols
    38 #DBG=1
    39 
    40 ### The C++ compiler and options:
    41 CXX      ?= g++
    42 CXXFLAGS ?= -O2 -fPIC -Wall -Woverloaded-virtual
    43 
    44 ###############################################
    45 ###############################################
    46 #
    47 # no user configurable options below this point
    48 #
    49 ###############################################
    50 ###############################################
    51 
    52 ### The directory environment:
    53 
    54 VDRDIR = ../../..
    55 LIBDIR = ../../lib
    56 TMPDIR = /tmp
    57 
    58 # The official name of this plugin.
    59 # This name will be used in the '-P...' option of VDR to load the plugin.
    60 # By default the main source file also carries this name.
    61 #
    62 PLUGIN  = mp3
    63 PLUGIN2 = mplayer
    64 
    65 ### Allow user defined options to overwrite defaults:
    66 
    67 -include $(VDRDIR)/Make.config
    68 -include Make.config
    69 
    70 ### The version number of this plugin:
    71 
    72 HGARCHIVE = .hg_archival.txt
    73 RELEASE := $(shell grep 'define PLUGIN_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
    74 RELSTR  := $(shell if test -d .hg; then \
    75                      echo -n "-"; (hg identify 2>/dev/null || echo -n "Unknown") | sed -e 's/ .*//'; \
    76                    elif test -r $(HGARCHIVE); then \
    77                      echo -n "-"; grep "^node" $(HGARCHIVE) | awk '{ printf "%.12s",$$2 }'; \
    78                    fi)
    79 VERSION := $(RELEASE)$(RELSTR)
    80 
    81 ### The version number of VDR (taken from VDR's "config.h"):
    82 
    83 VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    84 APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    85 ifeq ($(strip $(APIVERSION)),)
    86    APIVERSION = $(VDRVERSION)
    87 endif
    88 VDRVERSNUM := $(shell sed -ne '/define VDRVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    89 APIVERSNUM := $(shell sed -ne '/define APIVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    90 ifeq ($(strip $(APIVERSNUM)),)
    91    APIVERSNUM = $(VDRVERSNUM)
    92 endif
    93 
    94 ### The name of the distribution archive:
    95 
    96 ARCHIVE = $(PLUGIN)-$(RELEASE)
    97 PACKAGE = vdr-$(ARCHIVE)
    98 
    99 ### Includes and Defines (add further entries here):
   100 
   101 INCLUDES += -I$(VDRDIR)/include
   102 DEFINES  += -D_GNU_SOURCE -DAPIVERSNUM=$(APIVERSNUM)
   103 
   104 ### The object files (add further files here):
   105 
   106 COM_OBJS = data.o menu.o version.o
   107 
   108 OBJS     = $(PLUGIN).o $(COM_OBJS)\
   109             data-mp3.o setup-mp3.o player-mp3.o stream.o network.o\
   110             decoder.o decoder-mp3.o decoder-mp3-stream.o decoder-snd.o \
   111             decoder-ogg.o
   112 LIBS     = -lmad -lid3tag
   113 
   114 ifndef WITHOUT_LIBSNDFILE
   115   LIBS    += -lsndfile
   116   DEFINES += -DHAVE_SNDFILE
   117 endif
   118 ifndef WITHOUT_LIBVORBISFILE
   119   LIBS    += -lvorbisfile -lvorbis
   120   DEFINES += -DHAVE_VORBISFILE
   121 endif
   122 ifdef WITH_OSS_OUTPUT
   123   DEFINES += -DWITH_OSS
   124 endif
   125 ifdef BROKEN_PCM
   126   DEFINES += -DBROKEN_PCM
   127 endif
   128 
   129 OBJS2    = $(PLUGIN2).o $(COM_OBJS)\
   130             setup-mplayer.o player-mplayer.o
   131 LIBS2    = 
   132 
   133 ifeq ($(shell test -f $(VDRDIR)/fontsym.h ; echo $$?),0)
   134   DEFINES += -DHAVE_BEAUTYPATCH
   135 endif  
   136 
   137 ifdef DBG
   138   CXXFLAGS += -g
   139 endif
   140 
   141 ### Internationalization (I18N):
   142 
   143 PODIR     = po
   144 I18Npot   = $(PODIR)/mp3-mplayer.pot
   145 I18Npots  := $(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))
   146 ifeq ($(strip $(APIVERSION)),1.5.7)
   147   I18Nmo  = $(PLUGIN).mo
   148   I18Nmo2 = $(PLUGIN2).mo
   149 else
   150   I18Nmo  = vdr-$(PLUGIN).mo
   151   I18Nmo2 = vdr-$(PLUGIN2).mo
   152 endif
   153 LOCALEDIR = $(VDRDIR)/locale
   154 I18Nmsgs  := $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo),$(I18Npots)))
   155 I18Nmsgs2 := $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo2),$(I18Npots)))
   156 
   157 HASLOCALE = $(shell grep -l 'I18N_DEFAULT_LOCALE' $(VDRDIR)/include/vdr/i18n.h)
   158 ifeq ($(strip $(HASLOCALE)),)
   159   COM_OBJS += i18n.o
   160 endif
   161 
   162 ### Targets:
   163 
   164 ifndef WITHOUT_MP3
   165   ALL += libvdr-$(PLUGIN).so
   166   ifneq ($(strip $(HASLOCALE)),)
   167     ALL += i18n-$(PLUGIN)
   168   endif
   169 endif
   170 ifndef WITHOUT_MPLAYER
   171   ALL += libvdr-$(PLUGIN2).so
   172   ifneq ($(strip $(HASLOCALE)),)
   173     ALL += i18n-$(PLUGIN2)
   174   endif
   175 endif
   176 
   177 all: $(ALL)
   178 .PHONY: i18n-$(PLUGIN) i18n-$(PLUGIN2)
   179 
   180 # Dependencies:
   181 
   182 MAKEDEP = g++ -MM -MG
   183 DEPFILE = .dependencies
   184 DEPFILES = $(subst i18n.c,,$(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c)))
   185 $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
   186 	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
   187 
   188 -include $(DEPFILE)
   189 
   190 # Rules
   191 
   192 %.o: %.c
   193 	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
   194 
   195 libvdr-$(PLUGIN).so: $(OBJS)
   196 	$(CXX) $(CXXFLAGS) -shared $(OBJS) $(LIBS) -o $@
   197 	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
   198 
   199 libvdr-$(PLUGIN2).so: $(OBJS2)
   200 	$(CXX) $(CXXFLAGS) -shared $(OBJS2) $(LIBS2) -o $@
   201 	@cp $@ $(LIBDIR)/$@.$(APIVERSION)
   202 
   203 $(I18Npot): $(shell grep -rl '\(tr\|trNOOP\)(\".*\")' *.c )
   204 	xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='<s.huelswitt@gmx.de>' -o $@ $^
   205 
   206 %.po: $(I18Npot)
   207 	msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
   208 	@touch $@
   209 
   210 %.mo: %.po
   211 	msgfmt -c -o $@ $<
   212 
   213 $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo): $(PODIR)/%.mo
   214 	@mkdir -p $(dir $@)
   215 	cp $< $@
   216 
   217 i18n-$(PLUGIN): $(I18Nmsgs)
   218 
   219 $(I18Nmsgs2): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo2): $(PODIR)/%.mo
   220 	@mkdir -p $(dir $@)
   221 	cp $< $@
   222 
   223 i18n-$(PLUGIN2): $(I18Nmsgs2)
   224 
   225 i18n.c: $(PODIR)/*.po i18n-template.c po2i18n.pl
   226 	perl ./po2i18n.pl <i18n-template.c >i18n.c
   227 
   228 version.c: FORCE
   229 	@echo >$@.new "/* this file will be overwritten without warning */"; \
   230 	 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
   231 	 diff $@.new $@ >$@.diff 2>&1; \
   232 	 if test -s $@.diff; then mv -f $@.new $@; fi; \
   233 	 rm -f $@.new $@.diff;
   234 
   235 dist: clean
   236 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   237 	@mkdir $(TMPDIR)/$(ARCHIVE)
   238 	@cp -a * $(TMPDIR)/$(ARCHIVE)
   239 	@tar czf $(PACKAGE).tar.gz -C $(TMPDIR) $(ARCHIVE)
   240 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   241 	@echo Distribution package created as $(PACKAGE).tar.gz
   242 
   243 clean:
   244 	@-rm -f $(OBJS) $(OBJS2) $(DEPFILE) libvdr-*.so $(PACKAGE).tar.gz core* *~
   245 	@-rm -f version.c i18n.c
   246 	@-rm -f $(PODIR)/*.mo
   247 
   248 FORCE: