1 #-------------------------------------------------------------------------
3 # Makefile for ecpg library
5 # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.53 2007/10/05 01:51:40 tgl Exp $
10 #-------------------------------------------------------------------------
12 subdir = src/interfaces/ecpg/ecpglib
13 top_builddir = ../../../..
14 include $(top_builddir)/src/Makefile.global
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)
25 # Need to recompile any libpgport object files
26 LIBS := $(filter-out -lpgport, $(LIBS))
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))
32 # thread.c is needed only for non-WIN32 implementation of path.c
33 ifneq ($(PORTNAME), win32)
37 SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) -lm $(PTHREAD_LIBS)
39 ifeq ($(PORTNAME), win32)
40 # Link to shfolder.dll instead of shell32.dll
41 SHLIB_LINK += -lshfolder
42 DLL_DEFFILE=libecpgdll.def
45 all: def-files all-lib
47 # Shared library stuff
48 include $(top_srcdir)/src/Makefile.shlib
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.
55 path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c: % : $(top_srcdir)/src/port/%
56 rm -f $@ && $(LN_S) $< .
58 path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
60 $(top_builddir)/src/port/pg_config_paths.h:
61 $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
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.
72 def-files: $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def
74 $(srcdir)/libecpgdll.def: exports.txt
75 echo '; DEF file for MS VC++' > $@
76 echo 'LIBRARY LIBECPG' >> $@
78 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' < $< >> $@
80 $(srcdir)/blibecpgdll.def: exports.txt
81 echo '; DEF file for Borland C++ Builder' > $@
82 echo 'LIBRARY BLIBECPG' >> $@
84 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/' < $< >> $@
86 echo '; Aliases for MS compatible names' >> $@
87 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' < $< | sed 's/ *$$//' >> $@
89 # Where possible, restrict the symbols exported by the library to just the
90 # official list, so as to avoid unintentional ABI changes.
92 ifeq ($(PORTNAME), darwin)
93 $(shlib): exports.list
95 exports.list: exports.txt
96 $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
98 exported_symbols_list = -exported_symbols_list exports.list
101 ifeq ($(PORTNAME), linux)
102 $(shlib): exports.list
104 exports.list: exports.txt
106 $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
107 echo ' local: *; };' >>$@
109 exported_symbols_list = -Wl,--version-script=exports.list
112 install: all installdirs install-lib
115 $(mkinstalldirs) '$(DESTDIR)$(libdir)'
117 uninstall: uninstall-lib
119 clean distclean: clean-lib
121 rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c exports.list
123 maintainer-clean: distclean
124 rm -f $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def