Makefile
branchtrunk
changeset 11 7f424cf3f798
parent 9 dc75c2890a31
child 14 1d78b544c9de
equal deleted inserted replaced
10:bb902053eaff 11:7f424cf3f798
    72 RELEASE := $(shell grep 'define PLUGIN_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
    72 RELEASE := $(shell grep 'define PLUGIN_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
    73 VERSION := $(shell if test -d .hg; then echo -n '$(RELEASE)-'; (hg identify 2>/dev/null || echo -n Unknown) | sed -e 's/ .*//'; else echo -n '$(RELEASE)'; fi)
    73 VERSION := $(shell if test -d .hg; then echo -n '$(RELEASE)-'; (hg identify 2>/dev/null || echo -n Unknown) | sed -e 's/ .*//'; else echo -n '$(RELEASE)'; fi)
    74 
    74 
    75 ### The version number of VDR (taken from VDR's "config.h"):
    75 ### The version number of VDR (taken from VDR's "config.h"):
    76 
    76 
    77 VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
    77 VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    78 APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
    78 APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    79 ifeq ($(strip $(APIVERSION)),)
    79 ifeq ($(strip $(APIVERSION)),)
    80    APIVERSION = $(VDRVERSION)
    80    APIVERSION = $(VDRVERSION)
    81 endif
    81 endif
    82 VDRVERSNUM := $(shell sed -ne '/define VDRVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/config.h)
    82 VDRVERSNUM := $(shell sed -ne '/define VDRVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    83 APIVERSNUM := $(shell sed -ne '/define APIVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/config.h)
    83 APIVERSNUM := $(shell sed -ne '/define APIVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
    84 ifeq ($(strip $(APIVERSNUM)),)
    84 ifeq ($(strip $(APIVERSNUM)),)
    85    APIVERSNUM = $(VDRVERSNUM)
    85    APIVERSNUM = $(VDRVERSNUM)
    86 endif
    86 endif
    87 
    87 
    88 ### The name of the distribution archive:
    88 ### The name of the distribution archive:
    95 INCLUDES += -I$(VDRDIR)/include
    95 INCLUDES += -I$(VDRDIR)/include
    96 DEFINES  += -D_GNU_SOURCE -DAPIVERSNUM=$(APIVERSNUM)
    96 DEFINES  += -D_GNU_SOURCE -DAPIVERSNUM=$(APIVERSNUM)
    97 
    97 
    98 ### The object files (add further files here):
    98 ### The object files (add further files here):
    99 
    99 
   100 ifndef WITHOUT_MP3
   100 COM_OBJS = data.o menu.o version.o
   101   ALL += libvdr-$(PLUGIN).so
       
   102   ifneq ($(shell grep -l 'Phrases' $(VDRDIR)/i18n.c),$(VDRDIR)/i18n.c)
       
   103     ALL += i18n-$(PLUGIN)
       
   104   endif
       
   105 endif
       
   106 ifndef WITHOUT_MPLAYER
       
   107   ALL += libvdr-$(PLUGIN2).so
       
   108   ifneq ($(shell grep -l 'Phrases' $(VDRDIR)/i18n.c),$(VDRDIR)/i18n.c)
       
   109     ALL += i18n-$(PLUGIN2)
       
   110   endif
       
   111 endif
       
   112 
       
   113 COM_OBJS = i18n.o data.o menu.o version.o
       
   114 
   101 
   115 OBJS     = $(PLUGIN).o $(COM_OBJS)\
   102 OBJS     = $(PLUGIN).o $(COM_OBJS)\
   116             data-mp3.o setup-mp3.o player-mp3.o stream.o network.o\
   103             data-mp3.o setup-mp3.o player-mp3.o stream.o network.o\
   117             decoder.o decoder-mp3.o decoder-mp3-stream.o decoder-snd.o \
   104             decoder.o decoder-mp3.o decoder-mp3-stream.o decoder-snd.o \
   118             decoder-ogg.o
   105             decoder-ogg.o
   147 
   134 
   148 ### Internationalization (I18N):
   135 ### Internationalization (I18N):
   149 
   136 
   150 PODIR     = po
   137 PODIR     = po
   151 I18Npot   = $(PODIR)/mp3-mplayer.pot
   138 I18Npot   = $(PODIR)/mp3-mplayer.pot
   152 I18Npots  = $(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))
   139 I18Npots  := $(notdir $(foreach file, $(wildcard $(PODIR)/*.po), $(basename $(file))))
   153 I18Nmsgs  = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo,$(I18Npots)))
   140 ifeq ($(strip $(APIVERSION)),1.5.7)
   154 I18Nmsgs2 = $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/vdr-$(PLUGIN2).mo,$(I18Npots)))
   141   I18Nmo  = $(PLUGIN).mo
       
   142   I18Nmo2 = $(PLUGIN2).mo
       
   143 else
       
   144   I18Nmo  = vdr-$(PLUGIN).mo
       
   145   I18Nmo2 = vdr-$(PLUGIN2).mo
       
   146 endif
   155 LOCALEDIR = $(VDRDIR)/locale
   147 LOCALEDIR = $(VDRDIR)/locale
       
   148 I18Nmsgs  := $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo),$(I18Npots)))
       
   149 I18Nmsgs2 := $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(I18Nmo2),$(I18Npots)))
       
   150 
       
   151 HASLOCALE = $(shell grep -l 'I18N_DEFAULT_LOCALE' $(VDRDIR)/include/vdr/i18n.h)
       
   152 ifeq ($(strip $(HASLOCALE)),)
       
   153   COM_OBJS += i18n.o
       
   154 endif
   156 
   155 
   157 # Dependencies:
   156 # Dependencies:
   158 
   157 
   159 MAKEDEP = g++ -MM -MG
   158 MAKEDEP = g++ -MM -MG
   160 DEPFILE = .dependencies
   159 DEPFILE = .dependencies
   161 DEPFILES = $(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c))
   160 DEPFILES = $(subst i18n.c,,$(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c)))
   162 $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
   161 $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
   163 	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
   162 	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
   164 
   163 
   165 -include $(DEPFILE)
   164 -include $(DEPFILE)
   166 
   165 
   167 ### Targets:
   166 ### Targets:
       
   167 
       
   168 ifndef WITHOUT_MP3
       
   169   ALL += libvdr-$(PLUGIN).so
       
   170   ifneq ($(strip $(HASLOCALE)),)
       
   171     ALL += i18n-$(PLUGIN)
       
   172   endif
       
   173 endif
       
   174 ifndef WITHOUT_MPLAYER
       
   175   ALL += libvdr-$(PLUGIN2).so
       
   176   ifneq ($(strip $(HASLOCALE)),)
       
   177     ALL += i18n-$(PLUGIN2)
       
   178   endif
       
   179 endif
   168 
   180 
   169 all: $(ALL)
   181 all: $(ALL)
   170 .PHONY: i18n-$(PLUGIN) i18n-$(PLUGIN2)
   182 .PHONY: i18n-$(PLUGIN) i18n-$(PLUGIN2)
   171 
   183 
   172 %.o: %.c
   184 %.o: %.c
   188 	@touch $@
   200 	@touch $@
   189 
   201 
   190 %.mo: %.po
   202 %.mo: %.po
   191 	msgfmt -c -o $@ $<
   203 	msgfmt -c -o $@ $<
   192 
   204 
   193 $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
   205 $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo): $(PODIR)/%.mo
   194 	@mkdir -p $(dir $@)
   206 	@mkdir -p $(dir $@)
   195 	cp $< $@
   207 	cp $< $@
   196 
   208 
   197 i18n-$(PLUGIN): $(I18Nmsgs)
   209 i18n-$(PLUGIN): $(I18Nmsgs)
   198 
   210 
   199 $(I18Nmsgs2): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN2).mo: $(PODIR)/%.mo
   211 $(I18Nmsgs2): $(LOCALEDIR)/%/LC_MESSAGES/$(I18Nmo2): $(PODIR)/%.mo
   200 	@mkdir -p $(dir $@)
   212 	@mkdir -p $(dir $@)
   201 	cp $< $@
   213 	cp $< $@
   202 
   214 
   203 i18n-$(PLUGIN2): $(I18Nmsgs2)
   215 i18n-$(PLUGIN2): $(I18Nmsgs2)
       
   216 
       
   217 i18n.c: $(PODIR)/*.po i18n-template.c po2i18n.pl
       
   218 	perl ./po2i18n.pl <i18n-template.c >i18n.c
   204 
   219 
   205 version.c: FORCE
   220 version.c: FORCE
   206 	@echo >$@.new "/* this file will be overwritten without warning */"; \
   221 	@echo >$@.new "/* this file will be overwritten without warning */"; \
   207 	 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
   222 	 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
   208 	 diff $@.new $@ >$@.diff 2>&1; \
   223 	 diff $@.new $@ >$@.diff 2>&1; \
   217 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   232 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   218 	@echo Distribution package created as $(PACKAGE).tar.gz
   233 	@echo Distribution package created as $(PACKAGE).tar.gz
   219 
   234 
   220 clean:
   235 clean:
   221 	@-rm -f $(OBJS) $(OBJS2) $(DEPFILE) libvdr-*.so $(PACKAGE).tar.gz core* *~
   236 	@-rm -f $(OBJS) $(OBJS2) $(DEPFILE) libvdr-*.so $(PACKAGE).tar.gz core* *~
   222 	@-rm -f version.c
   237 	@-rm -f version.c i18n.c
   223 	@-rm -f $(PODIR)/*.mo
   238 	@-rm -f $(PODIR)/*.mo
   224 
   239 
   225 FORCE:
   240 FORCE: