Subject: Re: "specs" related problems
From: [email-masked] (Mumit Khan)

26 Dec 1998 13:29:10 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
To: Corinna Vinschen <[email-masked]>
Cc: Serguei DACHIAN <[email-masked]>, [email-masked]

Corinna Vinschen <[email-masked]> writes:
> If you wish to set the default include paths, you may change
> the *cpp line, e.g, to add /usr/local/include in case of cygwin,
> but not for mingw:
> 
> original:
> ---------
> *cpp:
> -remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{!mno-cygwin:-D__CYGWIN32__ -D__C
> YGWIN__} %{mno-cygwin:-iwithprefixbefore include/mingw32 -D__MINGW32__=0.2}
> 
> /usr/local/include added:
> -------------------------
> *cpp:
> -remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{!mno-cygwin:-D__CYGWIN32__ -D__C
> YGWIN__ -I/usr/local/include} %{mno-cygwin:-iwithprefixbefore include/mingw32
>  -D__MINGW32__=0.2}

I recommend not using `-I <path>' in specs file since that makes it hard
to override include paths from command line (which should always take
precendence). 

GNU CPP has the concept of "main" and "second" include paths, and more
often than not, you want to add a path to the beginning of the *second*
include path (eg., /usr/local etc). There is also the concept of "system"
include path.

Here're some of the useful ones from CPP info pages (there are web sites
out there with CPP info pages in html format):

  `-include FILE'
       Process FILE as input, and include all the resulting output,
       before processing the regular input file.

  `-idirafter DIR'
       Add the directory DIR to the second include path.  The directories
       on the second include path are searched when a header file is not
       found in any of the directories in the main include path (the one
       that `-I' adds to).

  `-iprefix PREFIX'
       Specify PREFIX as the prefix for subsequent `-iwithprefix' options.

  `-iwithprefix DIR'
       Add a directory to the second include path.  The directory's name
       is made by concatenating PREFIX and DIR, where PREFIX was
       specified previously with `-iprefix'.

  `-isystem DIR'
       Add a directory to the beginning of the second include path,
     marking it as a system directory, so that it gets the same special
     treatment as is applied to the standard system directories.

You probably want `-idirafter', so that you can override that from the
command line. Unfortunately, these options are rather obtuse and confusing
(I've used these for years, and still get confused).

Unfortunately, there are no such convenient ways to handle library paths,
and you might have to do what Corinna suggests (by adding a -L<path> to
the specs file). I however find it much more convenient to do these via
Makefiles to avoid confusion as to what paths get searched before what.

To add to the confusion, there's also the -B<prefix> option that can be
used to control both the library and system-include search paths. Argh.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".