summaryrefslogtreecommitdiff
path: root/GNUmakefile
blob: bbb5d1acf7097b9966528eae34fac526ffcf2a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# GNUmakefile
#
#      PGXS-based makefile for Veil
#
#      Copyright (c) 2005 - 2015 Marc Munro
#      Author:  Marc Munro
#      License: BSD
#
# For a list of targets use make help.
# 

# Default target.  Dependencies for this are further defined in the 
# included makefiles for SUBDIRS below.
all:

BUILD_DIR = $(shell pwd)
MODULE_big = veil
OBJS = $(SOURCES:%.c=%.o)
DEPS = $(SOURCES:%.c=%.d)
EXTENSION=veil
MODULEDIR=extension
VEIL_VERSION = $(shell \
    grep default_version veil.control | sed 's/[^0-9.]*\([0-9.]*\).*/\1/')

VEIL_CONTROL = veil--$(VEIL_VERSION).sql
VEIL_DEMO_CONTROL = veil_demo--$(VEIL_VERSION).sql

SUBDIRS = src regress docs demo
EXTRA_CLEAN = $(SRC_CLEAN) $(VEIL_CONTROL) $(VEIL_DEMO_CONTROL)
include $(SUBDIRS:%=%/Makefile)


DATA = $(wildcard veil--*.sql)
ALLDOCS = $(wildcard docs/html/*)
# Only define DOCS (for the install target) if there are some.
ifneq "$(ALLDOCS)" ""
       DOCS = $(ALLDOCS)
endif

PG_CONFIG := $(shell ./find_pg_config)
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

ifneq ($(origin FORCE_32_BIT), undefined)
DFORCE_32_BIT = -DFORCE_32_BIT=1
endif

override CFLAGS := $(CFLAGS) -O0 $(DFORCE_32_BIT)

include $(DEPS)

# Build per-source dependency files for inclusion
# This ignores header files and any other non-local files (such as
# postgres include files).  Since I don't know if this will work
# on non-Unix platforms, we will ship veil with the dep files
# in place).  This target is mostly for maintainers who may wish
# to rebuild dep files.
%.d: %.c
	@echo Recreating $@
	@$(SHELL) -ec "$(CC) -MM -MT $*.o $(CPPFLAGS) $< | \
		xargs -n 1 | grep '^[^/]' | \
		sed -e '1,$$ s/$$/ \\\\/' -e '$$ s/ \\\\$$//' \
		    -e '2,$$ s/^/  /' | \
		sed 's!$*.o!& $@!g'" > $@

# Target used by recursive call from deps target below.  This ensures
# that make deps always rebuilds the dep files even if they are up to date.
make_deps: $(DEPS)

# Target that rebuilds all dep files unconditionally.  There should be a
# simpler way to do this using .PHONY but I can't figure out how.
deps: 
	rm -f $(DEPS)
	$(MAKE) MAKEFLAGS="$(MAKEFLAGS)" make_deps

# Define some variables for the following tarball targets.
VEIL_DIR=veil_$(VEIL_VERSION)

# Create a version numbered tarball of source (including deps), tools, 
# and possibly docs.
tarball:
	@rm -rf $(VEIL_DIR)
	@if test ! -r docs/html/index.html; then \
	    echo "You may want to make the docs first"; fi
	@mkdir -p $(VEIL_DIR)/src $(VEIL_DIR)/regress
	@cp CO* LI* GNU* veil.control veil_demo* $(VEIL_DIR)
	@cp src/*akefile src/*.[cdh] src/*sqs $(VEIL_DIR)/src
	@cp regress/*akefile regress/*.sh regress/*sql $(VEIL_DIR)/regress
	@ln -s `pwd`/tools $(VEIL_DIR)/tools
	@ln -s `pwd`/demo $(VEIL_DIR)/demo
	@ln -s `pwd`/docs $(VEIL_DIR)/docs
	@echo Creating veil_$(VEIL_VERSION).tgz...
	@tar czhf veil_$(VEIL_VERSION).tgz $(VEIL_DIR)
	@rm -rf $(VEIL_DIR)

# Ensure that tarball tmp files and dirs are removed by the clean target
EXTRA_CLEAN = $(VEIL_DIR) regress.log $(DEPS) \
	      PG_VERSION veil--*sql veil_demo--*sql \
	      veil_$(VEIL_VERSION).tgz

# Install veil_demo as well as veil
install: demo_install
demo_install:
	$(MAKE) MAKEFLAGS=$(MAKEFLAGS) -f veil_demo.mk install

# Uninstall veil_demo as well as veil
uninstall: demo_uninstall
demo_uninstall:
	$(MAKE) MAKEFLAGS=$(MAKEFLAGS) -f veil_demo.mk uninstall

clean: docs_clean demo_clean

# Provide a list of the targets buildable by this makefile.
list help:
	@echo -e "\n\
 Major targets for this makefile are:\n\n\
 all       - Build veil libraries, without docs\n\
 check     - Build veil and run regression tests\n\
 clean     - remove target and object files\n\
 deps      - Recreate the xxx.d dependency files\n\
 docs      - Build veil html docs (requires doxygen and dot)\n\
 help      - show this list of major targets\n\
 install   - Install veil\n\
 list      - show this list of major targets\n\
 regress   - same as check\n\
 regress_clean - clean up after regression tests - (drop regressdb)\n\
 tarball   - create a tarball of the sources and documents\n\
 uninstall - Undo the install\n\
\n\
"