]> granicus.if.org Git - postgresql/blob - src/port/Makefile
Make psql reject attempts to set special variables to invalid values.
[postgresql] / src / port / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile
4 #    Makefile for the port-specific subsystem of the backend
5 #
6 # These files are used in other directories for portability on systems
7 # with broken/missing library files, and for common code sharing.
8 #
9 # This makefile generates two outputs:
10 #
11 #       libpgport.a - contains object files with FRONTEND defined,
12 #               for use by client application and libraries
13 #
14 #       libpgport_srv.a - contains object files without FRONTEND defined,
15 #               for use only by the backend binaries
16 #
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.
20 #
21 # IDENTIFICATION
22 #    src/port/Makefile
23 #
24 #-------------------------------------------------------------------------
25
26 subdir = src/port
27 top_builddir = ../..
28 include $(top_builddir)/src/Makefile.global
29
30 override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
31 LIBS += $(PTHREAD_LIBS)
32
33 OBJS = $(LIBOBJS) $(PG_CRC32C_OBJS) chklocale.o erand48.o inet_net_ntop.o \
34         noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o \
35         pgstrcasecmp.o pqsignal.o \
36         qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o
37
38 ifeq ($(enable_strong_random), yes)
39 OBJS += pg_strong_random.o
40 endif
41
42 # foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND
43 OBJS_SRV = $(OBJS:%.o=%_srv.o)
44
45 all: libpgport.a libpgport_srv.a
46
47 # libpgport is needed by some contrib
48 install: all installdirs
49         $(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(libdir)/libpgport.a'
50
51 installdirs:
52         $(MKDIR_P) '$(DESTDIR)$(libdir)'
53
54 uninstall:
55         rm -f '$(DESTDIR)$(libdir)/libpgport.a'
56
57 libpgport.a: $(OBJS)
58         rm -f $@
59         $(AR) $(AROPT) $@ $^
60
61 # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)
62 thread.o: CFLAGS+=$(PTHREAD_CFLAGS)
63
64 # pg_crc32c_sse42.o and its _srv.o version need CFLAGS_SSE42
65 pg_crc32c_sse42.o: CFLAGS+=$(CFLAGS_SSE42)
66 pg_crc32c_sse42_srv.o: CFLAGS+=$(CFLAGS_SSE42)
67
68 #
69 # Server versions of object files
70 #
71
72 libpgport_srv.a: $(OBJS_SRV)
73         rm -f $@
74         $(AR) $(AROPT) $@ $^
75
76 # Because this uses its own compilation rule, it doesn't use the
77 # dependency tracking logic from Makefile.global.  To make sure that
78 # dependency tracking works anyway for the *_srv.o files, depend on
79 # their *.o siblings as well, which do have proper dependencies.  It's
80 # a hack that might fail someday if there is a *_srv.o without a
81 # corresponding *.o, but it works for now (and those would probably go
82 # into src/backend/port/ anyway).
83 %_srv.o: %.c %.o
84         $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
85
86 $(OBJS_SRV): | submake-errcodes
87
88 .PHONY: submake-errcodes
89
90 submake-errcodes:
91         $(MAKE) -C ../backend submake-errcodes
92
93 # Dependency is to ensure that path changes propagate
94
95 path.o: path.c pg_config_paths.h
96
97 path_srv.o: path.c pg_config_paths.h
98
99 # We create a separate file rather than put these in pg_config.h
100 # because many of these values come from makefiles and are not
101 # available to configure.
102 pg_config_paths.h: $(top_builddir)/src/Makefile.global
103         echo "#define PGBINDIR \"$(bindir)\"" >$@
104         echo "#define PGSHAREDIR \"$(datadir)\"" >>$@
105         echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
106         echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
107         echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
108         echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
109         echo "#define LIBDIR \"$(libdir)\"" >>$@
110         echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
111         echo "#define LOCALEDIR \"$(localedir)\"" >>$@
112         echo "#define DOCDIR \"$(docdir)\"" >>$@
113         echo "#define HTMLDIR \"$(htmldir)\"" >>$@
114         echo "#define MANDIR \"$(mandir)\"" >>$@
115
116 clean distclean maintainer-clean:
117         rm -f libpgport.a libpgport_srv.a $(OBJS) $(OBJS_SRV) pg_config_paths.h