From 59a0211a49bccb35875a8ec4f1b3ce06f006b7f1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 26 Aug 2008 15:17:17 +0200 Subject: [PATCH] Use the visibility attributes only when building a shared library. Omair Eshkenazi has reported that libpci fails to build with gcc 3.x. We require gcc 4.x for building shared libraries, but it should not be needed when SHARED=no. This patch changes internal.h to define PCI_ABI as the visibility attribute only if we build a shared library. However, this means that we need to know the configuration settings before we include pci.h, so I had to include config.h explicitly from internal.h and create a new symbol PCI_CONFIG_H to check whether config.h has been already included. --- lib/configure | 2 ++ lib/internal.h | 4 +++- lib/pci.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/configure b/lib/configure index bec5f86..4861be1 100755 --- a/lib/configure +++ b/lib/configure @@ -42,6 +42,7 @@ echo " $host $rel" c=config.h m=config.mk +echo >$c '#define PCI_CONFIG_H' echo >$c "#define PCI_ARCH_`echo $cpu | tr '[a-z]' '[A-Z]'`" echo >>$c "#define PCI_OS_`echo $sys | tr '[a-z]' '[A-Z]'`" echo >$m 'WITH_LIBS=' @@ -164,6 +165,7 @@ else # We link the dependencies _to_ the library, so we do not need explicit deps in .pc echo >>$m 'LDLIBS=' echo >>$m 'LIB_LDLIBS=$(WITH_LIBS)' + echo >>$c '#define PCI_SHARED_LIB' if [ "$SHARED" = yes ] ; then echo >>$m 'SONAME=-Wl,-soname,$(LIBNAME).so$(ABI_VERSION)' fi diff --git a/lib/internal.h b/lib/internal.h index 81b2b83..62c8f33 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -6,7 +6,9 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ -#ifdef __GNUC__ +#include "config.h" + +#ifdef PCI_SHARED_LIB #define PCI_ABI __attribute__((visibility("default"))) #endif diff --git a/lib/pci.h b/lib/pci.h index 747b762..8f4773f 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -9,7 +9,10 @@ #ifndef _PCI_LIB_H #define _PCI_LIB_H +#ifndef PCI_CONFIG_H #include "config.h" +#endif + #include "header.h" #include "types.h" -- 2.39.2