aboutsummaryrefslogtreecommitdiffstats
path: root/src/build-data/makefile/gmake.in
blob: bcaa5b9a0b093edb3700ec94b661b34dcab408c1 (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
# Compiler Options
CXX           = %{cc}
LIB_OPT       = %{lib_opt}
APP_OPT       = %{app_opt}
LANG_FLAGS    = %{lang_flags}
WARN_FLAGS    = %{warn_flags}
SO_OBJ_FLAGS  = %{shared_flags}
LIB_LINKS_TO  = %{link_to}
APP_LINKS_TO  = $(LIB_LINKS_TO) -lboost_thread
TEST_LINKS_TO  = $(LIB_LINKS_TO) -lboost_filesystem

LIB_FLAGS    = $(SO_OBJ_FLAGS) $(LANG_FLAGS) $(LIB_OPT) $(WARN_FLAGS)
APP_FLAGS    = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS)
TEST_FLAGS   = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS)

# Version Numbers
VERSION       = %{version}
BRANCH        = %{version_major}.%{version_minor}

# Installation Settings
DESTDIR       = %{prefix}

BINDIR        = $(DESTDIR)/bin
LIBDIR        = $(DESTDIR)/%{libdir}
HEADERDIR     = $(DESTDIR)/%{includedir}/botan-$(BRANCH)/botan
DOCDIR        = $(DESTDIR)/%{docdir}/botan-$(VERSION)
PKGCONF_DIR   = $(LIBDIR)/pkgconfig

CONFIG_SCRIPT = %{botan_config}
PKGCONFIG     = %{botan_pkgconfig}

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

# Targets
APP           = %{app_prefix}botan
TEST          = %{app_prefix}botan-test
LIBRARIES     = $(STATIC_LIB)

LIBNAME       = %{lib_prefix}libbotan
STATIC_LIB    = $(LIBNAME)-$(BRANCH).a

LIBPATH       = botan-$(BRANCH)

all: $(APP) $(TEST)

# File Lists
INCLUDE_DIR = %{botan_include_dir}

LIBOBJS       = %{lib_objs}

APPOBJS     = %{app_objs}

TESTOBJS     = %{test_objs}

# Build Commands
%{lib_build_cmds}

%{app_build_cmds}

%{test_build_cmds}

# Link Commands
%{shared_makefile}

$(APP): $(LIBRARIES) $(APPOBJS)
	$(CXX) $(LDFLAGS) $(APPOBJS) -L. -l$(LIBPATH) $(APP_LINKS_TO) -o $(APP)

$(TEST): $(LIBRARIES) $(TESTOBJS)
	$(CXX) $(LDFLAGS) $(TESTOBJS) -L. -l$(LIBPATH) $(TEST_LINKS_TO) -o $(TEST)

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

%{python_makefile}

# Fake Targets
.PHONY = docs clean distclean install

docs:
%{build_doc_commands}

clean:
	$(RM_R) %{build_dir}/lib/* %{build_dir}/tests/*
	$(RM) $(LIBRARIES) $(SYMLINK) $(SONAME) $(APP)

distclean: clean
	$(RM_R) %{build_dir}
	$(RM) Makefile* $(CONFIG_SCRIPT) $(PKGCONFIG)
	$(RM) botan_all.cpp botan_all.h

install: $(LIBRARIES) docs
	$(MKDIR_INSTALL) $(DOCDIR)
	$(COPY_R) %{doc_output_dir}/* $(DOCDIR)

	$(MKDIR_INSTALL) $(HEADERDIR)
	for i in $(INCLUDE_DIR)/*.h; do \
	   $(INSTALL_CMD_DATA) $$i $(HEADERDIR); \
	 done

	$(MKDIR_INSTALL) $(LIBDIR)
	$(INSTALL_CMD_DATA) $(STATIC_LIB) $(LIBDIR)

        ifdef $(SHARED_LIB)
	$(INSTALL_CMD_EXEC) $(SHARED_LIB) $(LIBDIR)
	$(CD) $(LIBDIR); $(LN) $(SHARED_LIB) $(SYMLINK)
	$(CD) $(LIBDIR); $(LN) $(SHARED_LIB) $(SONAME)
        endif

	$(MKDIR_INSTALL) $(BINDIR)
	$(INSTALL_CMD_EXEC) $(CONFIG_SCRIPT) $(BINDIR)

	$(MKDIR_INSTALL) $(PKGCONF_DIR)
	$(INSTALL_CMD_DATA) $(PKGCONFIG) $(PKGCONF_DIR)