SUMMARY="A retargettable, optimizing ANSI-C compiler suite"
DESCRIPTION="SDCC is a retargettable, optimizing ANSI-C compiler suite that \
targets the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), \
Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 \
based (hc08, s08), Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 2000/3000, \
Rabbit 3000A, TLCS-90) and STMicroelectronics STM8. Work is in progress on \
supporting the Microchip PIC16 and PIC18 targets. It can be retargeted for \
other microprocessors."
HOMEPAGE="http://sdcc.sourceforge.net"
COPYRIGHT="1999-2021 Sandeep Dutta"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://sourceforge.net/projects/sdcc/files/sdcc/$portVersion/sdcc-src-$portVersion.tar.bz2"
SOURCE_DIR="sdcc"
CHECKSUM_SHA256="81edf776d5a2dc61a4b5c3408929db7b25874d69c46e4a71b116be1322fd533f"
PATCHES="sdcc-4.0.0.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	sdcc$secondaryArchSuffix = $portVersion
	cmd:as2gbmap
	cmd:makebin
	cmd:packihx
	cmd:s51
	cmd:savr
	cmd:sdar
	cmd:sdas390
	cmd:sdas6808
	cmd:sdas8051
	cmd:sdasgb
	cmd:sdaspdk13
	cmd:sdaspdk14
	cmd:sdaspdk15
	cmd:sdaspdk16
	cmd:sdasrab
	cmd:sdasstm8
	cmd:sdastlcs90
	cmd:sdasz80
	cmd:sdcc = $portVersion
	cmd:sdcdb
	cmd:sdcdb.el
	cmd:sdcdbsrc.el
	cmd:sdcpp
	cmd:sdld
	cmd:sdld6808
	cmd:sdldgb
	cmd:sdldpdk
	cmd:sdldstm8
	cmd:sdldz80
	cmd:sdnm
	cmd:sdobjcopy
	cmd:sdranlib
	cmd:shc08
	cmd:sm6809
	cmd:sp1516
	cmd:spdk
	cmd:sst7
	cmd:sstm8
	cmd:stlcs
	cmd:sz80
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libboost_graph$secondaryArchSuffix >= 1.70.0
	devel:libiconv$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:autoconf
	cmd:autoreconf
	cmd:automake
	cmd:bison
	cmd:find
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:gpasm
	cmd:gperf
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:makeinfo
	"

BUILD()
{
	pushd device/lib/pic16
	autoreconf -f
	popd

	pushd device/non-free/lib/pic16
	autoreconf -f
	popd

	pushd device/lib/pic14
	autoreconf -f
	popd

	pushd device/non-free/lib/pic14
	autoreconf -f
	popd

	pushd support/cpp
	autoconf
	popd

	mkdir -p build
	pushd build

	CFLAGS="-DO_ASYNC=0" \
	LDFLAGS="-lnetwork" \
	runConfigure ../configure \
		--bindir=$prefix/bin \
		--enable-avr-port \
		--enable-mcs51-port \
		--enable-z80-port \
		--enable-z180-port \
		--enable-r3ka-port \
		--enable-gbz80-port \
		--enable-tlcs90-port \
		--enable-ez80-z80-port \
		--enable-ds390-port \
		--enable-ds400-port \
		--enable-pic14-port \
		--enable-pic16-port \
		--enable-hc08-port \
		--enable-s08-port \
		--enable-stm8-port \
		--enable-pdk13-port \
		--enable-pdk14-port \
		--enable-pdk15-port \
		--enable-pdk16-port \
		--disable-doc \
		--without-ccache
	make $jobArgs
	popd
}

INSTALL()
{
	pushd build
	make install
	popd
}
