PDA

View Full Version : mspgcc4 uses a Perl script to fetch and build, how to integrate with ports?


caesius
May 14th, 2011, 12:28
Context: The MSP430 range is a line of microcontrollers from Texas Instruments. The very cheap Launchpad development boards from TI now feature a MSP chip only supported by mspgcc4.

I have built and tested mspgcc4 on FreeBSD. There were no issues. I'd like to have a go at porting it. I've emailed the maintainer of devel/msp430-gcc to see if he/she would rather do this but have had no response.

All I had to do to make it work was this:

1. Install ftp/wget
2. Download mspgcc4-20110312.tar.bz2 from http://sourceforge.net/projects/mspgcc4/files/ and extract it.
3. Run buildgcc.pl and answer a few questions.

It's step 3 that's got me. How does one integrate this with FreeBSD ports? I've had a look through the Perl script, it in turn calls a sh script which fetches the gcc source, patches it (presumably to add stuff for the msp430) and then builds the executable.

In fact the mspgcc4-20110312.tar.bz2 archive doesn't actually contain any source from what I can see. It is also responsible for building msp430-gdb, msp430-binutils and msp430-libc. You can choose to install these by selecting them in the build-gcc.pl script.

It seems like the Perl script is doing everything the ports system would do!

What is the standard approach for integrating something like this into the ports tree?

Cheers.

DutchDaemon
May 15th, 2011, 01:26
As to steps 1 and 2: why install wget when the base system has, and the ports tree makes use of, fetch to get the tarballs?

caesius
May 15th, 2011, 05:58
As to steps 1 and 2: why install wget when the base system has, and the ports tree makes use of, fetch to get the tarballs?

The build-gcc.pl script uses wget to fetch the gcc source. It fails if it is not installed.

I guess that IS my question. Should I dissect the build script to find out what it does, then create a Makefile? Or is there a standard way to integrate something like this into ports?

SirDice
May 16th, 2011, 11:07
Should I dissect the build script to find out what it does, then create a Makefile?
That's the way to do it.

Or is there a standard way to integrate something like this into ports?
Not for a complex fetch/build/install script like this one.

caesius
July 2nd, 2011, 13:56
UPDATE: I'm working my way through the build scripts the project provides, trying to translate things into something usable as a port.

mspgcc4 (what I'm porting) requires a patched version of GNU Binutils, so I'm creating a new port called "msp430-binutils221" (version 2.21+patches) that will work with mspgcc4. I've called it this so I don't break compatibility with the old devel/msp430-binutils that works with mspgcc3.

New problem: the project provides the patch that must be applied to GNU Binutils, but it's not the sort of patch I'm used to; it patches an entire folder of files.

It's called binutils-2.21.patch and it is meant to be used thus:

tar xzf binutils-2.21.tar.gz
( cd binutils-2.21 ; patch -p1 < ../binutils-2.21.patch )


It patches *a lot* of files. How can I integrate this with the ports system? I'm not going to go through and create individual patches for ~200 files, but simply trying to get the patch target to apply the patch to a folder doesn't work.

Yes I'm aware that it would be easier if ports could fetch the source with the patches already applied, but the patched source doesn't seem to be available.

Summary: how do I get ports to apply a patch on a directory?

wblock@
July 2nd, 2011, 14:34
It should not be necessary to make all those patches into FreeBSD port patches. x11-clocks/gdesklets-clock applies its own patches in do-build. lang/gnat does it in pre-patch, which seems better. If there are FreeBSD port patches, they should apply after any built-in patching.

The ports tree is so big that there are examples of most use cases. These were found with
find /usr/ports -name Makefile -exec grep -H \{PATCH\} {} \+ | less -S

caesius
July 2nd, 2011, 15:22
Ah I see. I will put it in its own pre-patch section.

What about the way the patch is being applied, how can I do it in the Makefile without being in the current directory?

I tried this with no success:

> patch -p1 work/binutils-2.21 files/binutils-2.21.patch
[...]
patch: **** work/binutils-2.21 is not a normal file--can't patch


Will it be easier to just use cd in the Makefile like below? Do I have to worry about preserving and restoring the cwd?

cd ${WRKSRC}/binutils-2.21
@${PATCH} -p1 < ${FILESDIR}/binutils-2.21.patch


Thanks.

wblock@
July 2nd, 2011, 19:34
@${PATCH} -d ${WRKSRC} -p1 < ${FILESDIR}/binutils-2.21.patch

(untested)