summaryrefslogtreecommitdiff
path: root/odb/makefile
blob: 742b3a57ff50decf0a3b11ac23b881383fe25573 (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
131
132
133
134
135
# file      : odb/makefile
# author    : Boris Kolpackov <boris@codesynthesis.com>
# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
# license   : GNU GPL v2; see accompanying LICENSE file

include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make

# Plugin units.
#
cxx_ptun := plugin.cxx

cxx_ptun +=                  \
semantics/class.cxx          \
semantics/class-template.cxx \
semantics/derived.cxx        \
semantics/elements.cxx       \
semantics/enum.cxx           \
semantics/fundamental.cxx    \
semantics/namespace.cxx      \
semantics/template.cxx       \
semantics/union.cxx          \
semantics/union-template.cxx \
semantics/unit.cxx

cxx_ptun +=                  \
traversal/class.cxx          \
traversal/class-template.cxx \
traversal/derived.cxx        \
traversal/elements.cxx       \
traversal/enum.cxx           \
traversal/template.cxx       \
traversal/union-template.cxx


# Driver units.
#
cxx_dtun := odb.cxx

# Options file.
#
cli_tun := options.cli

#
#
cxx_pobj  := $(addprefix $(out_base)/,$(cxx_ptun:.cxx=.o) $(cli_tun:.cli=.o))
cxx_dobj  := $(addprefix $(out_base)/,$(cxx_dtun:.cxx=.o) $(cli_tun:.cli=.o))
cxx_pod   := $(cxx_pobj:.o=.o.d)
cxx_dod   := $(cxx_dobj:.o=.o.d)

odb      := $(out_base)/odb
odb_so   := $(out_base)/odb.so
clean    := $(out_base)/.clean
install  := $(out_base)/.install

# Import.
#
$(call import,\
  $(scf_root)/import/cli/stub.make,\
  cli: cli,cli-rules: cli_rules)

$(call import,\
  $(scf_root)/import/libcutl/stub.make,\
  l: cutl.l,cpp-options: cutl.l.cpp-options)

# Build.
#
$(odb): $(cxx_dobj) $(cutl.l) | $(odb_so)
$(odb_so): $(cxx_pobj) $(cutl.l)

$(cxx_dobj) $(cxx_dod): cpp_options := -I$(src_base)
$(cxx_pobj) $(cxx_dobj) $(cxx_pod) $(cxx_dod): $(cutl.l.cpp-options)

genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx)
gen  := $(addprefix $(out_base)/,$(genf))

$(gen): cli := $(cli)
$(gen): cli_options := --generate-file-scanner --guard-prefix ODB

$(call include-dep,$(cxx_pod))
$(call include-dep,$(cxx_dod))

# Alias for default target.
#
$(out_base)/: $(odb)

# Install.
#
$(install): $(odb)
	$(call install-exec,$<,$(install_bin_dir)/odb)
	$(call install-exec,$<.so,$(install_bin_dir)/odb.so)

# Clean.
#
$(clean):                             \
  $(odb).o.clean                      \
  $(addsuffix .cxx.clean,$(cxx_pobj)) \
  $(addsuffix .cxx.clean,$(cxx_dobj)) \
  $(addsuffix .cxx.clean,$(cxx_pod))  \
  $(addsuffix .cxx.clean,$(cxx_dod))
	$(call message,rm $$1,rm -f $$1,$(out_base)/odb.so)

# Generated .gitignore.
#
ifeq ($(out_base),$(src_base))
$(odb): | $(out_base)/.gitignore

$(out_base)/.gitignore: files := odb odb.so
$(clean): $(out_base)/.gitignore.clean

$(call include,$(bld_root)/git/gitignore.make)
endif

# Rules.
#
$(call include,$(bld_root)/install.make)
$(call include,$(cli_rules))
$(call include,$(bld_root)/cxx/cxx-d.make)
$(call include,$(bld_root)/cxx/cxx-o.make)
$(call include,$(bld_root)/cxx/o-e.make)

# Custom rules for the plugin.
#
ifdef cxx_gnu

$(cxx_pobj): cxx_pic_options := -fPIC

$(cxx_pobj) $(cxx_pod): cpp_options := -I$(src_base) \
-I$(shell $(cxx_gnu) -print-file-name=plugin)/include

$(odb_so):
	$(call message,ld $@,$(ld) \
$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) -shared -o $@ \
$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs))

endif