mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
279 lines
8.2 KiB
Makefile
279 lines
8.2 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 is now on for all dicts and languages. dict2dawg.pl can't
|
|
# produce the old form any longer.
|
|
NEWDAWG=foo
|
|
|
|
# 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
|
|
|
|
ifeq ($(TARGET_TYPE),WINCE)
|
|
WINCE_ONLY = true
|
|
endif
|
|
|
|
.PHONY: clean_common help allbins checkARCH
|
|
|
|
|
|
##############################################################################
|
|
# PalmOS rules
|
|
##############################################################################
|
|
ifeq ($(TARGET_TYPE),PALM)
|
|
|
|
ifdef NEWDAWG
|
|
PDBTYPE = XwrD
|
|
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 $@
|
|
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
|
|
ifdef NEWDAWG
|
|
cat $(LANG)$*_flags.bin >> $@
|
|
else
|
|
perl -e "print pack(\"CC\",0)" >> $@ # c code added two more...
|
|
endif
|
|
|
|
|
|
# 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 info.txt
|
|
|
|
#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
|
|
empty: $(LANG)0to0.xwd
|
|
else
|
|
all: checkARCH $(LANG)2to8.seb
|
|
empty: $(LANG)0to0.seb
|
|
include ${EBOOKMAN_SDK}/ebsdk.uses
|
|
endif
|
|
|
|
checkARCH:
|
|
if [[ $$ARCH == "" ]]; then \
|
|
$(error "ARCH must be defined in ENV if TARGET_TYPE==FRANK"); \
|
|
fi
|
|
|
|
$(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"' >> $@
|
|
|
|
# the files to export for byod
|
|
byodbins: table.bin values.bin frankspecials.bin info.txt
|
|
|
|
|
|
else
|
|
ifeq ($(TARGET_TYPE),WINCE)
|
|
|
|
### WINCE section here ###
|
|
all: $(LANG)2to8.xwd
|
|
../mkxwdcab.pl -f $<
|
|
|
|
else
|
|
(Need to define TARGET_TYPE if get error pointing to this line)
|
|
endif #ifeq ($(TARGET_TYPE),FRANK)
|
|
endif
|
|
endif
|
|
|
|
ifeq (s$(TARGET_TYPE),s)
|
|
echo "It\'s an error not to specify a TARGET_TYPE"
|
|
endif
|
|
|
|
##############################################################################
|
|
# shared rules
|
|
##############################################################################
|
|
|
|
# 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) > $@
|
|
|
|
# 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
|
|
|
|
$(LANG)%.$(FRANK_EXT): dawg$(LANG)%.stamp $(LANG)%_flags.bin charcount.bin table.bin values.bin frankspecials.bin
|
|
cat $(LANG)$*_flags.bin charcount.bin table.bin values.bin \
|
|
frankspecials.bin $(LANG)StartLoc.bin \
|
|
$$(ls dawg$(LANG)$*_*.bin) > $@
|
|
cp $@ saveme.bin
|
|
|
|
|
|
# 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"; \
|
|
elif [ 4 = $$(cat $(LANG)$*_nodesize.bin) ] ; \
|
|
then perl -e "print pack(\"n\",0x0003)" > $@; echo "flags=3"; \
|
|
elif true; \
|
|
then echo "Unexpected node size"; exit 1; \
|
|
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
|
|
rm palmspecials.bin
|
|
|
|
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]"
|
|
|