1#-------------------------------------------------------------------------
2#
3# Makefile for ecpg library
4#
5# Portions Copyright (c) 1996-2018, 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 strnlen.o win32setlocale.o isinf.o, $(LIBOBJS)) \
31	$(WIN32RES)
32
33# thread.c is needed only for non-WIN32 implementation of path.c
34ifneq ($(PORTNAME), win32)
35OBJS += thread.o
36endif
37
38SHLIB_LINK_INTERNAL = -L../pgtypeslib -lpgtypes $(libpq)
39SHLIB_LINK = $(filter -lintl -lm, $(LIBS)) $(PTHREAD_LIBS)
40SHLIB_PREREQS = submake-libpq submake-pgtypeslib
41
42SHLIB_EXPORTS = exports.txt
43
44PKG_CONFIG_REQUIRES_PRIVATE = libpq libpgtypes
45
46all: all-lib
47
48.PHONY: submake-pgtypeslib
49submake-pgtypeslib:
50	$(MAKE) -C $(top_builddir)/src/interfaces/ecpg/pgtypeslib all
51
52# Shared library stuff
53include $(top_srcdir)/src/Makefile.shlib
54
55# We use some port modules verbatim, but since we need to
56# compile with appropriate options to build a shared lib, we can't
57# necessarily use the same object files as the backend uses. Instead,
58# symlink the source files in here and build our own object file.
59
60path.c pgstrcasecmp.c snprintf.c strlcpy.c strnlen.c thread.c win32setlocale.c isinf.c: % : $(top_srcdir)/src/port/%
61	rm -f $@ && $(LN_S) $< .
62
63misc.o: misc.c $(top_builddir)/src/port/pg_config_paths.h
64path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
65
66$(top_builddir)/src/port/pg_config_paths.h:
67	$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
68
69install: all installdirs install-lib
70
71installdirs: installdirs-lib
72
73uninstall: uninstall-lib
74
75clean distclean: clean-lib
76	rm -f $(OBJS)
77	rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c strnlen.c thread.c win32setlocale.c isinf.c
78
79maintainer-clean: distclean maintainer-clean-lib
80