###############################################################################
##    Makefile
##
##    This file is part of Dark Hook 2
##    Copyright (C) 2005-2007 Tom N Harris <telliamed@whoopdedo.org>
##
##    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
##
###############################################################################

.SUFFIXES:
.SUFFIXES: .o .c .cpp .rc

srcdir = .
LGDIR = ../lg

CC = g++
AR = ar
DLLWRAP = dllwrap
RC = windres

DEFINES = -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DWIN32_LEAN_AND_MEAN
INCLUDES = -I. -I$(LGDIR)
LIBS = -llg -lstdc++ -luuid
ARFLAGS = rc
LDFLAGS = -mno-cygwin -mwindows -mdll -Wl,--image-base=0x12200000 -L$(LGDIR)
CFLAGS = -W -Wall -mno-cygwin -masm=intel -O3 -march=pentium -fleading-underscore
DLLFLAGS =  --target i386-mingw32 --add-underscore --add-stdcall-alias

ALL = dh2.osl libdh2.a

DLLSRCS = dh2.cpp dh2dll.cpp dh2lib.cpp
DLLOBJS = dh2.o dh2dll.o dh2_res.o

LIBSRCS = dh2lib.cpp
LIBOBJS = dh2lib.o

%.o: %.c
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ -c $<

%.o: %.cpp
	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ -c $<

all:	$(ALL)

clean:
	$(RM) $(ALL) $(DLLOBJS) $(LIBOBJS)

dh2_res.o: dh2.rc
	$(RC) $(DEFINES) -o $@ -i $<

dh2.osl: $(DLLOBJS)
	$(DLLWRAP) $(DLLFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)

libdh2.a: $(LIBOBJS)
	$(AR) $(ARFLAGS) $@ $?


dh2.o: dh2.cpp dh2.h darkhook.h objprop.h

dh2dll.o: dh2dll.cpp dh2.h darkhook.h

dh2lib.o: dh2lib.cpp darkhook.h

