#
#  python/target/Makefile
#
#  Copyright (C) 2006 by Digi International Inc.
#  All rights reserved.
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License version2  as published by
#  the Free Software Foundation.

TARGET  = target

ifndef TOOLCHAIN_DIR
$(error TOOLCHAIN_DIR not defined. Export correct TOOLCHAIN_DIR location)
endif
override TOOLCHAIN_DIR := $(TOOLCHAIN_DIR:%/=%)

PATH := $(TOOLCHAIN_DIR)/usr/bin:$(PATH)

CC      = arm-linux-gcc
CXX     = arm-linux-g++
STRIP   = arm-linux-strip
AR      = arm-linux-ar

export PATH CC CXX STRIP AR

# Required for python
BASECFLAGS = -fno-strict-aliasing
CPPFLAGS = -I$(TOOLCHAIN_DIR)/include
LDFLAGS = -L$(TOOLCHAIN_DIR)/lib

export BASECFLAGS CPPFLAGS LDFLAGS

include ../Makefile.in

$(PACKAGE_DIR)/.hostpython: $(PACKAGE_DIR)/.unpacked
	(cd $(PACKAGE_DIR); rm -f config.cache; \
		unset CC CXX STRIP AR BASECFLAGS CPPFLAGS LDFLAGS; \
		./configure && \
		$(MAKE) python Parser/pgen && \
		mv python hostpython && \
		mv Parser/pgen Parser/hostpgen && \
		$(MAKE) distclean \
	);
	touch $@

$(PACKAGE_DIR)/.configured: $(PACKAGE_DIR)/.hostpython
	( cd $(PACKAGE_DIR); rm -f config.cache; \
		./configure \
		--prefix=/usr \
		--host=arm-linux \
		--disable-ipv6 \
	);
	touch $@
