about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xbuildtools/configure.pl72
-rw-r--r--other/pamx/Makefile26
2 files changed, 60 insertions, 38 deletions
diff --git a/buildtools/configure.pl b/buildtools/configure.pl
index e532e9af..1b65bec8 100755
--- a/buildtools/configure.pl
+++ b/buildtools/configure.pl
@@ -1167,43 +1167,49 @@ sub getX11Library($@) {
     my ($platform, @suggestedHdrDir) = @_;
 
     my $x11lib;
-    {
-        my $default;
-
-        if (-d('/usr/link/X11')) {
-            $default = '/usr/link/X11/libX11' . libSuffix($platform);
-        } elsif (-d('/usr/X11R6/lib')) {
-            $default = '/usr/X11R6/lib/libX11' . libSuffix($platform);
-        } else {
-            $default = "libX11" . libSuffix($platform);
-        }
-        print("What is your X11 (X client) library?\n");
-        
-        my $response = prompt("library filename or 'none'", $default);
-        
-        if ($response ne "none") {
-            $x11lib = $response;
-        }
-    }
     my $x11hdr_dir;
-    if (defined($x11lib)) {
-        my $default;
 
-        $default = "default";
+    if (system('pkg-config x11 --exists') == 0) {
+        # We don't need to ask where X libraries are; pkg-config knows and the
+        # make files will use that.
+    } else {
+        {
+            my $default;
 
-        print("Where are the interface headers for it?\n");
-        
-        my $response = prompt("X11 header directory", $default);
-        
-        if ($response ne "default") {
-            $x11hdr_dir = $response;
+            if (-d('/usr/link/X11')) {
+                $default = '/usr/link/X11/libX11' . libSuffix($platform);
+            } elsif (-d('/usr/X11R6/lib')) {
+                $default = '/usr/X11R6/lib/libX11' . libSuffix($platform);
+            } else {
+                $default = "libX11" . libSuffix($platform);
+            }
+            print("What is your X11 (X client) library?\n");
+            
+            my $response = prompt("library filename or 'none'", $default);
+            
+            if ($response ne "none") {
+                $x11lib = $response;
+            }
         }
-        if (defined($x11hdr_dir)) {
-            if (!-d($x11hdr_dir)) {
-                warnUser("No directory named '$x11hdr_dir' exists.");
-            } elsif (!-d("$x11hdr_dir/X11")) {
-                warnUser("Directory '$x11hdr_dir' does not contain " .
-                         "the requisite 'X11' subdirectory");
+        if (defined($x11lib)) {
+            my $default;
+
+            $default = "default";
+
+            print("Where are the interface headers for it?\n");
+            
+            my $response = prompt("X11 header directory", $default);
+            
+            if ($response ne "default") {
+                $x11hdr_dir = $response;
+            }
+            if (defined($x11hdr_dir)) {
+                if (!-d($x11hdr_dir)) {
+                    warnUser("No directory named '$x11hdr_dir' exists.");
+                } elsif (!-d("$x11hdr_dir/X11")) {
+                    warnUser("Directory '$x11hdr_dir' does not contain " .
+                             "the requisite 'X11' subdirectory");
+                }
             }
         }
     }
diff --git a/other/pamx/Makefile b/other/pamx/Makefile
index a40ea3a6..b41cadf8 100644
--- a/other/pamx/Makefile
+++ b/other/pamx/Makefile
@@ -8,13 +8,23 @@ VPATH=.:$(SRCDIR)/$(SUBDIR)
 include $(BUILDDIR)/config.mk
 
 EXTERN_INCLUDE =
-ifneq ($(X11LIB),NONE)
-  ifneq ($(X11HDR_DIR),)
-    EXTERN_INCLUDES += -I$(X11HDR_DIR)
+
+ifeq ($(shell pkg-config x11 --modversion --silence-errors),)
+  # Pkg-config has never heard of X11, or doesn't even exist
+
+  ifneq ($(X11LIB),NONE)
+    HAVE_X11LIB = Y
+    ifneq ($(X11HDR_DIR)x,x)
+      EXTERN_INCLUDES += -I$(X11HDR_DIR)
+    endif
   endif
+else
+  HAVE_X11LIB = Y
+  X11LIB = $(shell pkg-config x11 --libs)
+  EXTERN_INCLUDES += $(shell pkg-config x11 --cflags)
 endif
 
-ifneq ($(X11LIB),NONE)
+ifeq ($(HAVE_X11LIB),Y)
   BINARIES += pamx
 
   PAMX_OBJECTS = \
@@ -39,7 +49,13 @@ all: $(BINARIES)
 
 include $(SRCDIR)/common.mk
 
+ifeq ($(shell pkg-config x11 --libs),)
+  X11_LIBOPTS = $(shell $(LIBOPT) $(LIBOPTR) $(X11LIB))
+else
+  X11_LIBOPTS = $(shell pkg-config x11 --libs)
+endif
+
 pamx: $(PAMX_OBJECTS) $(NETPBMLIB) $(LIBOPT)
 	$(LD) -o $@ $(PAMX_OBJECTS) \
-	  $(shell $(LIBOPT) $(NETPBMLIB) $(X11LIB)) \
+	  $(shell $(LIBOPT) $(NETPBMLIB) $(X11_LIBOPTS)) \
 	  $(LDFLAGS) $(LDLIBS) $(MATHLIB) $(RPATH) $(LADD)