aboutsummaryrefslogtreecommitdiffstats
path: root/src/build-data/makefile.in
blob: f24b4dbbfc586e713e737a8dfa5b273815cb0297 (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
# Paths to relevant programs

CXX            = %{cxx}
LINKER         = %{linker}
AR             = %{ar_command}
AR_OPTIONS     = %{ar_options}
PYTHON_EXE     = %{python_exe}

# Compiler Flags

ABI_FLAGS      = %{cc_sysroot} %{cxx_abi_flags}
LANG_FLAGS     = %{cc_lang_flags}
CXXFLAGS       = %{cc_compile_flags}
WARN_FLAGS     = %{cc_warning_flags}
LIB_FLAGS      = %{lib_flags}
LDFLAGS        = %{ldflags}

EXE_LINK_CMD   = %{exe_link_cmd}
POST_LINK_CMD  = %{post_link_cmd}

LIB_LINKS_TO   = %{link_to}
EXE_LINKS_TO   = %{link_to_botan} $(LIB_LINKS_TO)

BUILD_FLAGS    = $(ABI_FLAGS) $(LANG_FLAGS) $(CXXFLAGS) $(WARN_FLAGS)

SCRIPTS_DIR    = %{scripts_dir}
INSTALLED_LIB_DIR = %{prefix}/%{libdir}

# The primary target
all: libs cli tests docs

# Executable targets
CLI           = %{cli_exe}
TEST          = %{test_exe}
LIBRARIES     = %{library_targets}

cli: $(CLI)
tests: $(TEST)
libs: $(LIBRARIES)
docs: %{doc_stamp_file}

# Misc targets

%{if make_supports_phony}
.PHONY = all cli libs tests docs clean distclean install
%{endif}

%{doc_stamp_file}: %{doc_dir}/manual/*.rst
	$(PYTHON_EXE) $(SCRIPTS_DIR)/build_docs.py --build-dir="%{build_dir}"

clean:
	$(PYTHON_EXE) $(SCRIPTS_DIR)/cleanup.py --build-dir="%{build_dir}"

distclean:
	$(PYTHON_EXE) $(SCRIPTS_DIR)/cleanup.py --build-dir="%{build_dir}" --distclean

install: libs cli docs
	$(PYTHON_EXE) $(SCRIPTS_DIR)/install.py --prefix="%{prefix}" --build-dir="%{build_dir}" --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir}

# Object Files
LIBOBJS = %{join lib_objs}

CLIOBJS = %{join cli_objs}

TESTOBJS = %{join test_objs}

# Executable targets

$(CLI): $(LIBRARIES) $(CLIOBJS)
	$(EXE_LINK_CMD) $(ABI_FLAGS) $(LDFLAGS) $(CLIOBJS) $(EXE_LINKS_TO) %{output_to_exe}$@
	$(POST_LINK_CMD)

$(TEST): $(LIBRARIES) $(TESTOBJS)
	$(EXE_LINK_CMD) $(ABI_FLAGS) $(LDFLAGS) $(TESTOBJS) $(EXE_LINKS_TO) %{output_to_exe}$@
	$(POST_LINK_CMD)

%{if build_fuzzers}

FUZZERS = %{fuzzer_bin}

fuzzers: libs $(FUZZERS)

fuzzer_corpus:
	git clone --depth=1 https://github.com/randombit/crypto-corpus.git fuzzer_corpus

fuzzer_corpus_zip: fuzzer_corpus
	./src/scripts/create_corpus_zip.py fuzzer_corpus %{fuzzobj_dir}

%{endif}

# Library targets

%{if build_static_lib}

%{out_dir}/%{static_lib_name}: $(LIBOBJS)
	$(AR) $(AR_OPTIONS) %{ar_output_to}$@ $(LIBOBJS)

%{endif}

%{if build_shared_lib}

%{out_dir}/%{shared_lib_name}: $(LIBOBJS)
	%{lib_link_cmd} $(ABI_FLAGS) $(LDFLAGS) $(LIBOBJS) $(LIB_LINKS_TO) %{output_to_exe}$@
%{endif}
%{if symlink_shared_lib}
	cd %{out_dir} && ln -fs %{shared_lib_name} %{soname_base}
	cd %{out_dir} && ln -fs %{shared_lib_name} %{soname_patch}
%{endif}

# Build Commands

%{for lib_build_info}
%{obj}: %{src}
	$(CXX) $(LIB_FLAGS) $(BUILD_FLAGS) %{isa_flags} %{include_paths} %{dash_c} %{src} %{dash_o}$@
%{endfor}

%{for cli_build_info}
%{obj}: %{src}
	$(CXX) $(BUILD_FLAGS) %{isa_flags} %{include_paths} %{dash_c} %{src} %{dash_o}$@
%{endfor}

%{for test_build_info}
%{obj}: %{src}
	$(CXX) $(BUILD_FLAGS) %{isa_flags} %{include_paths} %{dash_c} %{src} %{dash_o}$@
%{endfor}

%{for fuzzer_build_info}
%{obj}: %{src}
	$(CXX) $(BUILD_FLAGS) %{isa_flags} %{include_paths} %{dash_c} %{src} %{dash_o}$@

%{exe}: %{obj} $(LIBRARIES)
	$(EXE_LINK_CMD) $(ABI_FLAGS) %{obj} $(EXE_LINKS_TO) %{fuzzer_lib} %{output_to_exe}$@
%{endfor}