freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][master] graph/x11/rules.mk: Use pkg-confi


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] graph/x11/rules.mk: Use pkg-config to find the X11 headers and library
Date: Wed, 13 Oct 2021 12:17:35 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

2 changed files:

Changes:

  • README
    ... ... @@ -32,22 +32,9 @@ WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
    32 32
         X11 issues
    
    33 33
         ----------
    
    34 34
     
    
    35
    -    When building the demos, the build system tries to detect your X11
    
    36
    -    path  by  looking for  the  patterns  `X11/bin`, `X11R6/bin`,  and
    
    37
    -    `X11R5/bin` in your current path (in  this order).  If no X11 path
    
    38
    -    is found, some demo programs will  not be able to display graphics
    
    39
    -    and  will fail.   If you  have X11  in an  unusual place,  use the
    
    40
    -    `X11_PATH` make variable.  More  than one directory, if necessary,
    
    41
    -    must be separated with spaces.  Example:
    
    42
    -
    
    43
    -        make X11_PATH="/usr/openwin /usr/local/X11R6"
    
    44
    -
    
    45
    -    The build system then derives  the `X11_INCLUDE` include file path
    
    46
    -    from `X11_PATH`  by appending  `/include` to all  path components.
    
    47
    -    It  also derives  the `X11_LIB`  library path  from `X11_PATH`  by
    
    48
    -    appending `/lib64` and  `/lib` to all components  (in that order).
    
    49
    -    You  might  override  those  variables similar  to  `X11_PATH`  as
    
    50
    -    arguments to `make`.
    
    35
    +    When building the demos, the build system tries to detect X11 by
    
    36
    +    using pkg-config. If X11 is not found, some demo programs will
    
    37
    +    not be able to display graphics and will fail.
    
    51 38
     
    
    52 39
         If you  don't have X11  at all, fix  the definition of  the `EXES`
    
    53 40
         variable as described in the top-level Makefile.
    

  • graph/x11/rules.mk
    ... ... @@ -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
       #
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]