]> granicus.if.org Git - postgresql/blob - src/port/Makefile
Make pgbench use erand48() rather than random().
[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) chklocale.o dirmod.o erand48.o exec.o inet_net_ntop.o \
34         noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o pgstrcasecmp.o \
35         qsort.o qsort_arg.o sprompt.o thread.o
36
37 # foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND
38 OBJS_SRV = $(OBJS:%.o=%_srv.o)
39
40 all: libpgport.a libpgport_srv.a
41
42 # libpgport is needed by some contrib
43 install: all installdirs
44         $(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(libdir)/libpgport.a'
45
46 installdirs:
47         $(MKDIR_P) '$(DESTDIR)$(libdir)'
48
49 uninstall:
50         rm -f '$(DESTDIR)$(libdir)/libpgport.a'
51
52 libpgport.a: $(OBJS)
53         $(AR) $(AROPT) $@ $^
54
55 # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)
56 thread.o: thread.c
57         $(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<
58
59 #
60 # Server versions of object files
61 #
62
63 libpgport_srv.a: $(OBJS_SRV)
64         $(AR) $(AROPT) $@ $^
65
66 %_srv.o: %.c
67         $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
68
69 $(OBJS_SRV): | submake-errcodes
70
71 .PHONY: submake-errcodes
72
73 submake-errcodes:
74         $(MAKE) -C ../backend submake-errcodes
75
76 # Dependency is to ensure that path changes propagate
77
78 path.o: path.c pg_config_paths.h
79
80 path_srv.o: path.c pg_config_paths.h
81
82 # We create a separate file rather than put these in pg_config.h
83 # because many of these values come from makefiles and are not
84 # available to configure.
85 pg_config_paths.h: $(top_builddir)/src/Makefile.global
86         echo "#define PGBINDIR \"$(bindir)\"" >$@
87         echo "#define PGSHAREDIR \"$(datadir)\"" >>$@
88         echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
89         echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
90         echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
91         echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
92         echo "#define LIBDIR \"$(libdir)\"" >>$@
93         echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
94         echo "#define LOCALEDIR \"$(localedir)\"" >>$@
95         echo "#define DOCDIR \"$(docdir)\"" >>$@
96         echo "#define HTMLDIR \"$(htmldir)\"" >>$@
97         echo "#define MANDIR \"$(mandir)\"" >>$@
98
99 clean distclean maintainer-clean:
100         rm -f libpgport.a libpgport_srv.a $(OBJS) $(OBJS_SRV) pg_config_paths.h