1# aspell-0.50.2/win32/Makefile / 02-06-10	vim600:fdm=marker
2# Author : Thorsten Maerz <torte@netztorte.de>	vim:ts=32
3#
4# Standalone makefile for building GNU Aspell-0.50 using MinGW / GCC3.2
5#
6################################################################################
7#
8# DEBUGVERSION=1: uncomment to include debugging symbols
9#DEBUGVERSION=1
10
11# CURSESDIR=<path>: (optional) location of pdcurses headers and libs
12#CURSESDIR=../../pdcurses
13
14# MSVCLIB=LIB.EXE: (optional) build import .lib for MS VC++ (needs ms lib.exe)
15#MSVCLIB=LIB.EXE
16
17# TARGET=<path-and-prefix>: (optional) prefix for cross compilation
18#TARGET=i586-mingw32msvc-
19
20# USE_GCC_2X=1: use gcc2.x (not working)
21#USE_GCC_2X=1
22
23# WIN32_RELOCATABLE=1: uncomment to have user files in <prefix>
24WIN32_RELOCATABLE=1
25
26################################################################################
27
28prefix=c:/aspell
29pkglibdir=$(prefix)/dict
30pkgdatadir=$(prefix)/data
31sysconfdir=$(prefix)
32
33top_srcdir=..
34installdir=$(prefix)
35
36################################################################################
37# {{{1	compiler settings
38
39ifdef DEBUGVERSION
40	DEBUGFLAG=-g
41else
42	OPTIMIZATION=-O3
43endif
44
45ifdef CURSESDIR
46	CURSES_INCLUDE=-I$(CURSESDIR)
47	CURSES_LIB=$(CURSESDIR)/panel.a $(CURSESDIR)/pdcurses.a
48	CURSES_DEFINES=-DHAVE_LIBCURSES -DCURSES_NON_POSIX
49endif
50
51ifdef USE_GCC_2X
52	# gcc-2.x: -fnative-struct
53	BITFIELD=-fnative-struct
54	GCC2LIBS=-lmingwex -liberty
55else
56	# gcc-3.x: -mms-bitfields
57	BITFIELD=-mms-bitfields
58endif
59
60ifdef WIN32_RELOCATABLE
61	WIN32RELOC=-DENABLE_WIN32_RELOCATABLE
62endif
63
64# cygwin: built native w32 code
65NOCYGWIN=-mno-cygwin
66
67################################################################################
68
69LIBVERSION=15
70ASPELLVERSION=0-50-3
71
72CCOMPILER=gcc
73CPPCOMPILER=g++
74CC=$(TARGET)$(CCOMPILER)
75CXX=$(TARGET)$(CPPCOMPILER)
76AR=$(TARGET)ar
77ARFLAGS=rcv
78DEFINES=$(CURSES_DEFINES) $(WIN32RELOC)
79EXTRALIBS=
80RESOURCE=
81RESCOMP=$(TARGET)windres
82STRIP=$(TARGET)strip
83NATIVE_CC=$(NATIVE)$(CCOMPILER)
84NATIVE_CXX=$(NATIVE)$(CPPCOMPILER)
85
86VPATH=	$(top_srcdir)/common:\
87	$(top_srcdir)/modules/filter:\
88	$(top_srcdir)/modules/speller/default:\
89	$(top_srcdir)/modules/tokenizer:\
90	$(top_srcdir)/lib:\
91	$(top_srcdir)/prog
92INCLUDES = \
93	-I. \
94	-I${top_srcdir}/common \
95	-I$(top_srcdir)/interfaces/cc \
96	-I$(top_srcdir)/modules/filter \
97	-I$(top_srcdir)/modules/speller/default \
98	-I$(top_srcdir)/modules/tokenizer \
99	$(CURSES_INCLUDE)
100
101FLAGS=$(DEBUGFLAG) $(BITFIELD) $(NOCYGWIN) $(OPTIMIZATION)
102CFLAGS=$(FLAGS) $(DEFINES) $(INCLUDES)
103CXXFLAGS=$(CFLAGS)
104SUPPORTLIBS=
105LIBS=-lstdc++ $(GCC2LIBS)
106
107################################################################################
108# {{{1	targets
109#
110ifndef DEBUGVERSION
111all_strip:	all strip
112endif
113
114all: \
115	aspell_common_a \
116	aspell_filter_standard_a \
117	aspell_speller_default_a \
118	aspell_tokenizer_a \
119	aspell_dll \
120	pspell_dll \
121	aspell_exe \
122	word_list_compress_exe \
123	msvc_lib
124clean: \
125	aspell_common_clean \
126	aspell_filter_standard_clean \
127	aspell_speller_default_clean \
128	aspell_tokenizer_clean \
129	aspell_dll_clean \
130	pspell_dll_clean \
131	aspell_exe_clean \
132	word_list_compress_clean \
133	msvc_lib_clean \
134	regfile_clean
135
136################################################################################
137# {{{1	aspell-common
138#
139ASPELL_COMMON_A_NAME=aspell-common-$(ASPELLVERSION).a
140
141aspell_common_OBJECTS = \
142	string.o \
143	getdata.o \
144	itemize.o \
145	file_util.o \
146	string_buffer.o \
147	string_map.o \
148	string_list.o \
149	config.o \
150	posib_err.o \
151	errors.o \
152	error.o \
153	fstream.o \
154	iostream.o \
155	info.o \
156	can_have_error.o \
157	convert.o \
158	tokenizer.o \
159	speller.o \
160	document_checker.o \
161	filter.o \
162	strtonum.o
163
164string.o:	string.cpp
165getdata.o:	getdata.cpp
166itemize.o:	itemize.cpp
167file_util.o:	file_util.cpp
168string_buffer.o:	string_buffer.cpp
169string_map.o:	string_map.cpp
170string_list.o:	string_list.cpp
171config.o:	config.cpp
172posib_err.o:	posib_err.cpp
173errors.o:	errors.cpp
174error.o:	error.cpp
175fstream.o:	fstream.cpp
176iostream.o:	iostream.cpp
177info.o:	info.cpp
178can_have_error.o:	can_have_error.cpp
179convert.o:	convert.cpp
180tokenizer.o:	tokenizer.cpp
181speller.o:	speller.cpp
182document_checker.o:	document_checker.cpp
183filter.o:	filter.cpp
184strtonum.o:	strtonum.cpp
185
186dirs.h: mk-dirs_h
187	echo '#define PREFIX "${prefix}"'            >  dirs.h
188	./mk-dirs_h ${prefix} DICT_DIR ${pkglibdir}  >> dirs.h
189	./mk-dirs_h ${prefix} DATA_DIR ${pkgdatadir} >> dirs.h
190	./mk-dirs_h ${prefix} CONF_DIR ${sysconfdir} >> dirs.h
191
192mk-dirs_h: mk-dirs_h.cpp
193	$(NATIVE_CXX) $< $(LIBS) -o $@
194
195config.cpp: dirs.h
196
197aspell_common_a: $(ASPELL_COMMON_A_NAME)
198$(ASPELL_COMMON_A_NAME): dirs.h $(aspell_common_OBJECTS)
199	$(AR) $(ARFLAGS) \
200	$@ \
201	$(aspell_common_OBJECTS)
202aspell_common_clean:
203	-rm $(aspell_common_OBJECTS) \
204	$(ASPELL_COMMON_A_NAME) \
205	mk-dirs_h.exe mk-dirs_h \
206	dirs.h
207
208#######################################################################
209# {{{1	aspell-filter-standard
210#
211ASPELL_FILTER_STANDARD_A_NAME=aspell-filter-standard.a
212aspell_filter_standard_EXTRALIBS = \
213	$(ASPELL_COMMON_A_NAME)
214
215aspell_filter_standard_OBJECTS = \
216	email.o \
217	url.o \
218	tex.o \
219	sgml.o \
220
221email.o:	email.cpp
222url.o:	url.cpp
223tex.o:	tex.cpp
224sgml.o:	sgml.cpp
225
226aspell_filter_standard_a: $(ASPELL_FILTER_STANDARD_A_NAME)
227$(ASPELL_FILTER_STANDARD_A_NAME): $(aspell_filter_standard_OBJECTS)
228	$(AR) $(ARFLAGS) \
229	$@ \
230	$+
231aspell_filter_standard_clean:
232	-rm $(aspell_filter_standard_OBJECTS) \
233	 $(ASPELL_FILTER_STANDARD_A_NAME)
234
235#######################################################################
236# {{{1	aspell-speller-default
237#
238ASPELL_SPELLER_DEFAULT_A_NAME=aspell-speller-default.a
239aspell_speller_default_EXTRALIBS = \
240	$(ASPELL_COMMON_A_NAME)
241
242aspell_speller_default_OBJECTS = \
243	data.o \
244	leditdist.o \
245	primes.o \
246	writable_base.o \
247	editdist.o \
248	speller_impl.o \
249	readonly_ws.o \
250	writable_repl.o \
251	file_data_util.o \
252	multi_ws.o \
253	split.o \
254	writable_ws.o \
255	l2editdist.o \
256	phonet.o \
257	suggest.o \
258	language.o \
259	phonetic.o \
260	typo_editdist.o \
261
262data.o:	data.cpp
263leditdist.o:	leditdist.cpp
264primes.o:	primes.cpp
265writable_base.o:	writable_base.cpp
266editdist.o:	editdist.cpp
267speller_impl.o:	speller_impl.cpp
268readonly_ws.o:	readonly_ws.cpp
269writable_repl.o:	writable_repl.cpp
270file_data_util.o:	file_data_util.cpp
271multi_ws.o:	multi_ws.cpp
272split.o:	split.cpp
273writable_ws.o:	writable_ws.cpp
274l2editdist.o:	l2editdist.cpp
275phonet.o:	phonet.cpp
276suggest.o:	suggest.cpp
277language.o:	language.cpp
278phonetic.o:	phonetic.cpp
279typo_editdist.o:	typo_editdist.cpp
280
281aspell_speller_default_a: $(ASPELL_SPELLER_DEFAULT_A_NAME)
282$(ASPELL_SPELLER_DEFAULT_A_NAME): $(aspell_speller_default_OBJECTS)
283	$(AR) $(ARFLAGS) \
284	$@ \
285	$+
286aspell_speller_default_clean:
287	-rm $(aspell_speller_default_OBJECTS) \
288	$(ASPELL_SPELLER_DEFAULT_A_NAME)
289
290################################################################################
291# {{{1	aspell-tokenizer
292#
293ASPELL_TOKENIZER_A_NAME=aspell-tokenizer.a
294aspell_tokenizer_EXTRALIBS = \
295	$(ASPELL_COMMON_A_NAME)
296
297aspell_tokenizer_OBJECTS = \
298	basic.o \
299
300basic.o:	basic.cpp
301
302aspell_tokenizer_a: $(ASPELL_TOKENIZER_A_NAME)
303$(ASPELL_TOKENIZER_A_NAME): $(aspell_tokenizer_OBJECTS)
304	$(AR) $(ARFLAGS) \
305	$@ \
306	$+
307aspell_tokenizer_clean:
308	-rm $(aspell_tokenizer_OBJECTS) \
309	$(ASPELL_TOKENIZER_A_NAME)
310
311################################################################################
312# {{{1	aspell-dll
313#
314ASPELL_DLL_NAME=aspell-$(LIBVERSION).dll
315ASPELL_DLL_LIB_NAME=libaspell-$(LIBVERSION)-dll.lib
316ASPELL_DLL_DEF_NAME=aspell-$(LIBVERSION).def
317
318aspell_dll_EXTRALIBS = \
319	$(ASPELL_FILTER_STANDARD_A_NAME) \
320	$(ASPELL_SPELLER_DEFAULT_A_NAME) \
321	$(ASPELL_TOKENIZER_A_NAME) \
322	$(ASPELL_COMMON_A_NAME)
323aspell_dll_LDFLAGS = \
324	-Wl,--export-all-symbols \
325	-Wl,--compat-implib \
326	-Wl,--out-implib=$(ASPELL_DLL_LIB_NAME) \
327	-Wl,--output-def=$(ASPELL_DLL_DEF_NAME)
328
329aspell_dll_OBJECTS = \
330	can_have_error-c.o \
331	info-c.o \
332	string_list-c.o \
333	config-c.o \
334	speller-c.o \
335	string_map-c.o \
336	error-c.o \
337	mutable_container-c.o \
338	string_pair_enumeration-c.o \
339	find_speller.o \
340	new_checker.o \
341	new_filter.o \
342	new_config.o \
343	string_enumeration-c.o \
344	word_list-c.o \
345	filter-c.o \
346	document_checker-c.o \
347
348can_have_error-c.o:	can_have_error-c.cpp
349info-c.o:	info-c.cpp
350string_list-c.o:	string_list-c.cpp
351config-c.o:	config-c.cpp
352speller-c.o:	speller-c.cpp
353string_map-c.o:	string_map-c.cpp
354error-c.o:	error-c.cpp
355mutable_container-c.o:	mutable_container-c.cpp
356string_pair_enumeration-c.o:	string_pair_enumeration-c.cpp
357find_speller.o:	find_speller.cpp
358new_checker.o:	new_checker.cpp
359new_filter.o:	new_filter.cpp
360new_config.o:	new_config.cpp
361string_enumeration-c.o:	string_enumeration-c.cpp
362word_list-c.o:	word_list-c.cpp
363filter-c.o:	filter-c.cpp
364document_checker-c.o:	document_checker-c.cpp
365
366aspell_dll: $(ASPELL_DLL_NAME)
367$(ASPELL_DLL_NAME): $(aspell_dll_OBJECTS)
368	$(CC) $(FLAGS) \
369	-shared \
370	$(aspell_dll_LDFLAGS) \
371	$+ \
372	$(aspell_dll_EXTRALIBS) \
373	$(LIBS) -o $@
374aspell_dll_clean:
375	-rm $(aspell_dll_OBJECTS) \
376	$(ASPELL_DLL_NAME) \
377	$(ASPELL_DLL_LIB_NAME) \
378	$(ASPELL_DLL_DEF_NAME)
379
380################################################################################
381# {{{1	pspell-dll
382#
383PSPELL_DLL_NAME=pspell-$(LIBVERSION).dll
384PSPELL_DLL_LIB_NAME=libpspell-$(LIBVERSION)-dll.lib
385PSPELL_DLL_DEF_NAME=pspell-$(LIBVERSION).def
386
387pspell_dll_LDFLAGS = \
388	-Wl,--compat-implib \
389	-Wl,--out-implib=$(PSPELL_DLL_LIB_NAME) \
390	-Wl,--output-def=$(PSPELL_DLL_DEF_NAME)
391pspell_dll_OBJECTS = \
392	dummy.o \
393
394dummy.o:	dummy.cpp
395
396pspell_dll: $(PSPELL_DLL_NAME)
397$(PSPELL_DLL_NAME): $(pspell_dll_OBJECTS)
398	$(CC) $(FLAGS) \
399	-shared \
400	$(pspell_dll_LDFLAGS) \
401	$+ \
402	$(LIBS) -o $@
403pspell_dll_clean:
404	-rm $(pspell_dll_OBJECTS) \
405	$(PSPELL_DLL_NAME) \
406	$(PSPELL_DLL_LIB_NAME) \
407	$(PSPELL_DLL_DEF_NAME)
408
409################################################################################
410# {{{1	aspell-exe
411#
412ASPELL_EXE_NAME=aspell.exe
413aspell_exe_EXTRALIBS = \
414	$(ASPELL_COMMON_A_NAME) \
415	$(ASPELL_DLL_LIB_NAME) \
416	$(PSPELL_DLL_LIB_NAME) \
417
418aspell_exe_OBJECTS = \
419	aspell.o \
420	check_funs.o \
421	checker_string.o \
422
423aspell.o:	aspell.cpp
424check_funs.o:	check_funs.cpp
425checker_string.o:	checker_string.cpp
426
427aspell_exe: $(ASPELL_EXE_NAME)
428$(ASPELL_EXE_NAME): $(aspell_exe_OBJECTS)
429	$(CC) $(FLAGS) \
430	$+ \
431	$(aspell_exe_EXTRALIBS) \
432	$(CURSES_LIB) \
433	$(LIBS) -o $@
434aspell_exe_clean:
435	-rm $(aspell_exe_OBJECTS) $(ASPELL_EXE_NAME)
436
437################################################################################
438# {{{1	word-list-compress
439#
440WORD_LIST_COMPRESS_EXE_NAME=word-list-compress.exe
441
442word_list_compress_OBJECTS = \
443	compress.o \
444
445compress.o:	compress.c
446
447word_list_compress_exe: $(WORD_LIST_COMPRESS_EXE_NAME)
448$(WORD_LIST_COMPRESS_EXE_NAME): $(word_list_compress_OBJECTS)
449	$(CC) $(FLAGS) \
450	$+ \
451	$(LIBS) -o $@
452word_list_compress_clean:
453	-rm $(word_list_compress_OBJECTS) $(WORD_LIST_COMPRESS_EXE_NAME)
454
455################################################################################
456# {{{1	strip
457#
458strip:
459	$(STRIP) -g \
460	$(ASPELL_DLL_NAME) \
461	$(PSPELL_DLL_NAME) \
462	$(ASPELL_EXE_NAME) \
463	$(WORD_LIST_COMPRESS_EXE_NAME)
464
465################################################################################
466# {{{1	msvc-lib
467#
468msvc_lib:
469ifdef MSVCLIB
470	-$(MSVCLIB) -machine:ix86 -def:$(ASPELL_DLL_DEF_NAME)
471	-$(MSVCLIB) -machine:ix86 -def:$(PSPELL_DLL_DEF_NAME)
472else
473	@echo "msvc .lib skipped"
474endif
475msvc_lib_clean:
476	-rm aspell-$(LIBVERSION).lib pspell-$(LIBVERSION).lib aspell-common-$(ASPELLVERSION).lib
477	-rm aspell-$(LIBVERSION).exp pspell-$(LIBVERSION).exp aspell-common-$(ASPELLVERSION).exp
478
479################################################################################
480# {{{1	install, regfile
481#
482REGFILE_NAME=aspell.reg
483
484$(REGFILE_NAME):
485	echo REGEDIT4		>  aspell.reg
486	echo 		>> aspell.reg
487	echo [HKEY_CURRENT_USER\\Environment]	>> aspell.reg
488	echo \"ASPELL_CONF\"=\"prefix $(prefix)\"	>> aspell.reg
489
490regfile: $(REGFILE_NAME)
491regfile_clean:
492	-rm $(REGFILE_NAME)
493install: regfile
494	-mkdir $(installdir)
495	-mkdir $(installdir)/$(pkglibdir)
496	-mkdir $(installdir)/$(pkgdatadir)
497	-cp  $(WORD_LIST_COMPRESS_EXE_NAME) \
498	    $(ASPELL_EXE_NAME) \
499	    $(PSPELL_DLL_NAME) \
500	    $(ASPELL_DLL_NAME) \
501	    $(installdir)
502	-cp $(top_srcdir)/data/*.dat $(installdir)/$(pkgdatadir)
503	-cp $(top_srcdir)/data/*.kbd $(installdir)/$(pkgdatadir)
504	-cp $(REGFILE_NAME) $(installdir)
505
506
507
508