]> mj.ucw.cz Git - pciutils.git/commitdiff
Use the visibility attributes only when building a shared library.
authorMartin Mares <mj@ucw.cz>
Tue, 26 Aug 2008 13:17:17 +0000 (15:17 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 26 Aug 2008 13:17:17 +0000 (15:17 +0200)
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
lib/internal.h
lib/pci.h

index bec5f864a06809870d1a10ae5a597dc65af2d18d..4861be1dec7706f950276f203a3829f16eb3a7ae 100755 (executable)
@@ -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
index 81b2b831c8b015732043fd16d04ec4c0d11e9576..62c8f3337ca632c862748bd5014c00c1bb642cf0 100644 (file)
@@ -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
 
index 747b762b0cf78ed5bf2bbb7ae35c05a8f54927a7..8f4773fbeb429cb4e8955b5e0a5c48926b926ade 100644 (file)
--- 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"