1 #-------------------------------------------------------------------------
3 # Makefile for ecpg library
5 # Copyright (c) 1994, Regents of the University of California
7 # $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.52 2007/10/04 20:54:08 tgl Exp $
9 #-------------------------------------------------------------------------
11 subdir = src/interfaces/ecpg/ecpglib
12 top_builddir = ../../../..
13 include $(top_builddir)/src/Makefile.global
20 override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
21 -I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
22 override CFLAGS += $(PTHREAD_CFLAGS)
24 # Need to recompile any libpgport object files
25 LIBS := $(filter-out -lpgport, $(LIBS))
27 OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
28 connect.o misc.o path.o pgstrcasecmp.o \
29 $(filter snprintf.o strlcpy.o, $(LIBOBJS))
31 # thread.c is needed only for non-WIN32 implementation of path.c
32 ifneq ($(PORTNAME), win32)
36 SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) -lm $(PTHREAD_LIBS)
38 ifeq ($(PORTNAME), win32)
39 # Link to shfolder.dll instead of shell32.dll
40 SHLIB_LINK += -lshfolder
41 DLL_DEFFILE=libecpgdll.def
44 all: def-files all-lib
46 # Shared library stuff
47 include $(top_srcdir)/src/Makefile.shlib
49 # We use some port modules verbatim, but since we need to
50 # compile with appropriate options to build a shared lib, we can't
51 # necessarily use the same object files as the backend uses. Instead,
52 # symlink the source files in here and build our own object file.
54 path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c: % : $(top_srcdir)/src/port/%
55 rm -f $@ && $(LN_S) $< .
57 path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
59 $(top_builddir)/src/port/pg_config_paths.h:
60 $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
62 # We need several not-quite-identical variants of .DEF files to build libecpg
63 # DLLs for Windows. These are made from the single source file exports.txt.
64 # Since we can't assume that Windows boxes will have sed, the .DEF files are
65 # always built and included in distribution tarballs.
68 def-files: $(srcdir)/libecpgdll.def $(srcdir)/blibecpgdll.def
70 $(srcdir)/libecpgdll.def: exports.txt
71 echo '; DEF file for MS VC++' > $@
72 echo 'LIBRARY LIBECPG' >> $@
74 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' < $< >> $@
76 $(srcdir)/blibecpgdll.def: exports.txt
77 echo '; DEF file for Borland C++ Builder' > $@
78 echo 'LIBRARY BLIBECPG' >> $@
80 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/' < $< >> $@
82 echo '; Aliases for MS compatible names' >> $@
83 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' < $< | sed 's/ *$$//' >> $@
85 # Where possible, restrict the symbols exported by the library to just the
86 # official list, so as to avoid unintentional ABI changes.
88 ifeq ($(PORTNAME), darwin)
89 $(shlib): exports.list
91 exports.list: exports.txt
92 $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
94 exported_symbols_list = -exported_symbols_list exports.list
97 ifeq ($(PORTNAME), linux)
98 $(shlib): exports.list
100 exports.list: exports.txt
102 $(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
103 echo ' local: *; };' >>$@
105 exported_symbols_list = -Wl,--version-script=exports.list
108 install: all installdirs install-lib
111 $(mkinstalldirs) '$(DESTDIR)$(libdir)'
113 uninstall: uninstall-lib
115 clean distclean maintainer-clean: clean-lib
117 rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c exports.list