[sane-devel] SANE and XSane on HP-UX

Michael Piotrowski mxp@dynalabs.de
Wed, 03 Oct 2001 01:47:17 +0200

Henning Meier-Geinitz <henning@meier-geinitz.de> writes:


> sane-devel is usually the right place for such discussions/proposals
> if the patch/change doesn't get too long.

Thanks for listening ;-)

>> SANE can be compiled with the HP ANSI C Compiler or GCC.  On HP-UX 11
>> in 64-bit mode, if using the HP Compiler, for reasons having to do
>> with dlopen(), I would recommend to use the +DA2.0W option to generate
>> a 64-bit executable. (GCC can only produce 32-bit executables and
>> behaves like on 10.20).
> Currently, README.hp-ux states:
> | Under HP-UX, it is necessary to add options -Aa and -D_HPUX_SOURCE to
> | the compiler flags when using HP's C compiler (not gcc).  This can be
> | done by invoking configure with:
> |
> | CC=cc CPPFLAGS=-D_HPUX_SOURCE CFLAGS=-Aa ./configure
> Sorry for my cluelessness: Is -D_HPUX_SOURCE necessary, or does it
> harm in your case? What's the difference between -Aa and -Ae?

The information in README.hp-ux is correct, but there's more than one
way...  Here's the story:

On HP-UX 10.20, the default mode of the compiler is to "[c]ompile in a
mode compatible with HP-UX releases prior to 7.0", i.e., K&R 1st
edition plus UNIX and HP-UX extensions.  Really crufty.

The option -Aa enables ANSI mode; this means that the header files
only define those names specified by the Standard (ISO 9899:1990).  To
access UNIX macros and typedefs you have to explicitly define the
namespace you want; you get the full set with _HPUX_SOURCE, or smaller
subsets with _POSIX_SOURCE, _XOPEN_SOURCE, etc.  c89, the POSIX
compiler, corresponds to cc -Aa -D_POSIX_SOURCE.

The option -Ae is an abbreviation for -Aa -D_HPUX_SOURCE +e.  The +e
option enables some extension, most importantly the long long type.

On HP-UX 11, the -Ae behavior is the default.

The +DA<architecture> option allows you to specify the PA-RISC version
you want to generate code for; the default is to generate code for the
platform you're running on.  So, on HP-UX 10.20, you'd typically
either use the default, or, if you're on a PA-RISC 2.0 machine, maybe
+DAportable to produce an executable that also runs on PA-RISC 1.1

However, on a PA-RISC 2.0 machine running HP-UX 11 in 64-bit mode, you
have some more options: You can generate 32-bit PA2.0 or 64-bit PA2.0
code.  This choice also implies a choice of data model (ILP32
vs. LP64) and of object file format (COFF vs. ELF).  Furthermore, some
things are only available to 64-bit (ELF) executables.  Case in point:
dlopen().  SANE checks first for dlopen(), and then for shl_load(),
the corresponding 32-bit function.  Since it finds dlopen() on an
HP-UX 11 system, it will use it.  But since the compiler generates
32-bit code by default (to which dlopen() is not available), the
resulting executable will fail to load shared libraries.

> Maybe you can rewrite the README.hp-ux for us?

I'll be glad to help.  I'll put something together from my build notes
and post it here.


Michael Piotrowski, M.A.                                  <mxp@dynalabs.de>