# HP-UX 10 has a select() in libcurses, so we need to get the libc version,
# which we do by linking -lc before -lcurses.  (Unfortunately we can't
# just not use libcurses.)  This also ensures that we get the POSIX signal
# routines in libc, not the BSD-like ones in libBSD.
LIBS := -lc $(LIBS)

# On the other hand, if we don't have POSIX signals, we need to use the
# libBSD signal routines.  (HPUX 9 and early HPUX 10 releases don't have
# POSIX signals.)  Make sure libBSD comes before libc in that case.
ifeq ($(HAVE_POSIX_SIGNALS), no)
   LIBS := -lBSD $(LIBS)
endif

# Using X/Open Networking Interfaces requires to link with libxnet.
# Without specifying this, bind(), getpeername() and so on don't work
# correctly in the LP64 data model.
LIBS := -lxnet $(LIBS)

# Set up rpath so that the executables don't need SHLIB_PATH to be set.
# (Note: --disable-rpath is a really bad idea on this platform...)
ifeq ($(with_gnu_ld), yes)
   rpath = -Wl,-rpath -Wl,'$(rpathdir)'
else
   rpath = -Wl,+b -Wl,'$(rpathdir)'
endif

# catch null pointer dereferences
ifeq ($(with_gnu_ld), yes)
# XXX what to put here?
else
   LDFLAGS += -Wl,-z
endif

# set up appropriate options for shared library builds
export_dynamic = -Wl,-E

INSTALL_SHLIB_OPTS = -m 555

AROPT = crs

ifeq ($(host_cpu), ia64)
   DLSUFFIX = .so
else
   DLSUFFIX = .sl
endif
ifeq ($(GCC), yes)
   CFLAGS_SL = -fpic
else
   CFLAGS_SL = +z
endif

# Rule for building shared libs (currently used only for regression test
# shlib ... should go away, since this is not really enough knowledge)
%$(DLSUFFIX): %.o
ifeq ($(GCC), yes)
  ifeq ($(with_gnu_ld), yes)
	$(CC) $(LDFLAGS) -shared -o $@ $< `$(CC) $(LDFLAGS) -print-libgcc-file-name`
  else
	$(LD) -b -o $@ $< `$(CC) $(LDFLAGS) -print-libgcc-file-name`
  endif
else
  ifeq ($(with_gnu_ld), yes)
	$(CC) $(LDFLAGS) -shared -o $@ $<
  else
	$(LD) -b -o $@ $<
  endif
endif

sqlmansect = 5
