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
18 # $PostgreSQL: pgsql/src/port/Makefile,v 1.23 2005/03/20 02:40:28 momjian Exp $
20 #-------------------------------------------------------------------------
24 include $(top_builddir)/src/Makefile.global
26 override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
27 LIBS += $(PTHREAD_LIBS)
29 # Replace object files that use FRONTEND define
30 LIBOBJS_SRV := $(LIBOBJS)
31 LIBOBJS_SRV := $(patsubst dirmod.o,dirmod_srv.o, $(LIBOBJS_SRV))
32 LIBOBJS_SRV := $(patsubst exec.o,exec_srv.o, $(LIBOBJS_SRV))
33 LIBOBJS_SRV := $(patsubst getaddrinfo.o,getaddrinfo_srv.o, $(LIBOBJS_SRV))
34 LIBOBJS_SRV := $(patsubst snprintf.o,snpritnf_srv.o, $(LIBOBJS_SRV))
35 LIBOBJS_SRV := $(patsubst thread.o,thread_srv.o, $(LIBOBJS_SRV))
37 all: libpgport.a libpgport_srv.a
39 # libpgport is needed by some contrib
41 $(INSTALL_STLIB) libpgport.a $(DESTDIR)$(libdir)
44 $(RM) $(DESTDIR)$(libdir)/libpgport.a
46 libpgport.a: $(LIBOBJS)
50 $(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<
52 path.o: path.c pg_config_paths.h
55 # Server versions of object files
58 libpgport_srv.a: $(LIBOBJS_SRV)
61 dirmod_srv.o: dirmod.c
62 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
65 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
67 getaddrinfo_srv.o: getaddrinfo.c
68 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
70 snprintf_srv.o: snprintf.c
71 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
73 # No thread flags for server version
74 thread_srv.o: thread.c
75 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
77 # Dependency is to ensure that path changes propagate
78 pg_config_paths.h: $(top_builddir)/src/Makefile.global
79 echo "#define PGBINDIR \"$(bindir)\"" >$@
80 echo "#define PGSHAREDIR \"$(datadir)\"" >>$@
81 echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
82 echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
83 echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
84 echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
85 echo "#define LIBDIR \"$(libdir)\"" >>$@
86 echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
87 echo "#define LOCALEDIR \"$(localedir)\"" >>$@
89 clean distclean maintainer-clean:
90 rm -f libpgport.a libpgport_srv.a $(LIBOBJS) $(LIBOBJS_SRV) pg_config_paths.h