| 1 |
#------------------------------------------------------------------------- |
| 2 |
# |
| 3 |
# Makefile |
| 4 |
# Makefile for src/port |
| 5 |
# |
| 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. |
| 9 |
# |
| 10 |
# This makefile generates three outputs: |
| 11 |
# |
| 12 |
# libpgport.a - contains object files with FRONTEND defined, |
| 13 |
# for use by client applications |
| 14 |
# |
| 15 |
# libpgport_shlib.a - contains object files with FRONTEND defined, |
| 16 |
# built suitably for use in shared libraries; for use |
| 17 |
# by frontend libraries |
| 18 |
# |
| 19 |
# libpgport_srv.a - contains object files without FRONTEND defined, |
| 20 |
# for use only by the backend |
| 21 |
# |
| 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. |
| 25 |
# |
| 26 |
# IDENTIFICATION |
| 27 |
# src/port/Makefile |
| 28 |
# |
| 29 |
#------------------------------------------------------------------------- |
| 30 |
|
| 31 |
subdir = src/port |
| 32 |
top_builddir = ../.. |
| 33 |
include $(top_builddir)/src/Makefile.global |
| 34 |
|
| 35 |
override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS) |
| 36 |
LIBS += $(PTHREAD_LIBS) |
| 37 |
|
| 38 |
OBJS = \ |
| 39 |
$(LIBOBJS) \ |
| 40 |
$(PG_CRC32C_OBJS) \ |
| 41 |
bsearch_arg.o \ |
| 42 |
chklocale.o \ |
| 43 |
inet_net_ntop.o \ |
| 44 |
noblock.o \ |
| 45 |
path.o \ |
| 46 |
pg_bitutils.o \ |
| 47 |
pg_localeconv_r.o \ |
| 48 |
pg_numa.o \ |
| 49 |
pg_popcount_aarch64.o \ |
| 50 |
pg_popcount_avx512.o \ |
| 51 |
pg_strong_random.o \ |
| 52 |
pgcheckdir.o \ |
| 53 |
pgmkdirp.o \ |
| 54 |
pgsleep.o \ |
| 55 |
pgstrcasecmp.o \ |
| 56 |
pgstrsignal.o \ |
| 57 |
pqsignal.o \ |
| 58 |
qsort.o \ |
| 59 |
qsort_arg.o \ |
| 60 |
quotes.o \ |
| 61 |
snprintf.o \ |
| 62 |
strerror.o \ |
| 63 |
tar.o |
| 64 |
|
| 65 |
# libpgport.a, libpgport_shlib.a, and libpgport_srv.a contain the same files |
| 66 |
# foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c |
| 67 |
OBJS_SHLIB = $(OBJS:%.o=%_shlib.o) |
| 68 |
OBJS_SRV = $(OBJS:%.o=%_srv.o) |
| 69 |
|
| 70 |
all: libpgport.a libpgport_shlib.a libpgport_srv.a |
| 71 |
|
| 72 |
# libpgport is needed by some contrib |
| •73 |
install: all installdirs |
| 74 |
$(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(pkglibdir)/libpgport.a' |
| 75 |
$(INSTALL_STLIB) libpgport_shlib.a '$(DESTDIR)$(pkglibdir)/libpgport_shlib.a' |
| 76 |
|
| •77 |
installdirs: |
| 78 |
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)' |
| 79 |
|
| •80 |
uninstall: |
| 81 |
rm -f '$(DESTDIR)$(pkglibdir)/libpgport.a' |
| 82 |
rm -f '$(DESTDIR)$(pkglibdir)/libpgport_shlib.a' |
| 83 |
|
| 84 |
libpgport.a: $(OBJS) |
| 85 |
rm -f $@ |
| 86 |
$(AR) $(AROPT) $@ $^ |
| 87 |
|
| 88 |
# all versions of pg_crc32c_armv8.o need CFLAGS_CRC |
| 89 |
pg_crc32c_armv8.o: CFLAGS+=$(CFLAGS_CRC) |
| 90 |
pg_crc32c_armv8_shlib.o: CFLAGS+=$(CFLAGS_CRC) |
| 91 |
pg_crc32c_armv8_srv.o: CFLAGS+=$(CFLAGS_CRC) |
| 92 |
|
| 93 |
# |
| 94 |
# Shared library versions of object files |
| 95 |
# |
| 96 |
|
| 97 |
libpgport_shlib.a: $(OBJS_SHLIB) |
| 98 |
rm -f $@ |
| 99 |
$(AR) $(AROPT) $@ $^ |
| 100 |
|
| 101 |
# Because this uses its own compilation rule, it doesn't use the |
| 102 |
# dependency tracking logic from Makefile.global. To make sure that |
| 103 |
# dependency tracking works anyway for the *_shlib.o files, depend on |
| 104 |
# their *.o siblings as well, which do have proper dependencies. It's |
| 105 |
# a hack that might fail someday if there is a *_shlib.o without a |
| 106 |
# corresponding *.o, but there seems little reason for that. |
| 107 |
%_shlib.o: %.c %.o |
| 108 |
$(CC) $(CFLAGS) $(CFLAGS_SL) $(CPPFLAGS) -c $< -o $@ |
| 109 |
|
| 110 |
# |
| 111 |
# Server versions of object files |
| 112 |
# |
| 113 |
|
| 114 |
libpgport_srv.a: $(OBJS_SRV) |
| 115 |
rm -f $@ |
| 116 |
$(AR) $(AROPT) $@ $^ |
| 117 |
|
| 118 |
# Because this uses its own compilation rule, it doesn't use the |
| 119 |
# dependency tracking logic from Makefile.global. To make sure that |
| 120 |
# dependency tracking works anyway for the *_srv.o files, depend on |
| 121 |
# their *.o siblings as well, which do have proper dependencies. It's |
| 122 |
# a hack that might fail someday if there is a *_srv.o without a |
| 123 |
# corresponding *.o, but it works for now (and those would probably go |
| 124 |
# into src/backend/port/ anyway). |
| 125 |
%_srv.o: %.c %.o |
| 126 |
$(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@ |
| 127 |
|
| 128 |
# Dependency is to ensure that path changes propagate |
| 129 |
|
| 130 |
path.o: path.c pg_config_paths.h |
| 131 |
|
| 132 |
path_shlib.o: path.c pg_config_paths.h |
| 133 |
|
| 134 |
path_srv.o: path.c pg_config_paths.h |
| 135 |
|
| 136 |
# We create a separate file rather than put these in pg_config.h |
| 137 |
# because many of these values come from makefiles and are not |
| 138 |
# available to configure. |
| 139 |
pg_config_paths.h: $(top_builddir)/src/Makefile.global |
| 140 |
echo "#define PGBINDIR \"$(bindir)\"" >$@ |
| 141 |
echo "#define PGSHAREDIR \"$(datadir)\"" >>$@ |
| 142 |
echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@ |
| 143 |
echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ |
| 144 |
echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@ |
| 145 |
echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@ |
| 146 |
echo "#define LIBDIR \"$(libdir)\"" >>$@ |
| 147 |
echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@ |
| 148 |
echo "#define LOCALEDIR \"$(localedir)\"" >>$@ |
| 149 |
echo "#define DOCDIR \"$(docdir)\"" >>$@ |
| 150 |
echo "#define HTMLDIR \"$(htmldir)\"" >>$@ |
| 151 |
echo "#define MANDIR \"$(mandir)\"" >>$@ |
| 152 |
|
| 153 |
clean distclean: |
| 154 |
rm -f libpgport.a libpgport_shlib.a libpgport_srv.a |
| 155 |
rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h |