Fix a compiler warning in initStringInfo().
[pgsql.git] / src / port / Makefile
blob4c224319512a9fd45a6ee1c7d1c1feab7e989c8a
1 #-------------------------------------------------------------------------
3 # Makefile
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.
26 # IDENTIFICATION
27 # src/port/Makefile
29 #-------------------------------------------------------------------------
31 subdir = src/port
32 top_builddir = ../..
33 include $(top_builddir)/src/Makefile.global
35 override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
36 LIBS += $(PTHREAD_LIBS)
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_popcount_avx512.o \
48 pg_strong_random.o \
49 pgcheckdir.o \
50 pgmkdirp.o \
51 pgsleep.o \
52 pgstrcasecmp.o \
53 pgstrsignal.o \
54 pqsignal.o \
55 qsort.o \
56 qsort_arg.o \
57 quotes.o \
58 snprintf.o \
59 strerror.o \
60 tar.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'
74 installdirs:
75 $(MKDIR_P) '$(DESTDIR)$(libdir)'
77 uninstall:
78 rm -f '$(DESTDIR)$(libdir)/libpgport.a'
79 rm -f '$(DESTDIR)$(libdir)/libpgport_shlib.a'
81 libpgport.a: $(OBJS)
82 rm -f $@
83 $(AR) $(AROPT) $@ $^
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)
95 rm -f $@
96 $(AR) $(AROPT) $@ $^
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.
104 %_shlib.o: %.c %.o
105 $(CC) $(CFLAGS) $(CFLAGS_SL) $(CPPFLAGS) -c $< -o $@
108 # Server versions of object files
111 libpgport_srv.a: $(OBJS_SRV)
112 rm -f $@
113 $(AR) $(AROPT) $@ $^
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).
122 %_srv.o: %.c %.o
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)\"" >>$@
150 clean distclean:
151 rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
152 rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h