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

CLFLAGS=/c /D_UNICODE /DUNICODE /DNDEBUG /DWIN32 /D_WINDOWS /D_WIN32_WINNT=0x0500 /DWINVER=0x0500 /D_CRT_SECURE_NO_DEPRECATE /Fo$@ /MD /nologo /O2
LNFLAGS=/INCREMENTAL:NO /MACHINE:IX86 /NOLOGO /OUT:$@ /RELEASE /SUBSYSTEM:WINDOWS
RCFLAGS=/c932 /D_UNICODE /DUNICODE /dNDEBUG /dWIN32 /d_WINDOWS /d_WIN32_WINNT=0x0500 /dWINVER=0x0500 /fo$@ /l0
INCLUDES=/Imisc /Isrc

OBJECTS=\
	src\tmaid.res \
	misc\argument.obj \
	misc\dialog.obj \
	misc\fndir.obj \
	misc\history.obj \
	misc\imectrl.obj \
	misc\license.obj \
	misc\memapi.obj \
	misc\other.obj \
	misc\valstr.obj \
	src\abort.obj \
	src\edit.obj \
	src\file.obj \
	src\find.obj \
	src\format.obj \
	src\ftype.obj \
	src\general.obj \
	src\jump.obj \
	src\print.obj \
	src\prop.obj \
	src\reload.obj \
	src\repinfo.obj \
	src\replace.obj \
	src\tmaid.obj \
	src\valchr.obj \
	src\version.obj \
	src\wndmain.obj \
	src\wndtext.obj

all: src\tmaid.exe doc\tmaid.chm

src\tmaid.exe: $(OBJECTS)
	$(LINK) $(LNFLAGS) advapi32.lib comctl32.lib comdlg32.lib gdi32.lib htmlhelp.lib ole32.lib shell32.lib user32.lib $**
	if exist $@.manifest $(MT) -manifest $@.manifest -outputresource:$@;#1

src\tmaid.res: $*.rc $*.ico
	$(RC) $(RCFLAGS) $*.rc

misc\argument.obj: $*.c $*.h misc\memapi.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\fndir.obj: $*.c $*.h misc\memapi.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\dialog.obj: $*.c $*.h misc\memapi.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\history.obj: $*.c $*.h misc\dialog.h misc\fndir.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\imectrl.obj: $*.c $*.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\license.obj: $*.c $*.h misc\dialog.h misc\memapi.h misc\other.h src\resource.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\memapi.obj: $*.c $*.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\other.obj: $*.c $*.h misc\fndir.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

misc\valstr.obj: $*.c $*.h misc\memapi.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\abort.obj: $*.c $*.h misc\fndir.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\edit.obj: $*.c $*.h misc\fndir.h misc\memapi.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\file.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\history.h misc\memapi.h misc\other.h src\abort.h src\general.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\find.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\memapi.h misc\other.h src\abort.h src\edit.h src\general.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\format.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\memapi.h misc\other.h src\general.h src\prop.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\ftype.obj: $*.c $*.h misc\fndir.h misc\other.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\general.obj: $*.c $*.h misc\fndir.h misc\imectrl.h misc\memapi.h misc\other.h src\edit.h src\find.h src\replace.h src\resource.h src\tmaid.h src\valchr.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\jump.obj: $*.c $*.h misc\dialog.h misc\fndir.h src\edit.h src\general.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\print.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\memapi.h misc\other.h misc\valstr.h src\abort.h src\edit.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\prop.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\other.h src\ftype.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\reload.obj: $*.c $*.h misc\fndir.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\repinfo.obj: $*.c $*.h misc\fndir.h misc\other.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\replace.obj: $*.c $*.h misc\dialog.h misc\fndir.h src\find.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\tmaid.obj: $*.c $*.h misc\argument.h misc\dialog.h misc\fndir.h misc\license.h misc\memapi.h misc\other.h misc\valstr.h src\file.h src\find.h src\jump.h src\replace.h src\resource.h src\valchr.h src\wndmain.h src\wndtext.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\valchr.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\other.h misc\valstr.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\version.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\license.h src\resource.h src\tmaid.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\wndmain.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\history.h misc\imectrl.h misc\memapi.h misc\other.h misc\valstr.h src\file.h src\find.h src\format.h src\general.h src\jump.h src\replace.h src\resource.h src\tmaid.h src\valchr.h src\version.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

src\wndtext.obj: $*.c $*.h misc\dialog.h misc\fndir.h misc\history.h misc\imectrl.h misc\memapi.h misc\other.h misc\valstr.h src\abort.h src\edit.h src\file.h src\find.h src\general.h src\jump.h src\print.h src\prop.h src\reload.h src\resource.h src\repinfo.h src\replace.h src\tmaid.h src\valchr.h
	$(CC) $(CLFLAGS) $(INCLUDES) $*.c

doc\tmaid.chm: $*.hhc $*.hhk $*.hhp doc\address.htm doc\auto.htm doc\auto.png doc\code.htm doc\code.png doc\command.htm doc\date.htm doc\edit.htm doc\euc-jp.htm doc\filetype.htm doc\filetype.png doc\find.htm doc\find.png doc\ftype.htm doc\ftype.png doc\history.htm doc\history.png doc\index.htm doc\input.htm doc\install.htm doc\intro.htm doc\iso-2022.htm doc\margin.htm doc\open.htm doc\other.htm doc\print.htm doc\property.htm doc\property.png doc\repinfo.htm doc\repinfo.png doc\replace.htm doc\replace.png doc\shiftjis.htm doc\tab.htm doc\unicode.htm doc\utf-7.htm doc\utf-8.htm
	-$(HHC) $*.hhp

