#copyright (c) 2006 Kazuki IWAMOTO http://www.maid.org/ iwm@maid.org
#
#Permission is hereby granted, free of charge, to any person obtaining
#a copy of this software and associated documentation files (the
#"Software"), to deal in the Software without restriction, including
#without limitation the rights to use, copy, modify, merge, publish,
#distribute, sublicense, and/or sell copies of the Software, and to
#permit persons to whom the Software is furnished to do so, subject to
#the following conditions:
#
#The above copyright notice and this permission notice shall be included
#in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
#IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
#CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
#TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
#SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

VERSION=0.0.0

!ifndef LINK
LINK=link
!endif
!ifndef MT
MT=mt
!endif

CLFLAGS=/c /D_MBCS /DNDEBUG /DWIN32 /D_WINDOWS /D_WIN32_WINNT=0x0500 /DWINVER=0x0500 /D_CRT_SECURE_NO_DEPRECATE /Fo$@ /MD /nologo /O2 /w
LNFLAGS=/INCREMENTAL:NO /MACHINE:IX86 /NOLOGO /OUT:$@ /RELEASE /SUBSYSTEM:WINDOWS
RCFLAGS=/c1252 /d_MBCS /dNDEBUG /dWIN32 /d_WINDOWS /d_WIN32_WINNT=0x0500 /dWINVER=0x0500 /fo$@ /l0

all: iconv.dll

iconv.dll: $*.obj
	$(LINK) $(LNFLAGS) /DLL /EXPORT:_libiconv_version,@1 /EXPORT:iconv_canonicalize,@2 /EXPORT:libiconv,@3 /EXPORT:libiconv_close,@4 /EXPORT:libiconv_open,@5 /EXPORT:libiconv_set_relocation_prefix,@6 /EXPORT:libiconvctl,@7 /EXPORT:libiconvlist,@8 ole32.lib oleaut32.lib user32.lib $**
	if exist $@.manifest $(MT) -manifest $@.manifest -outputresource:$@

iconv.obj: $*.c
	$(CC) $(CLFLAGS) $**

clean:
	if exist iconv.dll del /q iconv.dll
	if exist iconv.exp del /q iconv.exp
	if exist iconv.lib del /q iconv.lib
	if exist iconv.obj del /q iconv.obj

dist:
	mkdir iconvmlang-$(VERSION)-win32
	copy /y AUTHORS iconvmlang-$(VERSION)-win32
	copy /y COPYING iconvmlang-$(VERSION)-win32
	copy /y Makefile iconvmlang-$(VERSION)-win32
	copy /y iconv.dll iconvmlang-$(VERSION)-win32
	copy /y iconv.c iconvmlang-$(VERSION)-win32
	zip -9 -r iconvmlang-$(VERSION)-win32.zip iconvmlang-$(VERSION)-win32
	rmdir /q /s iconvmlang-$(VERSION)-win32
