-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
127 lines (98 loc) · 3.74 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# Makefile for creating a Swedish - English dictionary based on data acquired
# from folkets lexikon http://folkets-lexikon.csc.kth.se/
#
#
###########################
DICT_NAME = "Svensk-English"
DICT_SRC_PATH = MacFolket.xml
CSS_PATH = MacFolket.css
PLIST_PATH = MacFolket.plist
DICT_BUILD_OPTS =
# Suppress adding supplementary key.
# DICT_BUILD_OPTS = -s 0 # Suppress adding supplementary key.
###########################
DICT_BUILD_TOOL_DIR = "./Dictionary Development Kit"
DICT_BUILD_TOOL_BIN = "$(DICT_BUILD_TOOL_DIR)/bin"
###########################
DICT_DEV_KIT_OBJ_DIR = ./objects
export DICT_DEV_KIT_OBJ_DIR
DESTINATION_FOLDER_USER = ~/Library/Dictionaries
DESTINATION_FOLDER_SYSTEM = /Library/Dictionaries
RM = /bin/rm
MV = /bin/mv
JING = tools/jing-20091111/bin/jing.jar
###########################
.PHONY: all fetch build install uninstall clean pristine convert_all reinstall reinstallsmall small devuninstall validate
all: fetch convert_all build
@echo -e "\n\nDone building the dictionary.\nTo install the dictionary run make install\n"
fetch:
@echo "Fetching needed files"
sh get_files.sh
build:
@echo "Building dictionary"
"$(DICT_BUILD_TOOL_BIN)/build_dict.sh" $(DICT_BUILD_OPTS) $(DICT_NAME) $(DICT_SRC_PATH) $(CSS_PATH) $(PLIST_PATH)
install: all
@echo "Installing into $(DESTINATION_FOLDER_USER)".
mkdir -p $(DESTINATION_FOLDER_USER)
ditto --noextattr --norsrc $(DICT_DEV_KIT_OBJ_DIR)/$(DICT_NAME).dictionary $(DESTINATION_FOLDER_USER)/$(DICT_NAME).dictionary
touch $(DESTINATION_FOLDER_USER)
@echo "Done."
@echo "To test the new dictionary, try Dictionary.app."
uninstall:
@echo "Uninstalling dictionary from system"
$(RM) -rf $(DESTINATION_FOLDER_USER)/$(DICT_NAME).dictionary
touch $(DESTINATION_FOLDER_USER)
clean:
@echo "Clean up"
$(RM) -rf $(DICT_DEV_KIT_OBJ_DIR)
$(RM) -rf MacFolket.xml
$(RM) -rf all.xml
$(RM) -rf out.xml
$(RM) -rf start.xml
$(RM) -rf end.xml
pristine: clean
@echo "Thoroughly clean up"
$(RM) -rf folkets_en_sv_public.xml
$(RM) -rf folkets_sv_en_public.xml
convert_all:
@echo "Converting Folkets dictionary file into Apples DictionarySchema"
@# WTF? In Makefiles you escape with $?
@# Delete last line
sed '$$ d' folkets_sv_en_public.xml > start.xml
@# Delete first 2 lines (yes +3 is first 2 lines)
tail -n +3 folkets_en_sv_public.xml > end.xml
cat start.xml end.xml > all.xml
$(RM) start.xml end.xml
xsltproc -o MacFolket.xml MacFolket.xsl all.xml
# $(RM) all.xml
sed 's/\&/\&/g' MacFolket.xml > out.xml
sed 's/\&\([, ]\)/\&\1/g' out.xml > MacFolket.xml
$(RM) out.xml
# for testing/development
reinstall: clean convert_all build install
reinstallsmall: clean small build install
small:
@echo SMALL
xsltproc -o MacFolket.xml MacFolket.xsl small.xml
sed 's/\&/\&/g' MacFolket.xml > out.xml
sed 's/\&\([, ]\)/\&\1/g' out.xml > MacFolket.xml
$(RM) out.xml
devuninstall:
@echo "DEVELOP Uninstalling dictionary from system and user"
rm -rf $(DESTINATION_FOLDER_USER)/$(DICT_NAME).dictionary
touch $(DESTINATION_FOLDER_USER)/
sudo rm -rf $(DESTINATION_FOLDER_SYSTEM)/$(DICT_NAME).dictionary
sudo touch $(DESTINATION_FOLDER_SYSTEM)/
# http://www.thaiopensource.com/relaxng/jing.html
# http://code.google.com/p/jing-trang/downloads/list
# you MUST download and unzip the apple Dictionary Development Kit in the same folder as the make file
# AND
# you MUST download and unzip jing here as well if you want to validate
validate:
java -jar $(JING) $(DICT_BUILD_TOOL_DIR)/documents/DictionarySchema/AppleDictionarySchema.rng MacFolket.xml
# 4 places where the readme has to get fixed for new update
# 1. readme.rtf -> displayed in installer
# 2. MacFolket.xsl -> Back / Front matter
# 3. plist file -> showed in dictionary config pane (2 places)
# 4. In the pkg package