clean:
	if exist src\tmaid.exe del /q src\tmaid.exe
	if exist doc\tmaid.chm del /q doc\tmaid.chm
	for %f in ($(OBJECTS)) do if exist %f del /q %f

dist: src\tmaid.exe doc\tmaid.chm
	mkdir tmaid
	mkdir tmaid\doc
	mkdir tmaid\misc
	mkdir tmaid\src
	copy /y ChangeLog tmaid
	copy /y COPYING tmaid
	copy /y Makefile tmaid
	copy /y README tmaid
	copy /y doc\address.htm tmaid\doc
	copy /y doc\auto.htm tmaid\doc
	copy /y doc\auto.png tmaid\doc
	copy /y doc\code.htm tmaid\doc
	copy /y doc\code.png tmaid\doc
	copy /y doc\command.htm tmaid\doc
	copy /y doc\date.htm tmaid\doc
	copy /y doc\edit.htm tmaid\doc
	copy /y doc\euc-jp.htm tmaid\doc
	copy /y doc\filetype.htm tmaid\doc
	copy /y doc\filetype.png tmaid\doc
	copy /y doc\find.htm tmaid\doc
	copy /y doc\find.png tmaid\doc
	copy /y doc\ftype.htm tmaid\doc
	copy /y doc\ftype.png tmaid\doc
	copy /y doc\history.htm tmaid\doc
	copy /y doc\history.png tmaid\doc
	copy /y doc\index.htm tmaid\doc
	copy /y doc\input.htm tmaid\doc
	copy /y doc\install.htm tmaid\doc
	copy /y doc\intro.htm tmaid\doc
	copy /y doc\iso-2022.htm tmaid\doc
	copy /y doc\margin.htm tmaid\doc
	copy /y doc\open.htm tmaid\doc
	copy /y doc\other.htm tmaid\doc
	copy /y doc\print.htm tmaid\doc
	copy /y doc\property.htm tmaid\doc
	copy /y doc\property.png tmaid\doc
	copy /y doc\repinfo.htm tmaid\doc
	copy /y doc\repinfo.png tmaid\doc
	copy /y doc\replace.htm tmaid\doc
	copy /y doc\replace.png tmaid\doc
	copy /y doc\shiftjis.htm tmaid\doc
	copy /y doc\tab.htm tmaid\doc
	copy /y doc\tmaid.hhc tmaid\doc
	copy /y doc\tmaid.hhk tmaid\doc
	copy /y doc\tmaid.hhp tmaid\doc
	copy /y doc\unicode.htm tmaid\doc
	copy /y doc\utf-7.htm tmaid\doc
	copy /y doc\utf-8.htm tmaid\doc
	copy /y misc\argument.c tmaid\misc
	copy /y misc\argument.h tmaid\misc
	copy /y misc\dialog.c tmaid\misc
	copy /y misc\dialog.h tmaid\misc
	copy /y misc\fndir.c tmaid\misc
	copy /y misc\fndir.h tmaid\misc
	copy /y misc\history.c tmaid\misc
	copy /y misc\history.h tmaid\misc
	copy /y misc\imectrl.c tmaid\misc
	copy /y misc\imectrl.h tmaid\misc
	copy /y misc\license.c tmaid\misc
	copy /y misc\license.h tmaid\misc
	copy /y misc\memapi.c tmaid\misc
	copy /y misc\memapi.h tmaid\misc
	copy /y misc\other.c tmaid\misc
	copy /y misc\other.h tmaid\misc
	copy /y misc\valstr.c tmaid\misc
	copy /y misc\valstr.h tmaid\misc
	copy /y src\abort.c tmaid\src
	copy /y src\abort.h tmaid\src
	copy /y src\edit.c tmaid\src
	copy /y src\edit.h tmaid\src
	copy /y src\file.c tmaid\src
	copy /y src\file.h tmaid\src
	copy /y src\find.c tmaid\src
	copy /y src\find.h tmaid\src
	copy /y src\format.c tmaid\src
	copy /y src\format.h tmaid\src
	copy /y src\ftype.c tmaid\src
	copy /y src\ftype.h tmaid\src
	copy /y src\general.c tmaid\src
	copy /y src\general.h tmaid\src
	copy /y src\jump.c tmaid\src
	copy /y src\jump.h tmaid\src
	copy /y src\print.c tmaid\src
	copy /y src\print.h tmaid\src
	copy /y src\prop.c tmaid\src
	copy /y src\prop.h tmaid\src
	copy /y src\reload.c tmaid\src
	copy /y src\reload.h tmaid\src
	copy /y src\repinfo.c tmaid\src
	copy /y src\repinfo.h tmaid\src
	copy /y src\replace.c tmaid\src
	copy /y src\replace.h tmaid\src
	copy /y src\resource.h tmaid\src
	copy /y src\tmaid.c tmaid\src
	copy /y src\tmaid.h tmaid\src
	copy /y src\tmaid.ico tmaid\src
	copy /y src\tmaid.rc tmaid\src
	copy /y src\valchr.c tmaid\src
	copy /y src\valchr.h tmaid\src
	copy /y src\version.c tmaid\src
	copy /y src\version.h tmaid\src
	copy /y src\wndmain.c tmaid\src
	copy /y src\wndmain.h tmaid\src
	copy /y src\wndtext.c tmaid\src
	copy /y src\wndtext.h tmaid\src
	zip -9 -r tmaid.zip tmaid
	rmdir /q /s tmaid
	mkdir tm019uja
	copy /y ChangeLog tm019uja
	copy /y COPYING tm019uja
	copy /y README tm019uja
	copy /y src\tmaid.exe tm019uja
	copy /y doc\tmaid.chm tm019uja
	copy /y tmaid.zip tm019uja
	zip -9 -r tm019uja.zip tm019uja
	del /q tmaid.zip
	rmdir /q /s tm019uja
