1# src/makefiles/Makefile.win32
2
3ifdef PGXS
4BE_DLLLIBS= -L$(libdir) -lpostgres
5override CPPFLAGS+= -I$(includedir_server)/port/win32
6else
7BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
8override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32"
9endif
10
11override CPPFLAGS += -DWIN32_STACK_RLIMIT=$(WIN32_STACK_RLIMIT)
12
13AROPT = crs
14DLSUFFIX = .dll
15
16ifneq (,$(findstring backend,$(subdir)))
17ifeq (,$(findstring conversion_procs,$(subdir)))
18ifeq (,$(findstring libpqwalreceiver,$(subdir)))
19ifeq (,$(findstring replication/pgoutput,$(subdir)))
20ifeq (,$(findstring snowball,$(subdir)))
21override CPPFLAGS+= -DBUILDING_DLL
22endif
23endif
24endif
25endif
26endif
27
28ifneq (,$(findstring src/common,$(subdir)))
29override CPPFLAGS+= -DBUILDING_DLL
30endif
31
32ifneq (,$(findstring src/port,$(subdir)))
33override CPPFLAGS+= -DBUILDING_DLL
34endif
35
36ifneq (,$(findstring timezone,$(subdir)))
37override CPPFLAGS+= -DBUILDING_DLL
38endif
39
40ifneq (,$(findstring ecpg/ecpglib,$(subdir)))
41override CPPFLAGS+= -DBUILDING_DLL
42endif
43
44# required by Python headers
45ifneq (,$(findstring src/pl/plpython,$(subdir)))
46override CPPFLAGS+= -DUSE_DL_IMPORT
47endif
48
49# it is better to install shared-libraries anyway?
50# may be overridden with make MAKE_DLL=false install
51ifndef MAKE_DLL
52MAKE_DLL	= true
53endif
54
55
56# Build rules to add versioninfo resources to win32 binaries
57
58WIN32RES += win32ver.o
59ifeq ($(PGFILESHLIB),1)
60PGFTYPE = VFT_DLL
61else
62PGFTYPE = VFT_APP
63endif
64ifneq (,$(PGAPPICON))
65PGICOSTR = $(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
66endif
67
68# We do not install src/port/win32ver.rc, its content being specific to
69# PostgreSQL Global Development Group software.  Any module can ship a
70# win32ver.rc or furnish a rule for generating one.  Set $(PGFILEDESC) to
71# signal win32ver.rc availability to the dll build rule below.
72ifndef PGXS
73win32ver.rc: $(top_srcdir)/src/port/win32ver.rc
74	sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0 *$$;\1,'`date '+%y%j' | sed 's/^0*//'`';' $< >$@
75endif
76
77win32ver.o: win32ver.rc
78	$(WINDRES) -i $< -o $@ --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir)
79
80# Rule for building a shared library from a single .o file
81%.dll: %.o $(if $(PGFILEDESC),$(WIN32RES))
82	$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $^ -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)
83