Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # Copyright (C) 1996-2026 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, see
  13. # <https://www.gnu.org/licenses/>.
  14. #
  15. # Sub-makefile for login portion of the library.
  16. #
  17. subdir := login
  18. include ../Makeconfig
  19. headers := \
  20. bits/utmp.h \
  21. lastlog.h \
  22. pty.h \
  23. utmp.h \
  24. # headers
  25. routines := \
  26. forkpty \
  27. getlogin \
  28. getlogin_r \
  29. getlogin_r_chk \
  30. getpt \
  31. getutent \
  32. getutent_r \
  33. getutid \
  34. getutid_r \
  35. getutline \
  36. getutline_r \
  37. grantpt \
  38. login \
  39. login_tty \
  40. logout \
  41. logwtmp \
  42. openpty \
  43. ptsname \
  44. ptsname_r_chk \
  45. setlogin \
  46. unlockpt \
  47. updwtmp \
  48. utmp_file \
  49. utmpname \
  50. # routines
  51. CFLAGS-grantpt.c += -DLIBEXECDIR='"$(libexecdir)"'
  52. others = utmpdump
  53. ifeq (yes,$(build-pt-chown))
  54. others += \
  55. pt_chown \
  56. # others
  57. others-pie = \
  58. pt_chown \
  59. # others-pie
  60. install-others-programs = $(inst_libexecdir)/pt_chown
  61. endif
  62. subdir-dirs = programs
  63. vpath %.c programs
  64. tests := \
  65. tst-getlogin \
  66. tst-grantpt \
  67. tst-ptsname \
  68. tst-pututxline-cache \
  69. tst-pututxline-lockfail \
  70. tst-updwtmpx \
  71. tst-utmp \
  72. tst-utmp-size \
  73. tst-utmp-size-64 \
  74. tst-utmp-unsigned \
  75. tst-utmp-unsigned-64 \
  76. tst-utmpx \
  77. # tests
  78. CFLAGS-tst-utmp-size-64.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
  79. CFLAGS-tst-utmp-unsigned-64.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
  80. # Empty compatibility library for old binaries.
  81. extra-libs := libutil
  82. extra-libs-others := $(extra-libs)
  83. ifeq ($(have-GLIBC_2.33),yes)
  84. libutil-routines := libutil-compat
  85. libutil-shared-only-routines := libutil-compat
  86. # Pretend that libutil.so is a linker script, so that the symbolic
  87. # link is not installed.
  88. install-lib-ldscripts = libutil.so
  89. $(inst_libdir)/libutil.so:
  90. else # not $(have-GLIBC_2.33)
  91. libutil-inhibit-o = $(filter-out .o,$(object-suffixes))
  92. endif # $(have-GLIBC_2.33)
  93. include ../Rules
  94. CFLAGS-getpt.c += -fexceptions
  95. # Exclude fortified routines from being built with _FORTIFY_SOURCE
  96. routines_no_fortify += \
  97. getlogin_r \
  98. ptsname_r \
  99. # routines_no_fortify
  100. ifeq (yesyes,$(have-fpie)$(build-shared))
  101. pt_chown-cflags += $(pie-ccflag)
  102. endif
  103. ifeq (yes,$(have-libcap))
  104. libcap = -lcap
  105. endif
  106. CFLAGS-pt_chown.c += $(pt_chown-cflags)
  107. LDLIBS-pt_chown = $(libcap)
  108. ifeq (yesyes,$(have-fpie)$(build-shared))
  109. LDFLAGS-pt_chown = -Wl,-z,now
  110. endif
  111. # pt_chown needs to be setuid root.
  112. $(inst_libexecdir)/pt_chown: $(objpfx)pt_chown $(+force)
  113. $(make-target-directory)
  114. -$(INSTALL_PROGRAM) -m 4755 -o root $< $@
  115. $(objpfx)tst-pututxline-lockfail: $(shared-thread-library)
  116. $(objpfx)tst-pututxline-cache: $(shared-thread-library)