1# ----------
2# Makefile for src/slonik
3#
4#	Copyright (c) 2003-2009, PostgreSQL Global Development Group
5#	Author: Jan Wieck, Afilias USA INC.
6#
7# ----------
8
9slony_subdir = src/slonik
10slony_top_builddir = ../..
11SLFILEDESC="Slony command interpreter"
12include $(slony_top_builddir)/Makefile.global
13ifeq ($(HAVE_PGPORT),1)
14CPPFLAGS:=$(CPPFLAGS_SERVER) $(CPPFLAGS_CLIENT)
15else
16CPPFLAGS:=$(CPPFLAGS_CLIENT)
17endif
18ifeq ($(PORTNAME), aix)
19  CFLAGS += -D_LARGE_FILES
20endif
21
22CFLAGS += -I$(slony_top_builddir) -DPGSHARE="\"$(pgsharedir)\""
23
24PROG		= slonik
25
26ifeq ($(PORTNAME), win)
27PROG            = slonik.exe
28LDFLAGS += -lpgport
29endif
30ifeq ($(PORTNAME), win32)
31PROG            = slonik.exe
32LDFLAGS += -lpgport
33else ifdef HAVE_PGPORT
34LDFLAGS += -lpgport
35ifdef HAVE_PGCOMMON
36LDFLAGS += -lpgcommon
37endif
38endif
39
40OBJS		= 			\
41	slonik.o			\
42	dbutil.o			\
43	parser.o $(WIN32RES)            \
44	../parsestatements/scanner.o    \
45	scan.o
46DISTFILES = Makefile $(wildcard *.c) $(wildcard *.h) $(wildcard *.l) $(wildcard *.y)
47
48ALL =					\
49	$(PROG)
50
51
52all:	$(ALL)
53
54$(PROG):	$(OBJS)
55	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(PROG)
56slonik.o:			slonik.c slonik.h
57dbutil.o:			dbutil.c slonik.h
58parser.o:			parser.c scan.c
59
60parser.c:			parser.y slonik.h
61ifdef YACC
62	$(YACC) -d $(YFLAGS) $<
63	mv -f y.tab.c parser.c
64else
65	@echo "Missing yacc $< $@"
66	@exit 1
67endif
68
69scan.c: SCANNER_HEADER=scan.h
70
71scan.c:				scan.l slonik.h
72ifdef FLEX
73	$(FLEX) $(FLEXFLAGS) --header-file=$(SCANNER_HEADER) -o'$@' $<
74else
75	@echo "Missing flex $< $@"
76	@exit
77endif
78
79splint:
80	splint -I $(pgincludedir) -I $(pgincludeserverdir) +unixlib -preproc +skip-sys-headers $(wildcard *.c)
81
82clean distclean:
83	rm -f $(ALL) $(OBJS) $(PROG).core
84
85maintainer-clean:	clean
86	rm -f parser.c scan.c y.tab.h
87
88install: all installdirs
89	$(INSTALL_SCRIPT) $(PROG) $(DESTDIR)$(slonbindir)
90
91
92installdirs:
93	$(mkinstalldirs) $(DESTDIR)$(slonbindir)
94
95
96distdir: $(DISTFILES)
97	mkdir $(distdir)/$(subdir)
98	-chmod 777 $(distdir)/$(subdir)
99	for file in $(DISTFILES) ; do \
100      cp $$file $(distdir)/$(subdir)/$$file || exit; \
101    done
102