]> granicus.if.org Git - postgresql/blob - src/interfaces/ecpg/ecpglib/Makefile
Fix distprep and maintainer-clean targets so that ecpg's .def files are
[postgresql] / src / interfaces / ecpg / ecpglib / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for ecpg library
4 #
5 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.53 2007/10/05 01:51:40 tgl Exp $
9 #
10 #-------------------------------------------------------------------------
11
12 subdir = src/interfaces/ecpg/ecpglib
13 top_builddir = ../../../..
14 include $(top_builddir)/src/Makefile.global
15
16 NAME= ecpg
17 SO_MAJOR_VERSION= 6
18 SO_MINOR_VERSION= 0
19 DLTYPE= library
20
21 override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
22         -I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
23 override CFLAGS += $(PTHREAD_CFLAGS)
24
25 # Need to recompile any libpgport object files
26 LIBS := $(filter-out -lpgport, $(LIBS))
27
28 OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
29         connect.o misc.o path.o pgstrcasecmp.o \
30         $(filter snprintf.o strlcpy.o, $(LIBOBJS))
31
32 # thread.c is needed only for non-WIN32 implementation of path.c
33 ifneq ($(PORTNAME), win32)
34 OBJS += thread.o
35 endif
36
37 SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) -lm $(PTHREAD_LIBS)
38
39 ifeq ($(PORTNAME), win32)
40 # Link to shfolder.dll instead of shell32.dll
41 SHLIB_LINK += -lshfolder
42 DLL_DEFFILE=libecpgdll.def
43 endif
44
45 all: def-files all-lib
46
47 # Shared library stuff
48 include $(top_srcdir)/src/Makefile.shlib
49
50 # We use some port modules verbatim, but since we need to
51 # compile with appropriate options to build a shared lib, we can't
52 # necessarily use the same object files as the backend uses. Instead,
53 # symlink the source files in here and build our own object file.
54
55 path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c: % : $(top_srcdir)/src/port/%
56         rm -f $@ && $(LN_S) $< .
57
58 path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
59
60 $(top_builddir)/src/port/pg_config_paths.h:
61         $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
62
63 # We need several not-quite-identical variants of .DEF files to build libecpg
64 # DLLs for Windows.  These are made from the single source file exports.txt.
65 # Since we can't assume that Windows boxes will have sed, the .DEF files are
66 # always built and included in distribution tarballs.
67
68 distprep: def-files
69
70 .PHONY: def-files
71
72 def-files: $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def
73
74 $(srcdir)/libecpgdll.def: exports.txt
75         echo '; DEF file for MS VC++' > $@
76         echo 'LIBRARY LIBECPG' >> $@
77         echo 'EXPORTS' >> $@
78         sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1@ \2/' < $< >> $@
79
80 $(srcdir)/blibecpgdll.def: exports.txt
81         echo '; DEF file for Borland C++ Builder' > $@
82         echo 'LIBRARY BLIBECPG' >> $@
83         echo 'EXPORTS' >> $@
84         sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    _\1@ \2/' < $< >> $@
85         echo '' >> $@
86         echo '; Aliases for MS compatible names' >> $@
87         sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/    \1= _\1/' < $< | sed 's/ *$$//' >> $@
88
89 # Where possible, restrict the symbols exported by the library to just the
90 # official list, so as to avoid unintentional ABI changes.
91
92 ifeq ($(PORTNAME), darwin)
93 $(shlib): exports.list
94
95 exports.list: exports.txt
96         $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
97
98 exported_symbols_list = -exported_symbols_list exports.list
99 endif
100
101 ifeq ($(PORTNAME), linux)
102 $(shlib): exports.list
103
104 exports.list: exports.txt
105         echo '{ global:' >$@
106         $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
107         echo ' local: *; };' >>$@
108
109 exported_symbols_list = -Wl,--version-script=exports.list
110 endif
111
112 install: all installdirs install-lib
113
114 installdirs:
115         $(mkinstalldirs) '$(DESTDIR)$(libdir)'
116
117 uninstall: uninstall-lib
118
119 clean distclean: clean-lib
120         rm -f $(OBJS)
121         rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c exports.list
122
123 maintainer-clean: distclean
124         rm -f $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def