1 #-------------------------------------------------------------------------
4 # Makefile for src/common
6 # This makefile generates two outputs:
8 # libpgcommon.a - contains object files with FRONTEND defined,
9 # for use by client applications
11 # libpgcommon_srv.a - contains object files without FRONTEND defined,
12 # for use only by the backend binaries
14 # You can also symlink/copy individual source files from this directory,
15 # to compile with different options. (libpq does that, because it needs
16 # to use -fPIC on some platforms.)
21 #-------------------------------------------------------------------------
25 include $(top_builddir)/src/Makefile.global
27 override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
28 LIBS += $(PTHREAD_LIBS)
30 # don't include subdirectory-path-dependent -I and -L switches
31 STD_CPPFLAGS := $(filter-out -I$(top_srcdir)/src/include -I$(top_builddir)/src/include,$(CPPFLAGS))
32 STD_LDFLAGS := $(filter-out -L$(top_builddir)/src/port,$(LDFLAGS))
33 override CPPFLAGS += -DVAL_CONFIGURE="\"$(configure_args)\""
34 override CPPFLAGS += -DVAL_CC="\"$(CC)\""
35 override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
36 override CPPFLAGS += -DVAL_CFLAGS="\"$(CFLAGS)\""
37 override CPPFLAGS += -DVAL_CFLAGS_SL="\"$(CFLAGS_SL)\""
38 override CPPFLAGS += -DVAL_LDFLAGS="\"$(STD_LDFLAGS)\""
39 override CPPFLAGS += -DVAL_LDFLAGS_EX="\"$(LDFLAGS_EX)\""
40 override CPPFLAGS += -DVAL_LDFLAGS_SL="\"$(LDFLAGS_SL)\""
41 override CPPFLAGS += -DVAL_LIBS="\"$(LIBS)\""
43 OBJS_COMMON = config_info.o controldata_utils.o exec.o ip.o keywords.o \
44 md5.o pg_lzcompress.o pgfnames.o psprintf.o relpath.o rmtree.o \
45 string.o username.o wait_error.o
47 OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o file_utils.o restricted_token.o
49 OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o)
51 all: libpgcommon.a libpgcommon_srv.a
53 # libpgcommon is needed by some contrib
54 install: all installdirs
55 $(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
58 $(MKDIR_P) '$(DESTDIR)$(libdir)'
61 rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
63 libpgcommon.a: $(OBJS_FRONTEND)
68 # Server versions of object files
71 libpgcommon_srv.a: $(OBJS_SRV)
75 # Because this uses its own compilation rule, it doesn't use the
76 # dependency tracking logic from Makefile.global. To make sure that
77 # dependency tracking works anyway for the *_srv.o files, depend on
78 # their *.o siblings as well, which do have proper dependencies. It's
79 # a hack that might fail someday if there is a *_srv.o without a
80 # corresponding *.o, but it works for now.
82 $(CC) $(CFLAGS) $(subst -DFRONTEND ,, $(CPPFLAGS)) -c $< -o $@
84 $(OBJS_SRV): | submake-errcodes
86 .PHONY: submake-errcodes
89 $(MAKE) -C ../backend submake-errcodes
91 # Dependencies of keywords.o need to be managed explicitly to make sure
92 # that you don't get broken parsing code, even in a non-enable-depend build.
93 # Note that gram.h isn't required for the frontend version of keywords.o.
94 $(top_builddir)/src/include/parser/gram.h: $(top_srcdir)/src/backend/parser/gram.y
95 $(MAKE) -C $(top_builddir)/src/backend $(top_builddir)/src/include/parser/gram.h
97 keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
98 keywords_srv.o: $(top_builddir)/src/include/parser/gram.h $(top_srcdir)/src/include/parser/kwlist.h
100 clean distclean maintainer-clean:
101 rm -f libpgcommon.a libpgcommon_srv.a $(OBJS_FRONTEND) $(OBJS_SRV)