1 #-------------------------------------------------------------------------
4 # Makefile for the port-specific subsystem of the backend
6 # These files are used in other directories for portability on systems
7 # with broken/missing library files, and for common code sharing.
9 # This makefile generates two outputs:
11 # libpgport.a - contains object files with FRONTEND defined,
12 # for use by client application and libraries
14 # libpgport_srv.a - contains object files without FRONTEND defined,
15 # for use only by the backend binaries
17 # LIBOBJS is set by configure (via Makefile.global) to be the list of object
18 # files that are conditionally needed as determined by configure's probing.
19 # OBJS adds additional object files that are always compiled.
24 #-------------------------------------------------------------------------
28 include $(top_builddir)/src/Makefile.global
30 override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
31 LIBS += $(PTHREAD_LIBS)
33 OBJS = $(LIBOBJS) chklocale.o dirmod.o erand48.o fls.o inet_net_ntop.o \
34 noblock.o path.o pgcheckdir.o pg_crc.o pgmkdirp.o pgsleep.o \
35 pgstrcasecmp.o pqsignal.o \
36 qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o
38 # foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND
39 OBJS_SRV = $(OBJS:%.o=%_srv.o)
41 all: libpgport.a libpgport_srv.a
43 # libpgport is needed by some contrib
44 install: all installdirs
45 $(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(libdir)/libpgport.a'
48 $(MKDIR_P) '$(DESTDIR)$(libdir)'
51 rm -f '$(DESTDIR)$(libdir)/libpgport.a'
56 # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)
57 thread.o: CFLAGS+=$(PTHREAD_CFLAGS)
60 # Server versions of object files
63 libpgport_srv.a: $(OBJS_SRV)
66 # Because this uses its own compilation rule, it doesn't use the
67 # dependency tracking logic from Makefile.global. To make sure that
68 # dependency tracking works anyway for the *_srv.o files, depend on
69 # their *.o siblings as well, which do have proper dependencies. It's
70 # a hack that might fail someday if there is a *_srv.o without a
71 # corresponding *.o, but it works for now (and those would probably go
72 # into src/backend/port/ anyway).
74 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
76 $(OBJS_SRV): | submake-errcodes
78 .PHONY: submake-errcodes
81 $(MAKE) -C ../backend submake-errcodes
83 # Dependency is to ensure that path changes propagate
85 path.o: path.c pg_config_paths.h
87 path_srv.o: path.c pg_config_paths.h
89 # We create a separate file rather than put these in pg_config.h
90 # because many of these values come from makefiles and are not
91 # available to configure.
92 pg_config_paths.h: $(top_builddir)/src/Makefile.global
93 echo "#define PGBINDIR \"$(bindir)\"" >$@
94 echo "#define PGSHAREDIR \"$(datadir)\"" >>$@
95 echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
96 echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
97 echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
98 echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
99 echo "#define LIBDIR \"$(libdir)\"" >>$@
100 echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
101 echo "#define LOCALEDIR \"$(localedir)\"" >>$@
102 echo "#define DOCDIR \"$(docdir)\"" >>$@
103 echo "#define HTMLDIR \"$(htmldir)\"" >>$@
104 echo "#define MANDIR \"$(mandir)\"" >>$@
106 clean distclean maintainer-clean:
107 rm -f libpgport.a libpgport_srv.a $(OBJS) $(OBJS_SRV) pg_config_paths.h