#!/usr/bin/make
#
# A Makefile to build (read: cross-compile) liblzo2 for windows using
# mingw32 on a linux machine.
#
# The following variables and commands were puzzled together from the
# named batch files included in the upstream source (which won't help
# you if you are running mingw under linux).
#
# The paths for CC and AR might be different on your system.
# They should fit if you installed mingw32 and mingw32-binutils on a
# Debian GNU/Linux system.
#
# Just place this file in the top level directory of the lzo suite and run
# make -f liblzo2-Makefile-mingw32
#
# Maximilian Wilhelm <max@rfc2324.org>
#  -- Sun, 29 Jul 2007 04:50:30 +0200
#

# prepare.bat
CFI = -Iinclude -I.
CFASM = -DLZO_USE_ASM
BNAME = lzo2
BLIB =  lib$(BNAME).a
BDLL = lzo2.dll

# win32/mingw.bat
CC = /usr/bin/i586-mingw32msvc-gcc
CF = -O2 -fomit-frame-pointer -Wall $(CFI) $(CFASM)
LF = $(BLIB) -lwinmm -s
AR = /usr/i586-mingw32msvc/bin/ar

all:
	$(CC) $(CF) -Wno-uninitialized -c src/*.c
	
	$(CC) -x assembler-with-cpp -c asm/i386/src_gas/*.S 
	
	$(AR) rcs $(BLIB) *.o
	
	$(CC) $(CF) -o dict.exe examples/dict.c $(LF)
	$(CC) $(CF) -o lzopack.exe examples/lzopack.c $(LF)
	$(CC) $(CF) -o precomp.exe examples/precomp.c $(LF)
	$(CC) $(CF) -o precomp2.exe examples/precomp2.c $(LF)
	$(CC) $(CF) -o simple.exe examples/simple.c $(LF)
	$(CC) $(CF) -o lzotest.exe lzotest/lzotest.c $(LF)

	$(CC) $(CF) -Iinclude/lzo -Wno-uninitialized -o testmini.exe minilzo/testmini.c minilzo/minilzo.c
	
clean:
	rm -f *.o $(BLIB) $(BDLL)
