web/wp-content/plugins/event-calendar/Makefile
changeset 136 bde1974c263b
equal deleted inserted replaced
135:53cff4b4a802 136:bde1974c263b
       
     1 # Copyright (c) 2006, Alex Tingle.  $Revision: 184 $
       
     2 # 
       
     3 # This program is free software; you can redistribute it and/or
       
     4 # modify it under the terms of the GNU General Public License
       
     5 # as published by the Free Software Foundation; either version 2
       
     6 # of the License, or (at your option) any later version.
       
     7 # 
       
     8 # This program is distributed in the hope that it will be useful,
       
     9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    11 # GNU General Public License for more details.
       
    12 # 
       
    13 # You should have received a copy of the GNU General Public License
       
    14 # along with this program; if not, write to the Free Software
       
    15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
       
    16 
       
    17 
       
    18 # Generates gettext translation file.
       
    19 # Just drop .po files into the gettext directory and make will do the rest.   
       
    20 
       
    21 PHP_FILES := $(wildcard *.php) $(wildcard */*.php)
       
    22 PO_FILES := $(wildcard gettext/ec3-*.po)
       
    23 MO_FILES := $(patsubst %.po,%.mo,$(PO_FILES))
       
    24 
       
    25 # EventCalendar's PO template
       
    26 POT := gettext/ec3.pot
       
    27 
       
    28 # Working space - The shell command creates this directory.
       
    29 TEMPDIR := $(shell mktemp -t -d eventcalendar.XXXXXXXXXXXXX)
       
    30 # Temporary files, filtered for gettext calls in the 'ec3' domain.
       
    31 XPHP_FILES := $(patsubst %,$(TEMPDIR)/%,$(PHP_FILES))
       
    32 
       
    33 # xgettext generates a .pot template from souce code.
       
    34 XGETTEXT := xgettext
       
    35 XGETTEXT_OPTIONS := \
       
    36  --default-domain=ec3 \
       
    37  --language=php \
       
    38  --keyword=_x_ \
       
    39  --from-code=UTF-8 \
       
    40  --msgid-bugs-address='eventcalendar@firetree.net' \
       
    41 
       
    42 .PHONY: all
       
    43 all: $(POT) $(MO_FILES) $(TEMPDIR)/delete
       
    44 
       
    45 $(MO_FILES): %.mo: %.po
       
    46 	@echo "MSGFMT:   $@"
       
    47 	msgfmt -o$@ $<
       
    48 
       
    49 $(PO_FILES): %: $(POT)
       
    50 	@echo "MSGMERGE: $@"
       
    51 	msgmerge -U $@ $(POT)
       
    52 	touch $@
       
    53 
       
    54 $(POT): $(XPHP_FILES) gettext/pot.sed
       
    55 	@echo "XGETTEXT: $@"
       
    56 	cd $(TEMPDIR) && \
       
    57 	$(XGETTEXT) $(XGETTEXT_OPTIONS) -o- $(PHP_FILES) \
       
    58 	| sed -f $(CURDIR)/gettext/pot.sed \
       
    59 	> $(CURDIR)/$@
       
    60 
       
    61 .INTERMEDIATE: $(XPHP_FILES)
       
    62 $(XPHP_FILES): $(TEMPDIR)/%: %
       
    63 	@echo "SED_FILTER: $<"
       
    64 	mkdir -p $(@D)
       
    65 	sed "s/_[_e]\(([^)]*,['\"]ec3['\"])\)/_x_\1/" $< > $@
       
    66 
       
    67 # Force the temporary directory to be deleted when everything is done.
       
    68 $(TEMPDIR)/delete:
       
    69 	rm -rf $(TEMPDIR)
       
    70 
       
    71 .PHONY: clean
       
    72 clean: $(TEMPDIR)/delete
       
    73 	rm -f $(POT)
       
    74 	rm -f $(MO_FILES)
       
    75 
       
    76 .SILENT:
       
    77 .DELETE_ON_ERROR: