]> granicus.if.org Git - postgresql/blob - src/common/Makefile
Move fsync routines of initdb into src/common/
[postgresql] / src / common / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile
4 #    Makefile for src/common
5 #
6 # This makefile generates two outputs:
7 #
8 #       libpgcommon.a - contains object files with FRONTEND defined,
9 #               for use by client applications
10 #
11 #       libpgcommon_srv.a - contains object files without FRONTEND defined,
12 #               for use only by the backend binaries
13 #
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.)
17 #
18 # IDENTIFICATION
19 #    src/common/Makefile
20 #
21 #-------------------------------------------------------------------------
22
23 subdir = src/common
24 top_builddir = ../..
25 include $(top_builddir)/src/Makefile.global
26
27 override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
28 LIBS += $(PTHREAD_LIBS)
29
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)\""
42
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
46
47 OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o file_utils.o restricted_token.o
48
49 OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o)
50
51 all: libpgcommon.a libpgcommon_srv.a
52
53 # libpgcommon is needed by some contrib
54 install: all installdirs
55         $(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
56
57 installdirs:
58         $(MKDIR_P) '$(DESTDIR)$(libdir)'
59
60 uninstall:
61         rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
62
63 libpgcommon.a: $(OBJS_FRONTEND)
64         rm -f $@
65         $(AR) $(AROPT) $@ $^
66
67 #
68 # Server versions of object files
69 #
70
71 libpgcommon_srv.a: $(OBJS_SRV)
72         rm -f $@
73         $(AR) $(AROPT) $@ $^
74
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.
81 %_srv.o: %.c %.o
82         $(CC) $(CFLAGS) $(subst -DFRONTEND ,, $(CPPFLAGS)) -c $< -o $@
83
84 $(OBJS_SRV): | submake-errcodes
85
86 .PHONY: submake-errcodes
87
88 submake-errcodes:
89         $(MAKE) -C ../backend submake-errcodes
90
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
96
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
99
100 clean distclean maintainer-clean:
101         rm -f libpgcommon.a libpgcommon_srv.a $(OBJS_FRONTEND) $(OBJS_SRV)