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 exec.o inet_net_ntop.o noblock.o \
34 path.o pgcheckdir.o pgmkdirp.o pgsleep.o pgstrcasecmp.o \
35 qsort.o qsort_arg.o sprompt.o thread.o
37 ifneq (,$(filter $(PORTNAME),cygwin win32))
41 # foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND
42 OBJS_SRV = $(OBJS:%.o=%_srv.o)
44 all: libpgport.a libpgport_srv.a
46 # libpgport is needed by some contrib
47 install: all installdirs
48 $(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(libdir)/libpgport.a'
51 $(MKDIR_P) '$(DESTDIR)$(libdir)'
54 rm -f '$(DESTDIR)$(libdir)/libpgport.a'
59 # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)
61 $(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<
64 # Server versions of object files
67 libpgport_srv.a: $(OBJS_SRV)
71 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
73 # Dependency is to ensure that path changes propagate
75 path.o: path.c pg_config_paths.h
77 path_srv.o: path.c pg_config_paths.h
79 # We create a separate file rather than put these in pg_config.h
80 # because many of these values come from makefiles and are not
81 # available to configure.
82 pg_config_paths.h: $(top_builddir)/src/Makefile.global
83 echo "#define PGBINDIR \"$(bindir)\"" >$@
84 echo "#define PGSHAREDIR \"$(datadir)\"" >>$@
85 echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
86 echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
87 echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
88 echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
89 echo "#define LIBDIR \"$(libdir)\"" >>$@
90 echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
91 echo "#define LOCALEDIR \"$(localedir)\"" >>$@
92 echo "#define DOCDIR \"$(docdir)\"" >>$@
93 echo "#define HTMLDIR \"$(htmldir)\"" >>$@
94 echo "#define MANDIR \"$(mandir)\"" >>$@
96 clean distclean maintainer-clean:
97 rm -f libpgport.a libpgport_srv.a $(OBJS) $(OBJS_SRV) pg_config_paths.h