... |
... |
@@ -5,94 +5,18 @@ |
5
|
5
|
#*
|
6
|
6
|
#**************************************************************************
|
7
|
7
|
|
8
|
|
-
|
9
|
|
-#############################################################################
|
10
|
|
-#
|
11
|
|
-# Try to detect an X11 setup.
|
12
|
|
-#
|
13
|
|
-# The goal is to define variable `X11_PATH', consisting of a list of
|
14
|
|
-# directories `A', `B', `C', ..., separated by spaces. While compiling the
|
15
|
|
-# demo programs that need X11 support, include file directories `A/include',
|
16
|
|
-# `B/include', etc., are passed to the compiler. While linking, directories
|
17
|
|
-# `A/lib', `A/lib64', `B/lib', `B/lib64', etc., are passed to the linker.
|
18
|
|
-# Note that it doesn't pose a problem to specify both 32bit and 64bit library
|
19
|
|
-# directories at the same time since the linker will properly reject the
|
20
|
|
-# incorrect ones.
|
21
|
|
-#
|
22
|
|
-# 1) We try to detect the following directories (in that order) as substrings
|
23
|
|
-# in the current path:
|
24
|
|
-#
|
25
|
|
-# X11/bin (usually a symlink to the current release)
|
26
|
|
-# X11R6/bin
|
27
|
|
-# X11R5/bin
|
28
|
|
-#
|
29
|
|
-# From the first hit we derive `X11_PATH' (by removing the `/bin' part).
|
30
|
|
-#
|
31
|
|
-# 2) If no success, we directly check the directories
|
32
|
|
-#
|
33
|
|
-# /usr
|
34
|
|
-# /usr/X11R6
|
35
|
|
-# /usr/local/X11R6
|
36
|
|
-#
|
37
|
|
-# whether they contain `include/X11/Xlib.h'. The first hit sets up
|
38
|
|
-# `X11_PATH'.
|
39
|
|
-#
|
40
|
|
-# 3) If the variable `X11_PATH' is already set (to specify unusual locations
|
41
|
|
-# of X11), no other directories are searched. For instance, let us assume
|
42
|
|
-# that the X11 header files are located in `/usr/local/X11/R6/include',
|
43
|
|
-# and the X11 library files in `/usr/openwin/lib'. Calling
|
44
|
|
-#
|
45
|
|
-# make X11_PATH="/usr/openwin /usr/local/X11R6"
|
46
|
|
-#
|
47
|
|
-# should then work.
|
48
|
|
-#
|
49
|
|
-FT_PATH := $(subst ;, ,$(subst :, ,$(subst $(SEP),/,$(PATH))))
|
50
|
|
-
|
51
|
|
-ifndef X11_PATH
|
52
|
|
- ifneq ($(findstring X11/bin,$(FT_PATH)),)
|
53
|
|
- xversion := X11
|
54
|
|
- else
|
55
|
|
- ifneq ($(findstring X11R6/bin,$(FT_PATH)),)
|
56
|
|
- xversion := X11R6
|
57
|
|
- else
|
58
|
|
- ifneq ($(findstring X11R5/bin,$(FT_PATH)),)
|
59
|
|
- xversion := X11R5
|
60
|
|
- endif
|
61
|
|
- endif
|
62
|
|
- endif
|
63
|
|
-
|
64
|
|
- ifdef xversion
|
65
|
|
- X11_PATH := $(filter %$(xversion)/bin,$(FT_PATH))
|
66
|
|
- X11_PATH := $(X11_PATH:%/bin=%)
|
67
|
|
- else
|
68
|
|
- X11_DIRS := /usr /usr/X11R6 /usr/local/X11R6
|
69
|
|
- X11_XLIB := include/X11/Xlib.h
|
70
|
|
- X11_PATH := $(foreach dir,$(X11_DIRS),$(wildcard $(dir)/$(X11_XLIB)))
|
71
|
|
- X11_PATH := $(X11_PATH:%/$(X11_XLIB)=%)
|
72
|
|
- endif
|
|
8
|
+ifeq ($(PKG_CONFIG),)
|
|
9
|
+ PKG_CONFIG = pkg-config
|
73
|
10
|
endif
|
74
|
11
|
|
|
12
|
+X11_INCLUDE := $(shell $(PKG_CONFIG) --cflags x11)
|
|
13
|
+X11_LIB := $(shell $(PKG_CONFIG) --libs x11)
|
75
|
14
|
|
76
|
|
-##########################################################################
|
77
|
|
-#
|
78
|
|
-# Update some variables to compile the X11 graphics module. Note that
|
79
|
|
-# X11 is available on Unix, or on OS/2. However, it only compiles with
|
80
|
|
-# gcc on the latter platform, which is why it is safe to use the flags
|
81
|
|
-# `-L' and `-l' in GRAPH_LINK.
|
82
|
|
-#
|
83
|
|
-ifneq ($(X11_PATH),)
|
84
|
|
-
|
85
|
|
- X11_INCLUDE := $(subst /,$(COMPILER_SEP),$(X11_PATH:%=%/include))
|
86
|
|
- X11_LIB := $(subst /,$(COMPILER_SEP),$(X11_PATH:%=%/lib64) \
|
87
|
|
- $(X11_PATH:%=%/lib))
|
88
|
|
-
|
|
15
|
+ifneq ($(X11_LIB),)
|
89
|
16
|
# The GRAPH_LINK variable is expanded each time an executable is linked
|
90
|
17
|
# against the graphics library.
|
91
|
18
|
#
|
92
|
|
- ifeq ($(PLATFORM),unix)
|
93
|
|
- GRAPH_LINK += $(X11_LIB:%=-R%)
|
94
|
|
- endif
|
95
|
|
- GRAPH_LINK += $(X11_LIB:%=-L%) -lX11
|
|
19
|
+ GRAPH_LINK += $(X11_LIB)
|
96
|
20
|
|
97
|
21
|
# Solaris needs a -lsocket in GRAPH_LINK.
|
98
|
22
|
#
|