blob: 78270e96be5306af4fcb49456f8fd60a616634af [file] [log] [blame]
Bram Moolenaare344bea2005-09-01 20:46:49 +00001# Aap recipe for Portuguese Vim spell files.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002#
3# Based on a shell script by Leonardo Fontenelle.
4# His remarks:
5#
6# Makes a Vim pt dictionary from OpenOffice.org's pt_BR and pt_PT.
7#
8# AFAIK, will have to update the script every time a new dictionary is
9# released for pt_BR. I asked the maintainer to update OOo's FTP site,
10# but it didn't happen yet. As for the pt_PT dictionary, they won't be
11# in OOo's FTP site for some time, because the Portuguese OOo project
12# decided to adapt the pt_BR dictionary, which is much more extensive.
13# I picked the Natura project unofficial dictionary, because it has been
14# developed by a team with linguists, and for a longer time. At least the
15# pt_PT dictionary has a "latest" file to make our lives easier.
16
Bram Moolenaare344bea2005-09-01 20:46:49 +000017
18# Use a freshly compiled Vim if it exists.
19@if os.path.exists('../../../src/vim'):
20 VIM = ../../../src/vim
21@else:
22 :progsearch VIM vim
23
24SPELLDIR = ..
25FILES = pt_PT.aff pt_PT.dic
26 pt_BR.aff pt_BR.dic
27
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000028#
29# Fetching the pt_PT files from the Natura project.
30#
31PT_DIR = http://natura.di.uminho.pt/download/sources/Dictionaries/myspell
32PT_FNAME = myspell.pt-latest.zip
33:attr {fetch = $PT_DIR/%file%} $PT_FNAME
34
35#
36# Fetching the pt_BR files from BrOffice.org (Brazilian OOo) 2.1. Should be
37# updated really soon.
38#
Bram Moolenaar10c56952007-05-10 18:38:52 +000039BR_BASENAME = pt_BR-2007-04-11
40BR_DIR = http://www.deso-se.com.br/downloads/download.php?arquivo=$BR_BASENAME
41BR_FNAME = $(BR_BASENAME).zip
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000042
43:attr {fetch = $BR_DIR} $BR_FNAME
44
Bram Moolenaare344bea2005-09-01 20:46:49 +000045all: $SPELLDIR/pt.latin1.spl $SPELLDIR/pt.utf-8.spl \
46 ../README_pt.txt
47
48$SPELLDIR/pt.latin1.spl : $FILES
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000049 :sys env LANG=pt_PT.ISO8859-1 LC_ALL=pt_PT.ISO8859-1
Bram Moolenaare344bea2005-09-01 20:46:49 +000050 $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
51
52$SPELLDIR/pt.utf-8.spl : $FILES
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000053 :sys env LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8
Bram Moolenaare344bea2005-09-01 20:46:49 +000054 $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
55
56../README_pt.txt: README_pt_PT.txt README_pt_BR.txt
57 :print pt_PT >!$target
58 :cat README_pt_PT.txt | :eval re.sub('\r', '', stdin) >>$target
59 :print =================================================== >>$target
60 :print pt_BR: >>$target
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000061 :print Information is in Leia-me.pdf, see $BR_DIR >>$target
62 :cat README_pt_BR.txt >>$target
Bram Moolenaare344bea2005-09-01 20:46:49 +000063
64# The files don't depend on the .zip file so that we can delete it.
65# Only download the zip file if the targets don't exist.
66pt_PT.aff pt_PT.dic: {buildcheck=}
67 :assertpkg unzip patch
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000068 :fetch $PT_FNAME
69 :sys $UNZIP $PT_FNAME
70 :delete $PT_FNAME
71 :move myspell.pt-*/pt_PT.dic .
72 :move myspell.pt-*/pt_PT.aff .
73 :move myspell.pt-*/README_pt_PT.txt .
74 :move myspell.pt-*/COPYING COPYING_pt_PT.txt
75 :deldir myspell.pt-*
Bram Moolenaare344bea2005-09-01 20:46:49 +000076 @if not os.path.exists('pt_PT.orig.aff'):
77 :copy pt_PT.aff pt_PT.orig.aff
78 @if not os.path.exists('pt_PT.orig.dic'):
79 :copy pt_PT.dic pt_PT.orig.dic
80 @if os.path.exists('pt_PT.diff'):
81 :sys patch <pt_PT.diff
82
83pt_BR.aff pt_BR.dic: {buildcheck=}
84 :assertpkg unzip patch
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000085 :fetch $BR_FNAME
86 :sys $UNZIP $BR_FNAME
87 :delete $BR_FNAME
88 :move Leia-me.pdf Leia-me_pt_BR.pdf
89
90# 1. pt_BR.dic contains a cp1252-specific character.
91# Changing it to its latin1 equivalent.
92# 2. Vim seems to ignore the dots from the word list.
93# Removing words with dot to avoid misbehaviour.
94 :sys $VIM pt_BR.dic -e -c "set ff=unix" -c "%s/\%x92/'/g" -c "/\./d" -c update -c q
95
96# Removing /* ... */ header to avoid warnings. Write it to the README file, it
97# contains the copyright notice.
Bram Moolenaar10c56952007-05-10 18:38:52 +000098 :sys $VIM pt_BR.aff -e -c "set ff=unix" -c "/\/\*/,/\*\//w! README_pt_BR.txt" -c "/\/\*/,/\*\//+1d" -c update -c q
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000099
100 #:sys $VIM README_pt_BR.txt -e -c "set ff=unix" -c update -c q
Bram Moolenaare344bea2005-09-01 20:46:49 +0000101 @if not os.path.exists('pt_BR.orig.aff'):
102 :copy pt_BR.aff pt_BR.orig.aff
103 @if not os.path.exists('pt_BR.orig.dic'):
104 :copy pt_BR.dic pt_BR.orig.dic
105 @if os.path.exists('pt_BR.diff'):
106 :sys patch <pt_BR.diff
107
108
109# Generate diff files, so that others can get the OpenOffice files and apply
110# the diffs to get the Vim versions.
111
112diff:
113 :assertpkg diff
114 :sys {force} diff -a -C 1 pt_PT.orig.aff pt_PT.aff >pt_PT.diff
115 :sys {force} diff -a -C 1 pt_PT.orig.dic pt_PT.dic >>pt_PT.diff
116 :sys {force} diff -a -C 1 pt_BR.orig.aff pt_BR.aff >pt_BR.diff
117 :sys {force} diff -a -C 1 pt_BR.orig.dic pt_BR.dic >>pt_BR.diff
118
119
120# Check for updated OpenOffice spell files. When there are changes the
121# ".new.aff" and ".new.dic" files are left behind for manual inspection.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000122# TO BE IMPLEMENTED
Bram Moolenaare344bea2005-09-01 20:46:49 +0000123
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000124check: check-pt check-br
Bram Moolenaare344bea2005-09-01 20:46:49 +0000125
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000126check-pt:
Bram Moolenaare344bea2005-09-01 20:46:49 +0000127 :assertpkg unzip diff
128 :fetch pt_PT.zip
129 :mkdir tmp
130 :cd tmp
131 @try:
132 @import stat
133 :sys $UNZIP ../pt_PT.zip
134 :sys {force} diff ../pt_PT.orig.aff pt_PT.aff >d
135 @if os.stat('d')[stat.ST_SIZE] > 0:
136 :copy pt_PT.aff ../pt_PT.new.aff
137 :sys {force} diff ../pt_PT.orig.dic pt_PT.dic >d
138 @if os.stat('d')[stat.ST_SIZE] > 0:
139 :copy pt_PT.dic ../pt_PT.new.dic
140 @finally:
141 :cd ..
142 :delete {r}{f}{q} tmp
143 :delete pt_PT.zip
144
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000145check-br:
Bram Moolenaare344bea2005-09-01 20:46:49 +0000146 :assertpkg unzip diff
147 :fetch pt_BR.zip
148 :mkdir tmp
149 :cd tmp
150 @try:
151 @import stat
152 :sys $UNZIP ../pt_BR.zip
153 :sys {force} diff ../pt_BR.orig.aff pt_BR.aff >d
154 @if os.stat('d')[stat.ST_SIZE] > 0:
155 :copy pt_BR.aff ../pt_BR.new.aff
156 :sys {force} diff ../pt_BR.orig.dic pt_BR.dic >d
157 @if os.stat('d')[stat.ST_SIZE] > 0:
158 :copy pt_BR.dic ../pt_BR.new.dic
159 @finally:
160 :cd ..
161 :delete {r}{f}{q} tmp
162 :delete pt_BR.zip
163
164# vim: set sts=4 sw=4 :