Best way to have a port...

Garrett Cooper yanefbsd at
Tue Mar 2 07:31:16 UTC 2010

Hi Warner,

On Mon, Mar 1, 2010 at 10:51 PM, M. Warner Losh <imp at> wrote:
> ... that builds part of FreeBSD?
> Let me back up...
> I'm trying to create a port for gcc and binutils that is configured
> for FreeBSD for a given machine.  FreeBSD mips, say.  binutils was
> relatively easy (once I ported our mips support forward).  However,
> gcc vexes me.  It requires, to build libgcc and friends, a fully
> populated include tree.  And it wants to use
> /usr/local/freebsd-mips/include instead of /usr/include (which is
> good).  However, the former doesn't exist.  I'd like to create a port
> for it, but I'm unclear how to even start.  This port should consist
> of all files from make includes TARGET_ARCH=mips.
> So, some questions: First, how do I know where the FreeBSD source tree
> is?  Is there some standard define like SYSDIR that contains this
> infomration?
> Second, I need to invoke make includes (and a few other things), with
> some slightly non-standard args.  is there a stylied way to do this?
> I'd like to avoid extracting everything into myport/work/FreeBSD :)
> Without solving these problems, the notion that we can use a ports
> compiler to build FreeBSD becomes less viable...

I don't know a lot of the answers (in fact, this will probably bring
up more questions than answers), but here's my experience:

1. There are a number of options available in gcc which will help pick
up the appropriate headers:

       -isysroot dir
           This option is like the --sysroot option, but applies only to
           header files.  See the --sysroot option for more information.

       -imultilib dir
           Use dir as a subdirectory of the directory containing target-spe-
           cific C++ headers.

       -isystem dir
           Search dir for header files, after all directories specified by -I
           but before the standard system directories.  Mark it as a system
           directory, so that it gets the same special treatment as is applied
           to the standard system directories.

I'm not sure why FreeBSD would be a cross-compiled overlay unless you
intend on creating a full-blown cross-compiler ala gcc, but then again
I can't read minds...

2. Packages (which all ports are converted into eventually) are the
foundation for how thing typically gets done. pkg-plist is the answer,
and pkg_create(1) is the ultimate resource for that end.

3. There's a porters handbook, but I honestly haven't read it yet: . It does have a
lot of helpful info in it though I see from just glancing at the ToC.

4. As for the non-standard includes, make wrappers are the best way to
go. If you use make -m {BLAH}/share/mk, it'll use that version's
equivalent of /usr/share/mk . There's also -I as well, just like with
cc / c++, etc. This is how I hope to resolve an ease-of-use issue with
compiling against custom src.conf's at Ironport -- it's pretty basic,
almost like straight make(1), and it gets the job done with minimal
overhead (23 lines of shell and 2 additional characters on the command

5. SRCDIR is a great idea for folks who are used to Gnu projects, but
it doesn't work with the source tree. I learned that the hard way
after wasting a day with slow compile machines...

Hopefully there will be some helpful info in there for you...


More information about the freebsd-ports mailing list