Makefile
branchtrunk
changeset 20 bc64e11172f5
parent 19 5686936eefc5
child 21 bc68e23ad6d5
equal deleted inserted replaced
19:5686936eefc5 20:bc64e11172f5
    22 # This name will be used in the '-P...' option of VDR to load the 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.
    23 # By default the main source file also carries this name.
    24 #
    24 #
    25 PLUGIN = premiereepg
    25 PLUGIN = premiereepg
    26 
    26 
    27 ### The version number of this plugin (taken from the main source file):
    27 ### The version number of this plugin:
    28 
    28 
    29 VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
    29 RELEASE := $(shell grep 'define PLUGIN_RELEASE' version.h | awk '{ print $$3 }' | sed -e 's/[";]//g')
       
    30 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)
    30 
    31 
    31 ### The C++ compiler and options:
    32 ### The C++ compiler and options:
    32 
    33 
    33 CXX      ?= g++
    34 CXX      ?= g++
    34 CXXFLAGS ?= -O2 -fPIC -Wall -Woverloaded-virtual
    35 CXXFLAGS ?= -O2 -fPIC -Wall -Woverloaded-virtual
    40 TMPDIR = /tmp
    41 TMPDIR = /tmp
    41 
    42 
    42 ### Allow user defined options to overwrite defaults:
    43 ### Allow user defined options to overwrite defaults:
    43 
    44 
    44 -include $(VDRDIR)/Make.config
    45 -include $(VDRDIR)/Make.config
       
    46 -include Make.config
    45 
    47 
    46 ### The version number of VDR (taken from VDR's "config.h"):
    48 ### The version number of VDR (taken from VDR's "config.h"):
    47 
    49 
    48 VDRVERSION = $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
    50 VDRVERSION := $(shell sed -ne '/define VDRVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
    49 APIVERSION = $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
    51 APIVERSION := $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
    50 ifeq ($(strip $(APIVERSION)),)
    52 ifeq ($(strip $(APIVERSION)),)
    51    APIVERSION = $(VDRVERSION)
    53    APIVERSION = $(VDRVERSION)
    52 endif
    54 endif
    53 
    55 
    54 ### The name of the distribution archive:
    56 ### The name of the distribution archive:
    62 
    64 
    63 DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
    65 DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
    64 
    66 
    65 ### The object files (add further files here):
    67 ### The object files (add further files here):
    66 
    68 
    67 OBJS = $(PLUGIN).o
    69 OBJS = $(PLUGIN).o version.o
    68 
    70 
    69 ifdef DBG
    71 ifdef DBG
    70 CXXFLAGS += -g
    72 CXXFLAGS += -g
    71 endif
    73 endif
    72 
    74 
    79 
    81 
    80 # Dependencies:
    82 # Dependencies:
    81 
    83 
    82 MAKEDEP = $(CXX) -MM -MG
    84 MAKEDEP = $(CXX) -MM -MG
    83 DEPFILE = .dependencies
    85 DEPFILE = .dependencies
    84 $(DEPFILE): Makefile
    86 DEPFILES = $(subst version.c,,$(OBJS:%.o=%.c) $(OBJS2:%.o=%.c))
    85 	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
    87 $(DEPFILE): Makefile $(DEPFILES) $(wildcard *.h)
       
    88 	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(DEPFILES) > $@
    86 
    89 
    87 -include $(DEPFILE)
    90 -include $(DEPFILE)
    88 
    91 
    89 ### Targets:
    92 ### Targets:
    90 
    93 
   117 	@mkdir -p $(dir $@)
   120 	@mkdir -p $(dir $@)
   118 	cp $< $@
   121 	cp $< $@
   119 
   122 
   120 i18n: $(I18Nmsgs)
   123 i18n: $(I18Nmsgs)
   121 
   124 
       
   125 version.c: FORCE
       
   126 	@echo >$@.new "/* this file will be overwritten without warning */"; \
       
   127 	 echo >>$@.new 'const char *PluginVersion =' '"'$(VERSION)'";'; \
       
   128 	 diff $@.new $@ >$@.diff 2>&1; \
       
   129 	 if test -s $@.diff; then mv -f $@.new $@; fi; \
       
   130 	 rm -f $@.new $@.diff;
       
   131 
   122 dist: clean
   132 dist: clean
   123 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   133 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   124 	@mkdir $(TMPDIR)/$(ARCHIVE)
   134 	@mkdir $(TMPDIR)/$(ARCHIVE)
   125 	@cp -a * $(TMPDIR)/$(ARCHIVE)
   135 	@cp -a * $(TMPDIR)/$(ARCHIVE)
   126 	@tar czf $(PACKAGE).tar.gz -C $(TMPDIR) $(ARCHIVE)
   136 	@tar czf $(PACKAGE).tar.gz -C $(TMPDIR) $(ARCHIVE)
   127 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   137 	@-rm -rf $(TMPDIR)/$(ARCHIVE)
   128 	@echo Distribution package created as $(PACKAGE).tar.gz
   138 	@echo Distribution package created as $(PACKAGE).tar.gz
   129 
   139 
   130 clean:
   140 clean:
   131 	@-rm -f $(OBJS) $(DEPFILE) *.so *.tar.gz core* *~
   141 	@-rm -f $(OBJS) $(DEPFILE) *.so *.tar.gz core* *~
   132 	@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
   142 	@-rm -f version.c
       
   143 	@-rm -f $(PODIR)/*.mo
       
   144 
       
   145 FORCE: