xwords/xwords4/dawg/Makefile.langcommon

264 lines
8 KiB
Makefile

# -*-mode: Makefile -*-
# Copyright 2000-2002 by Eric House (fixin@peak.org)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
FRANK_EXT = xwd
# this will make all dicts the new, larger type
#FORCE_4 = -force4
PALM_DICT_TYPE = DAWG
PAR = ../par.pl
LANGUAGE = $(shell basename $$(pwd))
#all: target_all
# let languages set this first, but we always add blank to it.
BLANK_INFO = "_" /dev/null /dev/null
# Supply a default so don't have to type so much; feel free to change
TARGET_TYPE ?= FRANK
ifdef NEWDAWG
TABLE_ARG = -mn
else
TABLE_ARG = -m
endif
##############################################################################
# PalmOS rules
##############################################################################
ifeq ($(TARGET_TYPE),PALM)
ifdef NEWDAWG
PDBTYPE = Xwr4
else
PDBTYPE = Xwr3
endif
all: $(LANG)2to8.pdb
empty: $(LANG)0to0.pdb
# Those languages that have bitmap files for custom glyphs will need to
# define BMPBINFILES and perhaps provide a rule for building the files
binfiles.stamp: $(BMPBINFILES)
touch binfiles.stamp
palmspecials.bin: ../palm_mkspecials.pl $(BMPFILES)
$< $(BLANK_INFO) $(LANG_SPECIAL_INFO) > $@
# can't just use values.bin because the specials bitmap info is
# platform-specific
palmvalues.bin: values.bin palmspecials.bin
cat $^ > $@
# values.bin: palmspecials.bin ../xloc binfiles.stamp
# cd ../ && $(MAKE) xloc
# binfileparms=""; \
# if [ "$(BMPBINFILES)" != "" ]; then \
# for f in $(BMPBINFILES)""; \
# do binfileparms="$$binfileparms -i $$f"; \
# done; \
# fi; \
# ../xloc -l $(LANGCODE) $$binfileparms -T $@
# cat palmspecials.bin >> $@
# header (first record) is node count (long) and 4 chars:
# unsigned char firstEdgeRecNum;
# unsigned char charTableRecNum;
# unsigned char valTableRecNum;
# unsigned char reserved[3]; // worst case this points to a new resource
# include "flags" as used on the other platforms
palmheader%.bin: $(LANG)%_wordcount.bin $(LANG)%_flags.bin
rm -f $@
touch $@
ifdef NEWDAWG
cat $(LANG)$*_flags.bin >> $@
endif
cat $< >> $@
perl -e "print pack(\"C\",3)" >> $@ # first edge
perl -e "print pack(\"C\",1)" >> $@ # char table rec number
perl -e "print pack(\"C\",2)" >> $@ # valTable rec number
perl -e "print pack(\"CCC\",0)" >> $@ # reserved 3 bytes
perl -e "print pack(\"CC\",0)" >> $@ # c code added two more...
# This works, but leaves out the header info that the current version
# has. I'm not sure anybody cares, though...
$(LANG)%.pdb: dawg$(LANG)%.stamp table.bin palmvalues.bin palmheader%.bin
$(PAR) c -a backup $@ \
$(basename $(@F)) $(PALM_DICT_TYPE) $(PDBTYPE) \
palmheader$*.bin table.bin palmvalues.bin dawg$(LANG)$*_*.bin
# start=$$(echo $@ | sed -e 's/$(LANG)\([0-9]*\)to[0-9]*.pdb/\1/'); \
# end=$$(echo $@ | sed -e 's/$(LANG)[0-9]*to\([0-9]*\).pdb/\1/'); \
# zcat $< | grep "^.\{$${start},$${end}\}$$" | \
# ../dict2pdb -t table.bin -v values.bin -n $(basename $(@F)) \
# > $@
# the files to export for byod
byodbins: table.bin values.bin palmvalues.bin
#endif # TARGET_TYPE==PALM
##############################################################################
# Franklin ebook rules
##############################################################################
else
ifeq ($(TARGET_TYPE),FRANK)
# If we're on a system that can build for Franklin, assume that's what
# we want to build (and the .xwd.saved [<-bug] file for other non-palm
# platforms is a by-product). But if the EBM tools aren't there, just
# build the .xwd file.
ifeq (x$(shell echo -n $$EBOOKMAN_SDK)x,xx)
all: $(LANG)2to8.xwd
else
all: $(LANG)2to8.seb
endif
empty: $(LANG)0to0.seb
ifneq (x$(shell echo -n $$EBOOKMAN_SDK)x,xx)
include ${EBOOKMAN_SDK}/ebsdk.uses
endif
# a binary file (one byte) giving the number of tiles in the dict
charcount.bin: table.bin
ifdef NEWDAWG
siz=$$(wc -c $< | sed -e 's/$<//'); \
perl -e "print pack(\"c\",$$siz/2)" > $@
else
siz=$$(wc -c $< | sed -e 's/$<//'); \
perl -e "print pack(\"c\",$$siz)" > $@
endif
# For each entry in the table whose face < 32, there needs to be a pair of
# pbitm files and a string giving the printing form
frankspecials.bin: ../frank_mkspecials.pl $(BMPFILES)
$< $(BLANK_INFO) $(LANG_SPECIAL_INFO) > $@
# xlock.bin is an artifact of the Palm format which the shipping
# eBookman code expects, but simply skips. It could be eliminated in
# the NEWDAWG format, i.e. for flags != 0x0001
xlock.bin:
perl -e "print pack(\"n\",0)" > $@
$(LANG)%.$(FRANK_EXT): dawg$(LANG)%.stamp $(LANG)%_flags.bin charcount.bin table.bin values.bin frankspecials.bin xlock.bin
cat $(LANG)$*_flags.bin charcount.bin table.bin values.bin \
frankspecials.bin $(LANG)StartLoc.bin xlock.bin \
$$(ls dawg$(LANG)$*_*.bin) > $@
cp $@ saveme.bin
$(LANG)%.seb: $(LANG)%.$(FRANK_EXT) $(LANG)%.atts
${ESDK_CREATESEB_EXE} $<
cp $< $<.saved
$(LANG)%.atts: #recreate it each time based on params
echo '_PUB|global+read-only|"Eric_House"' >> $@
echo "_NAME|global+read-only|\"$(LANG)2to8\"" >> $@
echo "_EXT|global+read-only|\"$(FRANK_EXT)\"" >> $@
echo '_LCAT|nosign+global|"CONTENT"' >> $@
echo '_PERM|global+read-only|"r"' >> $@
# values.bin: ../xloc
# cd ../ && $(MAKE) xloc
# ../xloc -l $(LANGCODE) -T $@
# the files to export for byod
byodbins: table.bin values.bin frankspecials.bin
else
(Need to define TARGET_TYPE if get error pointing to this line)
endif #ifeq ($(TARGET_TYPE),FRANK)
endif
ifeq (s$(TARGET_TYPE),s)
It's an error not to specify a TARGET_TYPE
endif
##############################################################################
# shared rules
##############################################################################
# For some reason I can't fathom dawg$(LANG)% gets nuked every time
# the top-level rule fires (all: for whatever TARGET_TYPE.) It
# happens after the rule finishes....
# 16 bits worth of flags for the start of the eventual file. At this
# point, the flags mean this:
# 1: old-style DAWG.
# 2: new-style DAWG, three bytes per node.
# 3: new-style DAWG, four bytes per node
$(LANG)%_flags.bin: dawg$(LANG)%.stamp
ifdef NEWDAWG
if [ 3 == $$(cat $(LANG)$*_nodesize.bin) ] ; \
then perl -e "print pack(\"n\",0x0002)" > $@; echo "flags=2"; \
else perl -e "print pack(\"n\",0x0003)" > $@; echo "flags=3"; \
fi
else
if [ 3 == $$(cat $(LANG)$*_nodesize.bin) ] ; \
then perl -e "print pack(\"n\",0x0001)" > $@; echo "flags=1"; \
else echo "ERROR: old format can't handle 4-byte"; exit 1; \
fi
endif
dawg$(LANG)%.stamp: $(LANG)Main.dict.gz ../dict2dawg.pl table.bin ../Makefile.langcommon
start=$$(echo $@ | sed -e 's/dawg$(LANG)\([0-9]*\)to[0-9]*.stamp/\1/'); \
end=$$(echo $@ | sed -e 's/dawg$(LANG)[0-9]*to\([0-9]*\).stamp/\1/'); \
echo $${start} and $$end; \
zcat $< | grep "^.\{$${start},$${end}\}$$" | tr '\n' '\0'| \
sort -z | ../dict2dawg.pl $(TABLE_ARG) table.bin -b 28000 \
-ob dawg$(LANG)$* \
-sn $(LANG)StartLoc.bin -k -term 0 -wc $(LANG)$*_wordcount.bin \
$(FORCE_4) -ns $(LANG)$*_nodesize.bin
touch $@
$(LANG)%_wordcount.bin: dawg$(LANG)%.stamp
@echo
# the files to export for byod
allbins:
$(MAKE) TARGET_TYPE=PALM byodbins
$(MAKE) TARGET_TYPE=FRANK byodbins
table.bin: ../xloc.pl
ifdef NEWDAWG
perl -I../ ../xloc.pl -tn > $@
else
perl -I../ ../xloc.pl -t > $@
endif
values.bin: ../xloc.pl
perl -I../ ../xloc.pl -v > $@
%.dict: %.dict.gz
zcat $< > $@
clean_common:
rm -f $(LANG)Main.dict *.bin *.pdb *.seb dawg*.stamp *.$(FRANK_EXT) \
$(LANG)*.pdb $(LANG)*.seb
help:
@echo "make TARGET_TYPE=[FRANK|PALM]"
test:
@echo $(LANGUAGE)