summaryrefslogtreecommitdiff
path: root/libcult/cult/makefile
blob: e4ce5ea2f31cbbb488e9289792c86f714f665041 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# file      : cult/makefile
# author    : Boris Kolpackov <boris@kolpackov.net>
# copyright : Copyright (c) 2005-2010 Boris Kolpackov
# license   : GNU GPL v2; see accompanying LICENSE file

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

$(call include,$(bld_root)/system.make)
$(call include,$(scf_root)/configuration.make)

cxx_tun   := eh/exception.cxx

cxx_tun   += mm/new.cxx        \
             mm/counter.cxx    \
             mm/buffer.cxx

cxx_tun   += rtti/type-info.cxx

cxx_tun   += trace/log.cxx

cxx_tun   += cli/arguments.cxx       \
	     cli/file-arguments.cxx  \
             cli/scanner.cxx         \
             cli/options.cxx         \
             cli/options-parser.cxx  \
             cli/options-spec.cxx

ifeq ($(cult_threads),y)
cxx_tun   += sched/condition.cxx \
             sched/mutex.cxx     \
             sched/spin.cxx      \
             sched/thread.cxx
endif


ifeq ($(cult_network),y)
cxx_tun   += os/net/address.cxx                \
             os/net/socket.cxx                 \
             os/net/datagram-socket.cxx        \
             os/net/multicast-socket.cxx       \
             os/net/ipv4/address.cxx           \
             os/net/ipv4/datagram-socket.cxx   \
             os/net/ipv4/multicast-socket.cxx
endif


ifeq ($(cult_dr),y)
cxx_tun   += dr/xdr/input-stream.cxx  \
             dr/xdr/output-stream.cxx
endif


cxx_o   := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
cxx_d   := $(cxx_o:.o=.o.d)

cult.l             := $(out_base)/cult.l
cult.l.cpp-options := $(out_base)/cult.l.cpp-options

clean     := $(out_base)/.clean


# Architectures.
#
#
#@@ arch can collide if src_root == out_root
#

# List of known architectures.
#
architectures := i386                        \
                 i386/i486                   \
                 i386/i486/i586              \
                 i386/i486/i586/i686         \
                 i386/i486/i586/i686/x86_64

# Directories with architecture-specific code.
#
arch_dirs := mm
arch := $(filter %$(host_cpu),$(architectures))

r :=
r := generic $(foreach a,$(subst /, ,$(arch)),$(eval r := $(if $r,$r/)$a)$r)

sub_archs :=
$(foreach a,$r,$(eval sub_archs := $a $(sub_archs)))

#$(warning $(sub_archs))

# $1 - sub-architecture dir (e.g. i386/i486)
#
define arch-rule

arch_targets += $(foreach d,$(arch_dirs),$(out_base)/arch/$1/cult/$d/arch)

$(out_base)/arch/$1/cult/%/arch: $(src_base)/%/arch/$1 | $(out_base)/arch/$1/cult/%/.
	$(call message,using $1,ln -s $$$$< $$$$@)
endef

arch_targets :=
$(foreach a,$(sub_archs),$(eval $(call arch-rule,$a)))


# Build.
#
$(cult.l): $(cxx_o)

ifeq ($(cult_threads),y)
$(cult.l): -lpthread
endif

$(cxx_o) $(cxx_d): $(cult.l.cpp-options)

$(cult.l.cpp-options): prefix := cult/ $(out_root)/
$(cult.l.cpp-options): value := $(addprefix -I$(out_base)/arch/,$(sub_archs))\
                                -I$(out_root)\
                                -I$(src_root)

$(cult.l.cpp-options): | $(arch_targets)

$(call include-dep,$(cxx_d))


# config.hxx
#
ifdef cult_dr
$(out_base)/config.hxx: cult_threads := $(cult_threads)
$(out_base)/config.hxx:
	@echo '// file      : cult/config.hxx'                            >$@
	@echo '// author    : automatically generated'                   >>$@
	@echo '// copyright : Copyright (c) 2006-2010 Boris Kolpackov'   >>$@
	@echo '// license   : GNU GPL v2; see accompanying LICENSE file' >>$@
	@echo '#ifndef CULT_CONFIG_HXX'                                  >>$@
	@echo '#define CULT_CONFIG_HXX'                                  >>$@
ifeq ($(cult_threads),y)
	@echo '#define CULT_THREADS'                                     >>$@
endif
	@echo '#endif // CULT_CONFIG_HXX'                                >>$@
endif

# Convenience alias for default target.
#
$(out_base)/: $(cult.l)


# Clean.
#
$(clean): $(cult.l).o.clean            \
  $(cult.l.cpp-options).clean          \
  $(out_base)/cli/mapper.hxx.m4.clean  \
  $(addsuffix .cxx.clean,$(cxx_o))     \
  $(addsuffix .cxx.clean,$(cxx_d))
	$(call message,rm $$1,rm -f -r $$1,$(out_base)/arch)
	$(call message,rm $$1,rm -f $$1,$(out_base)/config.hxx)

# How to.
#
$(call include,$(bld_root)/cxx/o-l.make)
$(call include,$(bld_root)/cxx/cxx-o.make)
$(call include,$(bld_root)/cxx/cxx-d.make)
$(call include,$(bld_root)/m4/m4.make)