# Makefile.in for mingw32.
# Supplied by Jan-Jaap van der Heijden <janjaap@Wit381304.student.utwente.nl>

# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

VPATH = .
srcdir = .

# Tools
CC = i386-mingw32-gcc
AR = i386-mingw32-ar
AS = i386-mingw32-as
NM = i386-mingw32-nm
RANLIB = i386-mingw32-ranlib
DLLTOOL = i386-mingw32-dlltool

# Where you keep your WIN32 SDK headers
SDK_INCLUDE=../../win32/include

CFLAGS = -O -Wall
INCLUDES = -nostdinc -I$(srcdir)/../include -I$(SDK_INCLUDE)
ALL_CFLAGS = $(INCLUDES) $(CFLAGS)

lib%.a:%.def
	$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib lib$*.a --def $<

.SUFFIXES: .y $(SUFFIXES) .cc .def .a

.c.o:
	$(CC) -c $(ALL_CFLAGS) $< -o $@

CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o
MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dirent.o dllmain.o gccmain.o main.o  
MOLD_OBJS = ctype_old.o string_old.o

all : libcrtdll.a \
	libmsvcrt.a \
	libmsvcrt20.a \
	libmsvcrt40.a \
	libmingw32.a \
	libmoldname.a \
	$(CRT0S)

libmingw32.a: $(MINGW_OBJS)
	$(AR) rc libmingw32.a $(MINGW_OBJS)
	$(RANLIB) libmingw32.a

libmoldname.a: $(srcdir)/moldname.def $(MOLD_OBJS)
	$(DLLTOOL) --as $(AS) -k -U	\
		--dllname crtdll.dll	\
		--def moldname.def	\
		--output-lib libmoldname.a
	$(AR) rc libmoldname.a $(MOLD_OBJS)
	$(RANLIB) libmoldname.a


crt2.o dllcrt2.o:
	$(CC) -c -D__MSVCRT__ $(ALL_CFLAGS) $< -o $@

clean:
	-rm -f *.o *.a *~ core a.out

#
# Dependancies
#
libcrtdll.a: $(srcdir)/crtdll.def
libmsvcrt.a: $(srcdir)/msvcrt.def
libmsvcrt20.a: $(srcdir)/msvcrt20.def
libmsvcrt40.a: $(srcdir)/msvcrt40.def
CRT_noglob.o: $(srcdir)/CRT_noglob.c
CRTfmode.o: $(srcdir)/CRTfmode.c
CRTglob.o: $(srcdir)/CRTglob.c
CRTinit.o: $(srcdir)/CRTinit.c
crt1.o: $(srcdir)/crt1.c $(srcdir)/init.c
crt2.o: $(srcdir)/crt1.c $(srcdir)/init.c
ctype_old.o: $(srcdir)/ctype_old.c
dllcrt1.o: $(srcdir)/dllcrt1.c $(srcdir)/init.c
dllcrt2.o: $(srcdir)/dllcrt1.c $(srcdir)/init.c
dirent.o: $(srcdir)/dirent.c
dllmain.o: $(srcdir)/dllmain.c
main.o: $(srcdir)/main.c
oldnames.o: $(srcdir)/oldnames.c
string_old.o: $(srcdir)/string_old.c
