Debian Codegraph @

src/interfaces/libpq-oauth/Makefile

raw
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for libpq-oauth
4 #
5 # Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # src/interfaces/libpq-oauth/Makefile
9 #
10 #-------------------------------------------------------------------------
11
12 subdir = src/interfaces/libpq-oauth
13 top_builddir = ../../..
14 include $(top_builddir)/src/Makefile.global
15
16 PGFILEDESC = "libpq-oauth - device authorization OAuth support"
17
18 # This is an internal module; we don't want an SONAME and therefore do not set
19 # SO_MAJOR_VERSION.
20 NAME = pq-oauth-$(MAJORVERSION)
21
22 # Force the name "libpq-oauth" for both the static and shared libraries. The
23 # staticlib doesn't need version information in its name.
24 override shlib := lib$(NAME)$(DLSUFFIX)
25 override stlib := libpq-oauth.a
26
27 override CPPFLAGS := -I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS) $(LIBCURL_CPPFLAGS)
28 override CFLAGS += $(PTHREAD_CFLAGS)
29
30 OBJS = \
31 $(WIN32RES)
32
33 OBJS_STATIC = oauth-curl.o
34
35 # The shared library needs additional glue symbols.
36 OBJS_SHLIB = \
37 oauth-curl_shlib.o \
38 oauth-utils.o \
39
40 oauth-utils.o: override CPPFLAGS += -DUSE_DYNAMIC_OAUTH
41 oauth-curl_shlib.o: override CPPFLAGS_SHLIB += -DUSE_DYNAMIC_OAUTH
42
43 # Add shlib-/stlib-specific objects.
44 $(shlib): override OBJS += $(OBJS_SHLIB)
45 $(shlib): $(OBJS_SHLIB)
46
47 $(stlib): override OBJS += $(OBJS_STATIC)
48 $(stlib): $(OBJS_STATIC)
49
50 SHLIB_LINK_INTERNAL = $(libpq_pgport_shlib)
51 SHLIB_LINK = $(LIBCURL_LDFLAGS) $(LIBCURL_LDLIBS) $(filter -lintl -lm $(PTHREAD_LIBS), $(LIBS))
52 SHLIB_PREREQS = submake-libpq
53 SHLIB_EXPORTS = exports.txt
54
55 # Disable -bundle_loader on macOS.
56 BE_DLLLIBS =
57
58 # Shared library stuff
59 include $(top_srcdir)/src/Makefile.shlib
60
61 # Use src/common/Makefile's trick for tracking dependencies of shlib-specific
62 # objects.
63 %_shlib.o: %.c %.o
64 $(CC) $(CFLAGS) $(CFLAGS_SL) $(CPPFLAGS) $(CPPFLAGS_SHLIB) -c $< -o $@
65
66 .PHONY: all-tests
67 all-tests: oauth_tests$(X)
68
69 oauth_tests$(X): test-oauth-curl.o oauth-utils.o $(WIN32RES) | submake-libpgport submake-libpq
70 $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(SHLIB_LINK) -o $@
71
72 #
73 # Top-Level Targets
74 #
75 # The existence of a t/ folder induces the buildfarm to run Make directly on
76 # this subdirectory, bypassing the recursion skip in src/interfaces/Makefile.
77 # Wrap the standard build targets in a with_libcurl conditional to avoid
78 # building OAuth code on platforms that haven't requested it. (The "clean"-style
79 # targets remain available.)
80 #
81
82 ifeq ($(with_libcurl), yes)
83
84 # By default, a library without an SONAME doesn't get a static library, so we
85 # add it to the build explicitly.
86 all: all-lib all-static-lib
87
88 # Ignore the standard rules for SONAME-less installation; we want both the
89 # static and shared libraries to go into libdir.
90 install: all installdirs $(stlib) $(shlib)
91 $(INSTALL_SHLIB) $(shlib) '$(DESTDIR)$(libdir)/$(shlib)'
92 $(INSTALL_STLIB) $(stlib) '$(DESTDIR)$(libdir)/$(stlib)'
93
94 installdirs:
95 $(MKDIR_P) '$(DESTDIR)$(libdir)'
96
97 check: all-tests
98 $(prove_check)
99
100 installcheck: all-tests
101 $(prove_installcheck)
102
103 endif # with_libcurl
104
105 uninstall:
106 rm -f '$(DESTDIR)$(libdir)/$(stlib)'
107 rm -f '$(DESTDIR)$(libdir)/$(shlib)'
108
109 clean distclean: clean-lib
110 rm -f $(OBJS) $(OBJS_STATIC) $(OBJS_SHLIB)
111 rm -f test-oauth-curl.o oauth_tests$(X)
112 rm -rf tmp_check