From 9bf6c8cb1aacc020d40b1abb7433b8eec662b858 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Thu, 10 Feb 2005 02:27:08 +0000
Subject: [PATCH] Auto-detect presence of used X headers and set NO_X if
 they're not present. Move X_HEADERS and X_PATH macros into Common.gmake
 rather than GNUmakefile for no good reason.

---
 src/conio/Common.gmake | 10 +++++++++-
 src/conio/GNUmakefile  |  6 +-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/conio/Common.gmake b/src/conio/Common.gmake
index 610b8c0cf3..edc0223c07 100644
--- a/src/conio/Common.gmake
+++ b/src/conio/Common.gmake
@@ -1,3 +1,11 @@
+X_PATH ?=	/usr/X11R6
+X_HEADERS	?=	$(X_PATH)$(DIRSEP)include
+X_PRESENT	= $(shell if [ ! \( -f $(X_HEADERS)$(DIRSEP)X11$(DIRSEP)Xlib.h -a -f $(X_HEADERS)$(DIRSEP)X11$(DIRSEP)Xutil.h -a -f $(X_HEADERS)$(DIRSEP)X11$(DIRSEP)keysym.h -a -f $(X_HEADERS)$(DIRSEP)X11$(DIRSEP)Xatom.h \) ] ; then echo NO ; else echo YES ; fi )
+ifeq ($(X_PRESENT),NO)
+ NO_X=1
+else
+endif
+
 ifeq ($(os),sunos)
  CIOLIB-MT_LIBS		+=	$(UL_PRE)curses$(UL_SUF)
 else
@@ -5,7 +13,7 @@ else
 endif
 ifndef NO_X
  ifdef STATIC
-  CIOLIB-MT_LIBS		+=	-L/usr/X11R6/lib -lX11
+  CIOLIB-MT_LIBS		+=	-L$(X_PATH)$(DIRSEP)lib -lX11
  else
   ifeq ($(os),linux)
    CIOLIB-MT_LIBS		+=  $(UL_PRE)dl$(UL_SUF)
diff --git a/src/conio/GNUmakefile b/src/conio/GNUmakefile
index 37fff0e19a..9151ede717 100644
--- a/src/conio/GNUmakefile
+++ b/src/conio/GNUmakefile
@@ -3,15 +3,11 @@ SRC_ROOT = ..
 include $(SRC_ROOT)/build/Common.gmake	# defines clean and output directory rules
 
 CFLAGS += $(XPDEV-MT_CFLAGS) $(CIOLIB-MT_CFLAGS)
-X_HEADERS	?=	/usr/X11R6/include
 
 OBJS	+=	$(MTOBJODIR)$(DIRSEP)curs_cio$(OFILE)
 ifdef NO_X
  CFLAGS	+=	-DNO_X
 else
- ifdef X_PATH
-  X_HEADERS	?=	$(X_PATH)$(DIRSEP)include
- endif
  CFLAGS	+=	-I$(X_HEADERS)
  OBJS	+=	$(MTOBJODIR)$(DIRSEP)console$(OFILE) \
 			$(MTOBJODIR)$(DIRSEP)x_cio$(OFILE)
@@ -22,7 +18,7 @@ endif
 
 $(MTOBJODIR)$(DIRSEP)console$(OFILE).static:
 	$(QUIET)$(DELETE) $(MTOBJODIR)$(DIRSEP)console$(OFILE)*
-	$(QUIET)touch $(MTOBJODIR)$(DIRSEP)console$(OFILE).static	
+	$(QUIET)touch $(MTOBJODIR)$(DIRSEP)console$(OFILE).static
 
 $(MTOBJODIR)$(DIRSEP)console$(OFILE).dynamic:
 	$(QUIET)$(DELETE) $(MTOBJODIR)$(DIRSEP)console$(OFILE)*
-- 
GitLab