# Copyright (C) 2007 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# Makefile for pacparser. Please read README file included with this package
# for more information about pacparser.
#
# pacparser is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# pacparser 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
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

CFLAGS=-g -DXP_WIN -Wall -I..
CC=gcc

ifndef PY_HOME
  $(error PY_HOME is not defined. It should point to your installtion \
	  directory e.g. C:\Python25. To avoid this error, this file should \
	  be called by setup.py only, which takes care of setting that \
	  variable.)
endif

ifndef PY_DLL
  $(error PY_DLL is not defined. It should point to python dll location e.g. \
	  C:\Windows\System32\Python25.dll. To avoid this error, this \
	  makefile should be called by setup.py only, which takes care \
	  of setting that variable.)
endif


CFLAGS+=-I"$(PY_HOME)\include"

.PHONY: dist clean

build: _pacparser.pyd

pacparser_py.o: pacparser_py.c
	$(CC) $(CFLAGS) -c pacparser_py.c -o pacparser_py.o
	
python.dll:
	copy $(PY_DLL) python.dll

_pacparser.pyd: pacparser_py.o python.dll ..\pacparser.dll
	$(CC) -shared -o _pacparser.pyd pacparser_py.o -lpython -L. -lpacparser -L.. -lws2_32

dist: build
	if exist dist rmdir /s /q dist
	mkdir dist
	mkdir dist\pacparser
	xcopy pacparser dist\pacparser
	copy _pacparser.pyd dist\pacparser
	copy ..\pacparser.dll dist\pacparser
	copy install_win32.py dist\install.py
	copy ..\..\COPYING dist\COPYING.txt
	copy ..\..\README dist\README.txt
	copy ..\..\README.win32 dist\README.win32.txt
	copy ..\..\INSTALL dist\INSTALL.txt

clean:
	del /F pacparser_py.o _pacparser.pyd
	if exist dist rmdir /s /q dist
