#--------------------------------------------------------------------- # Copyright (C) GFD Dennou Club, 2005. All rights reserved. #--------------------------------------------------------------------- #= Replace strings in documentations # # * Yasuhiro MORIKAWA, Masaki ISHIWATARI # * 2005/06/30 (Yasuhiro MORIKAWA) "Current_CVS_Tag.mk" is included # * 2005/06/23 (Yasuhiro MORIKAWA) Japanese commends are added # * 2005/06/12 (Yasuhiro MORIKAWA) Create # ###################################################################### # #== Settings # # [JAPANESE] 各種設定項目 INCLUDEFILE = Current_CVS_Tag.mk include $(INCLUDEFILE) # Include file (optional) # [JA] インクルードファイル (任意) RUBY = ruby1.8 # Path to Ruby (necessary) # [JA] Ruby へのパス (必須) # Target files for replacing strings. (necessary) # [JA] 文字列を入れ替える対象となるファイル (必須) TARGETS = gt4f90io.htm gt4f90io.htm.en # Replaced word described by the regular expression. (necessary) # [JA] 入れ替える文字列. FROM は正規表現で記述 (必須) FROM = \(Version: .*?\) TO = (Version: $(GT4IOTAG)) # End Settings [JA] 設定項目ここまで ###################################################################### ###################################################################### #== Ruby liner script for replacing version number REPLACER = $(RUBY) -e 'if ARGV.size < 3 then ;\ $$stdout.print "Replacing: Args: from to file\n";\ exit ;\ end ;\ if !(File.exist?(ARGV[2])) ;\ $$stdout.print "Replacing: \"\#{ARGV[2]}\" is not found\n";\ exit ;\ end ;\ body = open(ARGV[2]){|io| io.read} ;\ if /\#{ARGV[0]}/ =~ body then ;\ $$stdout.print "Replacing: \"\#{ARGV[0]}\" to " + \ " \"\#{ARGV[1]}\" in \"\#{ARGV[2]}\" ... " ;\ body = body.gsub!(/\#{ARGV[0]}/, "\#{ARGV[1]}");\ $$stdout.print "done.\n" ;\ end ;\ out = open(ARGV[2], "w"); out.puts(body) ;\ out.close' ###################################################################### #== Rules # all: replace help: @echo "" @echo " make [replace] :" @echo " Replace strings in documentations" @echo "" clean: -rm *~ clean.all: clean replace: @for i in $(TARGETS) ; do \ $(REPLACER) "$(FROM)" "$(TO)" "$$i" ;\ done ###################################################################### #== Mode setting for Emacs #Local Variables: #mode: makefile #End: #