#//////////////////////////////////////////////////////////////////////////
# Copyright 2001,2004,2008-2009 Ronald S. Burkey <info@sandroid.org>
#
# This file is part of GutenMark. 
#
# GutenMark 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.
#
# GutenMark 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 GutenMark; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Filename:	Makefile
# Purpose:	Builds the various utility functions used to massage
#		ispell wordlists and other wordlists into the single-word-
#		per-line format (with diacritical marks) needed by 
#		GutenMark.
# Mods:		11/09/01 RSB	Began.
#		11/17/01 RSB	Added "clean" and "all" targets.
#		12/18/01 RSB	Added USGS target.
#		12/22/01 RSB	Added NIMA target.
#		01/21/04 RSB	Added the GutenSplit and GutenSplit.exe 
#				targets.  The "exe" version is intended to
#				be a Win32 program that builds on a Linux
#				system, using a Linux version of MinGW.
#				Since few people are likely to have that
#				installed, failure doesn't cause an abort.
#		04/21/08 RSB	Corrected cross-compiler to account for
#				IMCROSS project.
#		05/09/08 RSB	Added GutenSplit-macosx
#		05/26/08 RSB	Now use ${CC} in place of gcc, and have it
#				default to cc, as suggested by Jason
#				Pollock.
#		03/09/09 RSB	Changed so that when *I* compile it, the
#				native-Linux version compiles for 32-bit 
#				CPU even if I'm using a 64-bit machine 
#				to compile it.  Changed the default target
#				so that only the native executables are 
#				built.  The new 'all-archs' target builds
#				for native Linux, Win32, and Mac OS X.
#//////////////////////////////////////////////////////////////////////////

ifndef DARWIN_VERSION
DARWIN_VERSION=darwin9
endif

ifeq "${USER}" "rburkey"
ARCH32=-m32
endif

BINS=espa~nol_filter hk2_deutsch names_english words197 string2line \
 gztest norsk utf8 USGS NoDups NIMA GutenSplit
CROSS_BINS=GutenSplit.exe GutenSplit-macosx

.PHONY: default
default: $(BINS)

.PHONY: all-archs
all-archs: default ${CROSS_BINS}

.PHONY: clean
clean:
	-rm $(BINS) ${CROSS_BINS}

.PHONY: all
all:	clean default

gztest:	gztest.c
	${CC} -g -Wall -o $@ $^ -lz

%.exe:	%.c
	@echo PATH=${PATH}
	-i386-mingw32-gcc -O2 -Wall -o $@ $^
	-i386-mingw32-strip $@
	
%-macosx: %.c
	-powerpc-apple-${DARWIN_VERSION}-gcc ${MAC_TARGETS} -O2 -Wall -o $@ $^
	-powerpc-apple-${DARWIN_VERSION}-strip $@
	
%:	%.c
	${CC} ${ARCH32} -Wall -o $@ $^
	strip $@
		
	
