* - review of ws_manager.h code
[mdictionary] / Makefile
1 ARCH = `arch`
2 REP_TAG = ../tags
3 REP_BRANCH = branches
4
5 DEB_REP_DIR = www
6
7 #declaration of directory names
8 BINARIES = bin
9 SOURCE = src
10 INCLUDE = include
11 DATA = data
12 PLUGINS = ${SOURCE}/plugins
13 XDXF_PLUGIN = ${PLUGINS}/xdxf
14 STARDICT_PLUGIN = ${PLUGINS}/stardict
15 GUI = ${SOURCE}/gui
16 MANAGER = ${SOURCE}/manager
17 DBUS = ${SOURCE}/dbus_wrapper
18 BOOKMARKS:=bdb
19 BOOKMARKS_DIR = ${SOURCE}/bookmarks/${BOOKMARKS}
20 DESTDIR = 
21
22 ifeq (${BOOKMARKS}, sql)
23         SQLITE:=-DSQLITE=0
24 endif
25
26 ifeq (${BOOKMARKS}, sql3)
27         SQLITE:=-DSQLITE=3
28 endif
29
30 PACKAGES = packages
31
32 #probably trash
33 STARDICT = stardict
34 APP_NAME = mDictionary
35
36 #versions
37 MAJOR_VER = 1
38 MINOR_VER = 0
39 PATCH_VER = 0
40 RELEASE_MAJOR_VER = 1
41 RELEASE_MINOR_VER = 0
42 RELEASE_PATCH_VER = 0
43 PACK_VER = 0
44 FRM_VER = 0.1
45
46 # VERSION_FILE = ./${INCLUDE}/ws_version.h
47
48 #package structure
49 GUI_PACK_NAME = mdictionarygui
50 MNG_PACK_NAME = mdictionary
51 PLUGINS_PACK_NAME = mdictionaryplugins
52 BOOKMARKS_PACK_NAME = mdictionarybookmarks
53 META_PACK_NAME = mdictionarydictionary
54
55 GUI_EXECUTABLE = ${BINARIES}/mdictionary
56 GUI_SERVICEFILE = org.maemo.mdictionaryGui.service
57 GUI_DIRS = ${DESTDIR}/usr/bin ${DESTDIR}/usr/share/applications/hildon ${DESTDIR}/usr/share/pixmaps ${DESTDIR}/usr/share/mis ${DESTDIR}/usr/share/dbus-1/services ${DESTDIR}/usr/share/locale  
58 #${DESTDIR}/usr/share/doc/mdictionarygui
59 GUI_DBUS = ${DATA}/other/${GUI_SERVICEFILE}
60 GUI_ICONS = ${DATA}/icons/mdictionary_icon.png ${DATA}/icons/mdictionary.png ${DATA}/icons/ws_top.png ${DATA}/icons/ws_warning_icon.png ${DATA}/icons/qgn_indi_search_mdictionary.png ${DATA}/icons/ws_tra.png ${DATA}/icons/mdictionary_about.png
61 GUI_LOCALE = ${DATA}/locale/out/
62 GUI_DOC = ${DATA}/docs/${GUI_PACK_NAME}/
63 GUI_OTHER = ${DATA}/other/mdictionary.desktop
64 GUI_MIS = ${DATA}/mis/mdictionary-search.xml
65
66 MNG_EXECUTABLE = ${BINARIES}/mdictionaryManager 
67 MNG_SERVICEFILE = org.maemo.mdictionaryManager.service
68 MNG_LIB = ${BINARIES}/engine_bookmarks.so
69 MNG_DIRS = ${DESTDIR}/usr/bin ${DESTDIR}/usr/lib/mdictionary ${DESTDIR}/usr/share/dbus-1/services  ${DESTDIR}/usr/share/mdictionary ${DESTDIR}/usr/share/doc/${MNG_PACK_NAME}
70 MNG_DBUS = ${DATA}/other/${MNG_SERVICEFILE}
71 MNG_OTHER = ${DATA}/dictionaries 
72
73 MNG_DICT1 = ${DATA}/dictionaries/FinnishEnglish/comn_sdict02_finnish-english.dict.dz ${DATA}/dictionaries/FinnishEnglish/comn_sdict02_finnish-english.idx ${DATA}/dictionaries/FinnishEnglish/comn_sdict02_finnish-english.ifo ${DESTDIR}/usr/share/mdictionary/dictionaries/FinnishEnglish/
74 MNG_DICT2 = ${DATA}/dictionaries/EnglishFinnish/dict.xdxf ${DATA}/dictionaries/EnglishFinnish/dict.cache ${DESTDIR}/usr/share/mdictionary/dictionaries/EnglishFinnish/
75
76 MNG_DICT_DIRS = ${DESTDIR}/usr/share/mdictionary/dictionaries/FinnishEnglish/ ${DESTDIR}/usr/share/mdictionary/dictionaries/EnglishFinnish/
77
78 MNG_BOOKMARKS = ${DATA}/bookmarks/${BOOKMARKS}/*
79 MNG_DOC = ${DATA}/docs/${MNG_PACK_NAME}/
80
81 PLUGINS_LIB = ${BINARIES}/engine_*.so
82 PLUGINS_DIRS = ${DESTDIR}/usr/lib/mdictionary ${DESTDIR}/usr/share/pixmaps
83 #${DESTDIR}/usr/share/doc/${PLUGINS_PACK_NAME} 
84 PLUGINS_ICONS = ${DATA}/icons/engine_xdxf_icon.png
85 PLUGINS_DOC = ${DATA}/docs/${PLUGINS_PACK_NAME}/
86
87 META_DIRS = ${PACKAGES}/${META_PACK_NAME}/usr/share/doc/${META_PACK_NAME}
88 META_DOC = ${DATA}/docs/${META_PACK_NAME}/
89
90 MAIL_ADDRESS = mdictionary-devel@garage.maemo.org
91 LOCALEDIR=/usr/share/locale
92 GETTEXT_PACKAGE=mdictionary
93 ALL_LINGUAS="en_GB"
94 #APP_VER = ${MAJOR_VER}.${MINOR_VER}.`svn info | grep "Revision:" | awk '{print $$2}'`
95
96 ifeq (${MAKECMDGOALS}, release-package)
97         APP_VER = ${RELEASE_MAJOR_VER}.${RELEASE_MINOR_VER}.${RELEASE_PATCH_VER}
98 else
99         APP_VER = ${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}-build`svn log -r HEAD -q | grep -v -e -- | awk '{print $$1}' | tr -d r`
100 endif
101
102 FILES = ${DATA}/files_debbuild
103 LOG_DIR = logs
104 LOG_CLEAN = ${LOG_DIR}/clean.log
105 LOG_BUILD = ${LOG_DIR}/build.log
106 LOG_RUN = ${LOG_DIR}/run.log
107 LOG_DEBS = ${LOG_DIR}/debs.log
108 LOG_INST = ${LOG_DIR}/install.log
109
110 first: build
111         @echo -e -n ""
112
113 tag-version: clean
114                 @install -d ${REP_TAG}/${APP_NAME}-${APP_VER}
115                 @tar -czf ${REP_TAG}/${APP_NAME}-${APP_VER}/${APP_NAME}-${APP_VER}.tar.gz ../trunk/* --exclude .svn
116                 @svn add ${REP_TAG}/${APP_NAME}-${APP_VER} 
117                 @svn ci ${REP_TAG}/${APP_NAME}-${APP_VER} -m "Tagged new version: ${APP_NAME}-${APP_VER}"
118
119 send-last:      debs
120                 @tar -czf ${APP_NAME}-${APP_VER}.tar.gz *_${APP_VER}-${PACK_VER}_${ARCH}.deb
121                 @echo -e -n "#!/bin/bash\n\
122                         mutt -x -a ~/debs.log -a ~/build.log -a ~/${APP_NAME}-${APP_VER}.tar.gz -s \"[mdictionary]: daily build - version ${APP_NAME}-${APP_VER}\" ${MAIL_ADDRESS} <~/mail.content\n\
123                         rm -f ~/${APP_NAME}-${APP_VER}.tar.gz\n" > mail.script
124
125                 @chmod +x mail.script
126
127                 @echo -e -n "\
128                         This message was generated automatically , please do not reply.\n\
129                         Attachment: ${APP_NAME}-${APP_VER}.tar.gz - tarball with the newest mdictionary's packages.\n\
130                         Attachment: build.log - logs from building binaries.\n\
131                         Attachment: debs.log - logs from making *.deb packages.\n\n\
132                         Automatic Building Framework ver: ${FRM_VER}\nCopyright 2006 ComArch S.A.\n" > mail.content
133                 @scp ${APP_NAME}-${APP_VER}.tar.gz krzsas@localhost:~/
134                 @scp ${LOG_BUILD} krzsas@localhost:~/
135                 @scp ${LOG_DEBS} krzsas@localhost:~/
136                 @scp mail.script krzsas@localhost:~/
137                 @scp mail.content krzsas@localhost:~/
138                 @rm -f mail.script
139                 @rm -f mail.content
140                 @ssh krzsas@localhost  ./mail.script
141
142 localization:
143                 @echo -e -n "Generating locale...\n"
144                 @echo -e -n "Generating locale...\n" > ${LOG_BUILD}
145                 
146                 @./generate_locale ${DATA}/locale/ ${GUI_LOCALE}
147                 @echo -e -n "Locale generation successfully completed...\n"
148                 @echo -e -n "Locale generation successfully completed...\n" > ${LOG_BUILD}
149
150 build: pre-build  ${BINARIES}/ws_dbus.o ${GUI_EXECUTABLE} ${MNG_EXECUTABLE} ${BINARIES}/engine_bookmarks.so plugins
151                 @echo -e -n "\nBuilding mdictionary is finished.\n"
152
153 pre-build:
154                 @echo -e -n "Building mdictionary... \n"
155                 @echo -e -n "" > ${LOG_BUILD}
156
157 plugins: ${BINARIES}/engine_xdxf.so ${BINARIES}/engine_stardict.so
158                 
159
160 ${MNG_EXECUTABLE}: 
161 # update-version
162                 @echo -e -n "**--> Compiling Manager...\n"
163                 @echo -e -n "**--> Compiling Manager...\n" >> ${LOG_BUILD}
164                 @make SQLITE=${SQLITE} -C ${MANAGER} >> ${LOG_BUILD}
165
166 ${BINARIES}/ws_dbus.o:
167                 @echo -e -n "**--> Compiling D-BUS Wrapper... \n"
168                 @echo -e -n "**--> Compiling D-BUS Wrapper... \n" >> ${LOG_BUILD}
169 #               @cd ${DBUS} && make >> ../../${LOG_BUILD}
170                 @make -C ${DBUS} >> ${LOG_BUILD}
171
172 ${GUI_EXECUTABLE}: 
173 #update-version
174                 @echo -e -n "**--> Compiling User Interface...\n"
175                 @echo -e -n "**--> Compiling User Interface...\n" >> ${LOG_BUILD}
176 #               @cd ${GUI} && make APP_VER=${APP_VER} >> ../../${LOG_BUILD}
177                 @make APP_VER=${APP_VER} -C ${GUI} >> ${LOG_BUILD}
178
179 ${BINARIES}/engine_xdxf.so: 
180 # update-version
181                 @echo -e -n "**--> Compiling XDXF Engine...\n"
182                 @echo -e -n "**--> Compiling XDXF Engine...\n" >> ${LOG_BUILD}
183 #               @cd ${XDXF_PLUGIN} && make >> ../../../${LOG_BUILD}
184                 @make -C ${XDXF_PLUGIN} >> ${LOG_BUILD}
185
186 ${BINARIES}/engine_stardict.so:  
187 # update-version
188                 @echo -e -n "**--> Compiling StarDict Engine...\n"
189                 @echo -e -n "**--> Compiling StarDict Engine...\n" >> ${LOG_BUILD}
190 #               @cd ${STARDICT_PLUGIN} && make >> ../../../${LOG_BUILD}
191                 @make -C ${STARDICT_PLUGIN} >> ${LOG_BUILD}
192
193 ${BINARIES}/engine_bookmarks.so: 
194 # update-version
195                 @echo -e -n "**--> Compiling Bookmarks...\n"
196                 @echo -e -n "**--> Compiling Bookmarks...\n" >> ${LOG_BUILD}
197                 @make -C ${BOOKMARKS_DIR} >> ${LOG_BUILD}
198                 
199 clean-logs:      
200                 @echo -e -n "Cleaning all logs\n"
201                 @rm -f ${LOG_DIR}/*.log
202
203 clean: clean-logs
204                 @-echo -e -n "Cleaning project directories\n"
205                 @echo -e -n "" > ${LOG_CLEAN}
206                 @-rm -f ${BINARIES}/* >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
207                 @-rm -f *~ >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
208                 @-rm -f *.deb >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
209                 @-rm -rf ${PACKAGES}/*
210                 @-make -C ${GUI} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
211                 @-make -C ${DBUS} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
212                 @-make -C ${XDXF_PLUGIN} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
213                 @-make -C ${STARDICT_PLUGIN} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
214                 @-cd ${MANAGER} && make clean >> ../../${LOG_CLEAN} 2>> ../../${LOG_CLEAN}
215                 @-make -C ${MANAGER} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN}
216                 @find src/bookmarks/ -mindepth 1 -maxdepth 1 -type d -not -name .svn -exec make -C {} clean >> ${LOG_CLEAN} 2>> ${LOG_CLEAN} \;
217                 @-rm -rf ${GUI_LOCALE}*
218                 
219 #               @-cd ${GUI} && make clean >> ../../${LOG_CLEAN} 2>> ../../${LOG_CLEAN}
220 #               @-cd ${DBUS} && make clean >> ../../${LOG_CLEAN} 2>> ../../${LOG_CLEAN}
221 #               @-cd ${XDXF_PLUGIN} && make clean >> ../../../${LOG_CLEAN} 2>> ../../../${LOG_CLEAN}
222 #               @-cd ${STARDICT_PLUGIN} && make clean >> ../../../${LOG_CLEAN} 2>> ../../../${LOG_CLEAN}
223 #               @-cd ${BOOKMARKS_DIR} && make clean >> ../../../${LOG_CLEAN} 2>> ../../../${LOG_CLEAN}
224
225 run: clean install entries run-dict clean-temp
226
227
228 run-dict:
229                 @run-standalone.sh mdictionaryManager
230
231 clean-temp:
232                 @-fakeroot rm -rf /usr/share/mdictionary
233                 @-fakeroot rm -rf /usr/lib/mdictionary
234                 @-fakeroot rm -rf /usr/include/mdictionary
235                 @-fakeroot rm -f /etc/others-menu/extra_applications/0112_mdictionarygui.desktop
236                 @-fakeroot rm -f /usr/share/applications/hildon/mdictionarygui.desktop 
237                 @-fakeroot rm -f /usr/share/pixmaps/mdictionary.png 
238                 @-fakeroot rm -f /usr/share/pixmaps/mdictionary_icon.png
239                 @-fakeroot rm -f /usr/bin/mdictionary
240                 @-fakeroot rm -f /usr/bin/mdictionaryManager
241                 @-fakeroot rm -f /usr/share/applications/hildon/mdictionarygui.desktop 
242                 @-fakeroot rm -f /usr/lib/mdictionary/engine_xdxf.so
243                 @-fakeroot rm -f /usr/lib/mdictionary/engine_stardict.so
244
245 #               gconftool-2 --recursive-unset /apps/maemo/mdictionary
246
247 install-manager: localization ${BINARIES}/ws_dbus.o  ${BINARIES}/engine_bookmarks.so ${MNG_EXECUTABLE}
248                 @install -d ${MNG_DIRS}
249                 @cp ${MNG_EXECUTABLE} ${DESTDIR}/usr/bin
250                 @cp ${MNG_LIB} ${DESTDIR}/usr/lib/mdictionary
251                 @cp ${MNG_DBUS} ${DESTDIR}/usr/share/dbus-1/services
252                 @find  ${MNG_DOC} -type f -not -path *.svn* -exec cp {} ${DESTDIR}/usr/share/doc/${MNG_PACK_NAME} \;
253                 
254 #               @install -d ${MNG_DICT_DIRS}
255 #               @cp ${MNG_DICT1}
256 #               @cp ${MNG_DICT2}
257                 
258                 @install -d ${DESTDIR}/usr/share/mdictionary/dictionaries/bookmarks
259                 @cp -rf ${MNG_BOOKMARKS} ${DESTDIR}/usr/share/mdictionary/dictionaries/bookmarks
260                 
261 install-gui:    ${BINARIES}/ws_dbus.o ${GUI_EXECUTABLE} 
262                 @install -d ${GUI_DIRS}
263                 @cp ${GUI_EXECUTABLE} ${DESTDIR}/usr/bin
264                 @cp ${GUI_ICONS} ${DESTDIR}/usr/share/pixmaps
265                 @cp ${GUI_DBUS} ${DESTDIR}/usr/share/dbus-1/services
266                 @cp ${GUI_OTHER} ${DESTDIR}/usr/share/applications/hildon
267                 @cp ${GUI_MIS} ${DESTDIR}/usr/share/mis
268                 @cp -a ${GUI_LOCALE}* ${DESTDIR}/usr/share/locale/              
269 #               @find  ${GUI_DOC} -type f -not -path *.svn* -exec cp {} ${DESTDIR}/usr/share/doc/${GUI_PACK_NAME} \;
270
271 install-plugins: plugins
272                 @install -d ${PLUGINS_DIRS}
273                 @cp ${PLUGINS_LIB} ${DESTDIR}/usr/lib/mdictionary
274                 @cp ${PLUGINS_ICONS} ${DESTDIR}/usr/share/pixmaps
275                 @install -d ${MNG_DICT_DIRS}
276                 @cp ${MNG_DICT1}
277                 @cp ${MNG_DICT2}
278 #               @find  ${PLUGINS_DOC} -type f -not -path *.svn* -exec cp {} ${DESTDIR}/usr/share/doc/${PLUGINS_PACK_NAME} \;
279
280 install-mdictionary:    install-manager install-gui install-plugins
281
282 install:        install-manager install-gui install-plugins
283                 @echo -e "\n\nIf you are installing mdictionary, please run 'make entries', before running the application ( not as root )\n\n"
284
285 entries:        
286                 gconftool-2 --type string --set /apps/maemo/mdictionary/dictionaries/StarDictSampleDict/name "Polish - English Sample Dictionary"
287                 gconftool-2 --type string --set /apps/maemo/mdictionary/dictionaries/StarDictSampleDict/path "/usr/share/mdictionary/dictionaries/StarDictSampleDict"
288                 gconftool-2 --type bool --set /apps/maemo/mdictionary/dictionaries/StarDictSampleDict/active true
289                 gconftool-2 --type bool --set /apps/maemo/mdictionary/dictionaries/StarDictSampleDict/optimized false
290                 gconftool-2 --type string --set /apps/maemo/mdictionary/dictionaries/XDXFSampleDict/name "English - Polish Sample Dictionary"
291                 gconftool-2 --type string --set /apps/maemo/mdictionary/dictionaries/XDXFSampleDict/path "/usr/share/mdictionary/dictionaries/XDXFSampleDict"
292                 gconftool-2 --type bool --set /apps/maemo/mdictionary/dictionaries/XDXFSampleDict/active true
293                 gconftool-2 --type bool --set /apps/maemo/mdictionary/dictionaries/XDXFSampleDict/optimized false
294                 
295                 gconftool-2 --type string --set /apps/maemo/mdictionary/engines/bookmarks/path "/usr/lib/mdictionary/engine_bookmarks.so"
296                 gconftool-2 --type string --set /apps/maemo/mdictionary/dictionaries/bookmarks/name "Bookmarks"
297                 gconftool-2 --type string --set /apps/maemo/mdictionary/dictionaries/bookmarks/path "/usr/share/mdictionary/dictionaries/bookmarks"
298                 gconftool-2 --type bool --set /apps/maemo/mdictionary/dictionaries/bookmarks/active false
299                 gconftool-2 --type bool --set /apps/maemo/mdictionary/dictionaries/bookmarks/optimized true
300                 chmod -R 0777 /usr/share/mdictionary/dictionaries
301                 
302                 gconftool-2 --type string --set /apps/maemo/mdictionary/engines/xdxf/path "/usr/lib/mdictionary/engine_xdxf.so"
303                 gconftool-2 --type string --set /apps/maemo/mdictionary/engines/stardict/path "/usr/lib/mdictionary/engine_stardict.so"
304                 
305 #               maemo-select-menu-location mdictionary.desktop
306
307
308 install_deb: clean-inst-log uninstall eng-deb-i mng-deb-i gui-deb-i
309                 @echo -e -n "All packages have been installed/reinstalled.\n"
310
311 clean-inst-log: 
312                 @echo -n "" > ${LOG_INST}
313
314 uninstall:
315                 @-fakeroot dpkg --purge mdictionary
316 #               @-fakeroot dpkg --purge mdictionarydictionary
317
318 display: access
319                 @fakeroot su ${USER} -c 'af-sb-init.sh start'   
320
321 display-s: access
322                 @fakeroot su ${USER} -c 'af-sb-init.sh stop'
323
324 display-r: access
325                 @fakeroot su ${USER} -c 'af-sb-init.sh restart'
326
327 access:
328                 @fakeroot chmod 0777 /var/run
329
330 release-package: clean debs meta-package
331                 @echo "Release package generation successfully completed"
332
333 snapshot: tag-version send-last
334
335 repo:   release-package meta-package
336
337         @rm -rf ${DEB_REP_DIR}
338         @./generate_repo ${DEB_REP_DIR}
339         
340 package: clean
341         dpkg-buildpackage -rfakeroot