#    padGnneco is a pad plugin for PS emulator.
#    Copyright (c) 2003 yokota (shirouto_yokota-lj@infoseek.jp)
#
#    Makefile is a derivative of padXwin v1.6
#
# * Pad for Psemu Pro like Emulators
# *
# * By: linuzappz <linuzappz@hotmail.com>
#
#    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


# CPUTYPE = k6-2
# DI_VER = 8
# NIHONGO = 1

ifndef CPUTYPE
	CPUOPT = -mcpu=pentiumpro
else
	CPUOPT = -march=$(CPUTYPE)
endif

ifndef DI_VER
	DI_VER = 7
endif

VERSION = 0
BUILD = 6
PLUGIN = padGnneco

CC = gcc
CFLAGS = -Wall -O2 $(CPUOPT)
CFLAGS += -c -DVERSION="$(VERSION)" -DBUILD="$(BUILD)" -DDI_VER="$(DI_VER)"
CFLAGS += -mno-cygwin -mwindows

RESOBJ = res.o
OBJECTS = padGnneco.o pgn_w32.o $(RESOBJ)

RC1 = brcc32
RC2 = windres
RC1FLAGS = -d__MINGW32__ -dPGN_VER="$(VERSION)" -dPGN_BLD="$(BUILD)" -dDI_VER="$(DI_VER)"
RC2FLAGS = -I res -O coff

LINK = dllwrap
LINKFLAGS = -dllname $(PLUGIN).dll -def $(PLUGIN).def
LINKFLAGS += -Wl,--enable-stdcall-fixup -mwindows

ifeq ($(DI_VER), 8)
	LIBS = -ldxguid -ldinput8
else
	LIBS = -ldxguid -ldinput
endif

COMMONFILES = Makefile padGnneco.h
COMMONFILES += pgn_res.h 

ifdef NIHONGO
RC1FLAGS += -m -dPGN_NIHONGO
CFLAGS += -DPGN_NIHONGO
COMMONFILES += pgn_resj.h
endif

all: plugin

plugin: ${OBJECTS} Makefile $(PLUGIN).def
	$(LINK) ${LINKFLAGS} ${OBJECTS} ${LIBS}
	strip $(PLUGIN).dll

clean: 
	-rm -f *.o
	-rm -f *.dll
	-rm -f *.res

objclean: 
	-rm -f *.o
	-rm -f *.res

.c.o:
	$(CC) ${CFLAGS} $< -o $@

$(RESOBJ) : pgn_res.rc $(COMMONFILES)
	$(RC1) $< $(RC1FLAGS) -fo$*.res
	$(RC2) $(RC2FLAGS) -o $@ -i $*.res

# Dependencies
padGnneco.o: padGnneco.c $(COMMONFILES)
pgn_w32.o: pgn_w32.c $(COMMONFILES)
