1#-------------------------------------------------------------------------
2#
3# Makefile for ecpg library
4#
5# Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
6# Portions Copyright (c) 1994, Regents of the University of California
7#
8# src/interfaces/ecpg/ecpglib/Makefile
9#
10#-------------------------------------------------------------------------
11
12subdir = src/interfaces/ecpg/ecpglib
13top_builddir = ../../../..
14include $(top_builddir)/src/Makefile.global
15
16PGFILEDESC = "ECPG - embedded SQL in C"
17NAME= ecpg
18SO_MAJOR_VERSION= 6
19SO_MINOR_VERSION= $(MAJORVERSION)
20
21override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
22	-I$(libpq_srcdir) -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
23override CFLAGS += $(PTHREAD_CFLAGS)
24
25# Need to recompile any libpgport object files
26LIBS := $(filter-out -lpgport, $(LIBS))
27
28OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
29	connect.o misc.o path.o pgstrcasecmp.o \
30	$(filter snprintf.o strlcpy.o win32setlocale.o isinf.o, $(LIBOBJS)) $(WIN32RES)
31
32# thread.c is needed only for non-WIN32 implementation of path.c
33ifneq ($(PORTNAME), win32)
34OBJS += thread.o
35endif
36
37SHLIB_LINK_INTERNAL = -L../pgtypeslib -lpgtypes $(libpq)
38SHLIB_LINK = $(filter -lintl -lm, $(LIBS)) $(PTHREAD_LIBS)
39SHLIB_PREREQS = submake-libpq submake-pgtypeslib
40
41SHLIB_EXPORTS = exports.txt
42
43PKG_CONFIG_REQUIRES_PRIVATE = libpq libpgtypes
44
45all: all-lib
46
47.PHONY: submake-pgtypeslib
48submake-pgtypeslib:
49	$(MAKE) -C $(top_builddir)/src/interfaces/ecpg/pgtypeslib all
50
51# Shared library stuff
52include $(top_srcdir)/src/Makefile.shlib
53
54# We use some port modules verbatim, but since we need to
55# compile with appropriate options to build a shared lib, we can't
56# necessarily use the same object files as the backend uses. Instead,
57# symlink the source files in here and build our own object file.
58
59path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c win32setlocale.c isinf.c: % : $(top_srcdir)/src/port/%
60	rm -f $@ && $(LN_S) $< .
61
62misc.o: misc.c $(top_builddir)/src/port/pg_config_paths.h
63path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
64
65$(top_builddir)/src/port/pg_config_paths.h:
66	$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
67
68install: all installdirs install-lib
69
70installdirs: installdirs-lib
71
72uninstall: uninstall-lib
73
74clean distclean: clean-lib
75	rm -f $(OBJS)
76	rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c win32setlocale.c isinf.c
77
78maintainer-clean: distclean maintainer-clean-lib
79