1 #-------------------------------------------------------------------------
4 # Makefile for src/port
6 # These files are used by the Postgres backend, and also by frontend
7 # programs. Primarily, they are meant to provide portability on systems
8 # with broken/missing library files.
10 # This makefile generates three outputs:
12 # libpgport.a - contains object files with FRONTEND defined,
13 # for use by client applications
15 # libpgport_shlib.a - contains object files with FRONTEND defined,
16 # built suitably for use in shared libraries; for use
17 # by frontend libraries
19 # libpgport_srv.a - contains object files without FRONTEND defined,
20 # for use only by the backend
22 # LIBOBJS is set by configure (via Makefile.global) to be the list of object
23 # files that are conditionally needed as determined by configure's probing.
24 # OBJS adds additional object files that are always compiled.
29 #-------------------------------------------------------------------------
33 include $(top_builddir
)/src
/Makefile.global
35 override CPPFLAGS
:= -I
$(top_builddir
)/src
/port
-DFRONTEND
$(CPPFLAGS
)
36 LIBS
+= $(PTHREAD_LIBS
)
47 pg_popcount_avx512.o \
62 # libpgport.a, libpgport_shlib.a, and libpgport_srv.a contain the same files
63 # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
64 OBJS_SHLIB
= $(OBJS
:%.o
=%_shlib.o
)
65 OBJS_SRV
= $(OBJS
:%.o
=%_srv.o
)
67 all: libpgport.a libpgport_shlib.a libpgport_srv.a
69 # libpgport is needed by some contrib
70 install: all installdirs
71 $(INSTALL_STLIB
) libpgport.a
'$(DESTDIR)$(libdir)/libpgport.a'
72 $(INSTALL_STLIB
) libpgport_shlib.a
'$(DESTDIR)$(libdir)/libpgport_shlib.a'
75 $(MKDIR_P
) '$(DESTDIR)$(libdir)'
78 rm -f
'$(DESTDIR)$(libdir)/libpgport.a'
79 rm -f
'$(DESTDIR)$(libdir)/libpgport_shlib.a'
85 # all versions of pg_crc32c_armv8.o need CFLAGS_CRC
86 pg_crc32c_armv8.o
: CFLAGS
+=$(CFLAGS_CRC
)
87 pg_crc32c_armv8_shlib.o
: CFLAGS
+=$(CFLAGS_CRC
)
88 pg_crc32c_armv8_srv.o
: CFLAGS
+=$(CFLAGS_CRC
)
91 # Shared library versions of object files
94 libpgport_shlib.a
: $(OBJS_SHLIB
)
98 # Because this uses its own compilation rule, it doesn't use the
99 # dependency tracking logic from Makefile.global. To make sure that
100 # dependency tracking works anyway for the *_shlib.o files, depend on
101 # their *.o siblings as well, which do have proper dependencies. It's
102 # a hack that might fail someday if there is a *_shlib.o without a
103 # corresponding *.o, but there seems little reason for that.
105 $(CC
) $(CFLAGS
) $(CFLAGS_SL
) $(CPPFLAGS
) -c
$< -o
$@
108 # Server versions of object files
111 libpgport_srv.a
: $(OBJS_SRV
)
115 # Because this uses its own compilation rule, it doesn't use the
116 # dependency tracking logic from Makefile.global. To make sure that
117 # dependency tracking works anyway for the *_srv.o files, depend on
118 # their *.o siblings as well, which do have proper dependencies. It's
119 # a hack that might fail someday if there is a *_srv.o without a
120 # corresponding *.o, but it works for now (and those would probably go
121 # into src/backend/port/ anyway).
123 $(CC
) $(CFLAGS
) $(subst -DFRONTEND
,, $(CPPFLAGS
)) -c
$< -o
$@
125 # Dependency is to ensure that path changes propagate
127 path.o
: path.c pg_config_paths.h
129 path_shlib.o
: path.c pg_config_paths.h
131 path_srv.o
: path.c pg_config_paths.h
133 # We create a separate file rather than put these in pg_config.h
134 # because many of these values come from makefiles and are not
135 # available to configure.
136 pg_config_paths.h
: $(top_builddir
)/src
/Makefile.global
137 echo
"#define PGBINDIR \"$(bindir)\"" >$@
138 echo
"#define PGSHAREDIR \"$(datadir)\"" >>$@
139 echo
"#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
140 echo
"#define INCLUDEDIR \"$(includedir)\"" >>$@
141 echo
"#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
142 echo
"#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
143 echo
"#define LIBDIR \"$(libdir)\"" >>$@
144 echo
"#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
145 echo
"#define LOCALEDIR \"$(localedir)\"" >>$@
146 echo
"#define DOCDIR \"$(docdir)\"" >>$@
147 echo
"#define HTMLDIR \"$(htmldir)\"" >>$@
148 echo
"#define MANDIR \"$(mandir)\"" >>$@
151 rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
152 rm -f
$(OBJS
) $(OBJS_SHLIB
) $(OBJS_SRV
) pg_config_paths.h