aboutsummaryrefslogtreecommitdiffstats
path: root/src/build-data/makefile/unix_shr.in
blob: 5b1522f705845abce2dea00bfb5df08e062ec909 (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
##################################################
# Compiler Options                               #
##################################################
CXX           = @{var:cc}
LIB_OPT       = @{var:lib_opt}
CHECK_OPT     = @{var:check_opt}
MACH_OPT      = @{var:mach_opt}
LANG_FLAGS    = @{var:lang_flags}
WARN_FLAGS    = @{var:warn_flags}
SO_OBJ_FLAGS  = @{var:shared_flags}
SO_LINK_CMD   = @{var:so_link}
LINK_TO       = @{var:link_to}

##################################################
# Version Numbers                                #
##################################################
VERSION       = @{var:version}
SO_VERSION    = @{var:so_version}

##################################################
# Installation Settings                          #
##################################################
DESTDIR       = @{var:prefix}

BINDIR        = $(DESTDIR)/bin
LIBDIR        = $(DESTDIR)/@{var:libdir}
HEADERDIR     = $(DESTDIR)/@{var:includedir}/botan
DOCDIR        = $(DESTDIR)/@{var:docdir}/Botan-$(VERSION)
PKGCONF_DIR   = $(LIBDIR)/pkgconfig

CONFIG_SCRIPT = @{var:botan-config}
PKGCONFIG     = @{var:botan-pkgconfig}

##################################################
# Aliases for Common Programs                    #
##################################################
AR               = @{var:ar_command}
CD               = @cd
ECHO             = @echo
INSTALL_CMD_EXEC = @{var:install_cmd_exec}
INSTALL_CMD_DATA = @{var:install_cmd_data}
LN               = ln -fs
MKDIR            = @mkdir
MKDIR_INSTALL    = @umask 022; mkdir -p -m 755
RANLIB           = @{var:ranlib_command}
RM               = @rm -f
RM_R             = @rm -rf

##################################################
# File Lists                                     #
##################################################
CHECK         = @{var:check_prefix}check

DOCS          = @{var:doc_files}

HEADERS       = @{var:include_files}

LIBOBJS       = @{var:lib_objs}

CHECKOBJS     = @{var:check_objs}

LIB_FLAGS     = $(LIB_OPT) $(MACH_OPT) $(LANG_FLAGS) $(WARN_FLAGS) $(SO_OBJ_FLAGS)
CHECK_FLAGS   = $(CHECK_OPT) $(LANG_FLAGS) $(WARN_FLAGS)

LIBRARIES     = $(STATIC_LIB) $(SHARED_LIB)

LIBNAME       = @{var:lib_prefix}libbotan
STATIC_LIB    = $(LIBNAME).a

SHARED_LIB    = $(LIBNAME)-$(SO_VERSION).@{var:so_suffix}
SONAME        = $(LIBNAME)-$(SO_VERSION).@{var:so_suffix}

SYMLINK       = libbotan.@{var:so_suffix}

all: $(LIBRARIES)

##################################################
# Build Commands                                 #
##################################################
@{var:lib_build_cmds}

@{var:check_build_cmds}

##################################################
# Link Commands                                  #
##################################################
$(CHECK): $(LIBRARIES) $(CHECKOBJS)
	$(CXX) $(LDFLAGS) $(CHECKOBJS) -o $(CHECK) -L. -lbotan-@{var:so_version} $(LINK_TO)

$(STATIC_LIB): $(LIBOBJS)
	$(RM) $(STATIC_LIB)
	$(AR) $(STATIC_LIB) $(LIBOBJS)
	$(RANLIB) $(STATIC_LIB)

$(SHARED_LIB): $(LIBOBJS)
	$(SO_LINK_CMD) $(LDFLAGS) $(LIBOBJS) -o $(SHARED_LIB) $(LINK_TO)
	$(LN) $(SHARED_LIB) $(SYMLINK)

##################################################
# Fake Targets                                   #
##################################################
.PHONY = doxygen clean distclean install static shared

static: $(STATIC_LIB)

shared: $(SHARED_LIB)

doxygen:
	doxygen @{var:doc-dir}/botan.doxy

clean:
	$(RM_R) @{var:build-dir}/lib/* @{var:build-dir}/checks/*
	$(RM) $(LIBRARIES) $(SYMLINK) $(CHECK)

distclean: clean
	$(RM_R) @{var:build-dir}
	$(RM_R) @{var:doc-dir}/doxygen @{var:doc-dir}/botan.doxy
	$(RM) Makefile $(CONFIG_SCRIPT) $(PKGCONFIG)

install: $(LIBRARIES)
	$(ECHO) "Installing Botan into $(DESTDIR)... "
	$(MKDIR_INSTALL) $(DOCDIR)
	$(MKDIR_INSTALL) $(HEADERDIR)
	$(MKDIR_INSTALL) $(LIBDIR)
	$(MKDIR_INSTALL) $(BINDIR)
	$(MKDIR_INSTALL) $(PKGCONF_DIR)
	for i in $(DOCS); do \
	   $(INSTALL_CMD_DATA) $$i $(DOCDIR); \
	 done
	for i in $(HEADERS); do \
	   $(INSTALL_CMD_DATA) $$i $(HEADERDIR); \
	 done
	$(INSTALL_CMD_DATA) $(STATIC_LIB) $(LIBDIR)
	$(INSTALL_CMD_EXEC) $(CONFIG_SCRIPT) $(BINDIR)
	$(INSTALL_CMD_EXEC) $(SHARED_LIB) $(LIBDIR)
	$(INSTALL_CMD_DATA) $(PKGCONFIG) $(PKGCONF_DIR)
	$(CD) $(LIBDIR); $(LN) $(SHARED_LIB) $(SYMLINK)