aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-08 01:47:05 +0000
committerlloyd <[email protected]>2006-09-08 01:47:05 +0000
commitb5893bb80ba9327c9a71b03da770187f909137eb (patch)
tree615d7c268699b78b45863cd41e245737d26bd789
parent662fccf63e1063d45cd9de6e8860cdb8a28c9e90 (diff)
Generate the Unix makefiles by processing templates and replacing
variables, rather than hardcoding the entire Makefile into the script.
-rwxr-xr-xconfigure.pl227
-rw-r--r--misc/config/makefile/unix.in119
-rw-r--r--misc/config/makefile/unix_shr.in134
3 files changed, 302 insertions, 178 deletions
diff --git a/configure.pl b/configure.pl
index e47870a10..f8d2327f3 100755
--- a/configure.pl
+++ b/configure.pl
@@ -1299,8 +1299,10 @@ sub process_template {
$line =~ s/@\{var:$name\}/$val/g;
unless($val eq 'no' or $val eq 'false') {
+ $line =~ s/\@\{if:$name (.*)\}/$1/g;
$line =~ s/\@\{if:$name (.*) (.*)\}/$1/g;
} else {
+ $line =~ s/\@\{if:$name (.*)\}//g;
$line =~ s/\@\{if:$name (.*) (.*)\}/$2/g;
}
}
@@ -1494,17 +1496,9 @@ sub print_unix_makefile {
$install_root, $header_dir, $lib_dir, $doc_dir,
$lib_list) = @_;
- my $__TAB__ = "\t";
-
my $link_to = "-lm";
foreach my $lib (@$lib_list) { $link_to .= " -l" . $lib; }
- my $lib_flags = '$(LIB_OPT) $(MACH_OPT) $(LANG_FLAGS) $(WARN_FLAGS)';
-
- my $libs = '$(STATIC_LIB)';
- if($make_shared) { $lib_flags .= ' $(SO_OBJ_FLAGS)';
- $libs .= ' $(SHARED_LIB)'; }
-
my $install_user = os_install_info($os, 'install_user');
my $install_group = os_install_info($os, 'install_group');
@@ -1559,187 +1553,64 @@ sub print_unix_makefile {
##################### / COMMON CODE (PARTIALLY) ######################
- print_header($makefile, 'Compiler Options');
- print $makefile <<END_OF_MAKEFILE_HEADER;
-CXX = $cc
-LIB_OPT = $lib_opt
-CHECK_OPT = $check_opt
-MACH_OPT = $mach_opt
-LANG_FLAGS = $lang_flags
-WARN_FLAGS = $warn_flags
-SO_OBJ_FLAGS = $so_obj
-SO_LINK_CMD = $so_link
-LINK_TO = $link_to
-
-END_OF_MAKEFILE_HEADER
-
- print_header($makefile, 'Version Numbers');
- print $makefile <<END_OF_VERSIONS;
-MAJOR = $MAJOR_VERSION
-MINOR = $MINOR_VERSION
-PATCH = $PATCH_VERSION
-
-VERSION = \$(MAJOR).\$(MINOR).\$(PATCH)
-
-END_OF_VERSIONS
-
- print_header($makefile, 'Installation Settings');
- print $makefile <<END_OF_INSTALL_SETTINGS;
-INSTALLROOT = $install_root
-
-BINDIR = \$(INSTALLROOT)/bin
-LIBDIR = \$(INSTALLROOT)/$lib_dir
-HEADERDIR = \$(INSTALLROOT)/$header_dir/botan
-DOCDIR = \$(INSTALLROOT)/$doc_dir/Botan-\$(VERSION)
-
-OWNER = $install_user
-GROUP = $install_group
-DATA_MODE = 644
-EXEC_MODE = 755
-
-CONFIG_SCRIPT = botan-config
-
-END_OF_INSTALL_SETTINGS
-
- print_header($makefile, 'Aliases for Common Programs');
- print $makefile <<END_OF_COMMAND_ALIASES;
-AR = $ar_command
-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 \$(EXEC_MODE)
-RANLIB = \@ranlib
-RM = \@rm -f
-RM_R = \@rm -rf
-
-END_OF_COMMAND_ALIASES
-
- print_header($makefile, 'File Lists');
- print $makefile <<END_OF_FILE_LISTS;
-CHECK = check
-
-DOCS = $doc_list
-
-HEADERS = $includes
-
-LIBOBJS = $lib_obj
-
-CHECKOBJS = $check_obj
+ sub build_cmds {
+ my ($dir, $flags, $obj_suffix, %files) = @_;
+ my $output = '';
-LIB_FLAGS = $lib_flags
-CHECK_FLAGS = \$(CHECK_OPT) \$(LANG_FLAGS) \$(WARN_FLAGS)
-
-LIBRARIES = $libs
-
-LIBNAME = libbotan
-STATIC_LIB = \$(LIBNAME).$static_lib_suffix
-
-END_OF_FILE_LISTS
-
- if($make_shared) {
- print $makefile <<END_OF_SHARED_LIB_DECL;
-SHARED_LIB = \$(LIBNAME)-\$(MAJOR).\$(MINOR).\$(PATCH).$so_suffix
-SONAME = \$(LIBNAME)-\$(MAJOR).\$(MINOR).\$(PATCH).$so_suffix
-
-SYMLINK = \$(LIBNAME).$so_suffix
-
-END_OF_SHARED_LIB_DECL
- }
-
- print $makefile "all: \$(LIBRARIES)\n\n";
- print_header($makefile, 'Build Commands');
-
- sub print_build_cmds {
- my ($fh, $dir, $flags, $obj_suffix, %files) = @_;
foreach (sort keys %files) {
my $src_file = File::Spec->catfile ($files{$_}, $_);
my $obj_file = File::Spec->catfile ($dir, $_);
$obj_file =~ s/\.cpp$/.$obj_suffix/;
$obj_file =~ s/\.s$/.$obj_suffix/;
$obj_file =~ s/\.S$/.$obj_suffix/;
- print $fh "$obj_file: $src_file\n",
+ $output .= "$obj_file: $src_file\n" .
"\t\$(CXX) -I$BUILD_INCLUDE_DIR $flags -c \$? -o \$@\n\n";
}
+ return $output;
}
- print_build_cmds($makefile, $BUILD_LIB_DIR,
- '$(LIB_FLAGS)', $obj_suffix, %$src, %added_src);
-
- print_build_cmds($makefile, $BUILD_CHECK_DIR,
- '$(CHECK_FLAGS)', $obj_suffix, %$check);
-
- print_header($makefile, 'Link Commands');
-
- print $makefile <<END_OF_LINK_COMMANDS;
-\$(CHECK): \$(LIBRARIES) \$(CHECKOBJS)
-$__TAB__\$(CXX) \$(CHECKOBJS) -L. -lbotan \$(LINK_TO) -o \$(CHECK)
-
-\$(STATIC_LIB): \$(LIBOBJS)
-$__TAB__\$(RM) \$(STATIC_LIB)
-$__TAB__\$(AR) \$(STATIC_LIB) \$(LIBOBJS)
-END_OF_LINK_COMMANDS
-
- if($use_ranlib) { print $makefile "$__TAB__\$(RANLIB) \$(STATIC_LIB)\n\n"; }
- else { print $makefile "\n"; }
-
- if($make_shared) {
- print $makefile <<END_OF_SO_LINK_COMMAND;
-\$(SHARED_LIB): \$(LIBOBJS)
-$__TAB__\$(SO_LINK_CMD) \$(LINK_TO) \$(LIBOBJS) -o \$(SHARED_LIB)
-$__TAB__\$(LN) \$(SHARED_LIB) \$(SYMLINK)
-
-END_OF_SO_LINK_COMMAND
- }
-
- print_header($makefile, 'Fake Targets');
-
- print $makefile ".PHONY = clean distclean install static";
- if($make_shared) { print $makefile " shared"; }
- print $makefile "\n\n";
-
- print $makefile "static: \$(STATIC_LIB)\n\n";
- if($make_shared) { print $makefile "shared: \$(SHARED_LIB)\n\n"; }
-
- print $makefile <<END_OF_FAKE_TARGETS;
-clean:
-$__TAB__\$(RM_R) $BUILD_LIB_DIR/* $BUILD_CHECK_DIR/*
-$__TAB__\$(RM) \$(LIBRARIES) \$(SYMLINK) \$(CHECK)
-
-distclean: clean
-$__TAB__\$(RM_R) $BUILD_DIR
-$__TAB__\$(RM) $MAKE_FILE \$(CONFIG_SCRIPT)
-
-END_OF_FAKE_TARGETS
-
- print $makefile <<END_OF_INSTALL_SCRIPTS;
-install: \$(LIBRARIES)
-$__TAB__\$(ECHO) "Installing Botan into \$(INSTALLROOT)... "
-$__TAB__\$(MKDIR_INSTALL) \$(DOCDIR)
-$__TAB__\$(MKDIR_INSTALL) \$(HEADERDIR)
-$__TAB__\$(MKDIR_INSTALL) \$(LIBDIR)
-$__TAB__\$(MKDIR_INSTALL) \$(BINDIR)
-$__TAB__\@for i in \$(DOCS); do \\
-$__TAB__ \$(INSTALL_CMD_DATA) \$\$i \$(DOCDIR); \\
-$__TAB__ done
-$__TAB__\@for i in \$(HEADERS); do \\
-$__TAB__ \$(INSTALL_CMD_DATA) \$\$i \$(HEADERDIR); \\
-$__TAB__ done
-$__TAB__\@\$(INSTALL_CMD_DATA) \$(STATIC_LIB) \$(LIBDIR)
-$__TAB__\@\$(INSTALL_CMD_EXEC) \$(CONFIG_SCRIPT) \$(BINDIR)
-END_OF_INSTALL_SCRIPTS
-
- if($make_shared) {
- print $makefile <<END_OF_SYMLINKS;
-$__TAB__\@\$(INSTALL_CMD_EXEC) \$(SHARED_LIB) \$(LIBDIR)
-$__TAB__\$(CD) \$(LIBDIR); \$(LN) \$(SHARED_LIB) \$(SYMLINK)
-
-END_OF_SYMLINKS
- }
- else { print $makefile "\n"; }
-
+ my $lib_build_cmds = build_cmds($BUILD_LIB_DIR, '$(LIB_FLAGS)',
+ $obj_suffix, %$src, %added_src);
+ my $check_build_cmds = build_cmds($BUILD_CHECK_DIR, '$(CHECK_FLAGS)',
+ $obj_suffix, %$check);
+
+ chomp($lib_build_cmds);
+ chomp($check_build_cmds);
+
+ my $template = 'misc/config/makefile/unix.in';
+ $template = 'misc/config/makefile/unix_shr.in' if($make_shared);
+
+ process_template($template, 'Makefile',
+ { 'cc' => $cc,
+ 'lib_opt' => $lib_opt,
+ 'check_opt' => $check_opt,
+ 'mach_opt' => $mach_opt,
+ 'lang_flags' => $lang_flags,
+ 'warn_flags' => $warn_flags,
+ 'so_obj_flags' => $so_obj,
+ 'so_link' => $so_link,
+ 'link_to' => $link_to,
+ 'shared' => ($make_shared ? 'yes' : 'no'),
+ 'version_major' => $MAJOR_VERSION,
+ 'version_minor' => $MINOR_VERSION,
+ 'version_patch' => $PATCH_VERSION,
+ 'prefix' => $install_root,
+ 'libdir' => $lib_dir,
+ 'includedir' => $header_dir,
+ 'docdir' => $doc_dir,
+ 'install_user' => $install_user,
+ 'install_group' => $install_group,
+ 'ar_command' => $ar_command,
+ 'install_cmd_exec' => $install_cmd_exec,
+ 'install_cmd_data' => $install_cmd_data,
+ 'doc_files' => $doc_list,
+ 'include_files' => $includes,
+ 'lib_objs' => $lib_obj,
+ 'check_objs' => $check_obj,
+ 'lib_build_cmds' => $lib_build_cmds,
+ 'check_build_cmds' => $check_build_cmds,
+ 'so_suffix' => $so_suffix,
+ 'build' => $BUILD_DIR });
}
##################################################
diff --git a/misc/config/makefile/unix.in b/misc/config/makefile/unix.in
new file mode 100644
index 000000000..241c0a662
--- /dev/null
+++ b/misc/config/makefile/unix.in
@@ -0,0 +1,119 @@
+##################################################
+# 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}
+LINK_TO = @{var:link_to}
+
+##################################################
+# Version Numbers #
+##################################################
+MAJOR = @{var:version_major}
+MINOR = @{var:version_minor}
+PATCH = @{var:version_patch}
+
+VERSION = $(MAJOR).$(MINOR).$(PATCH)
+
+##################################################
+# Installation Settings #
+##################################################
+INSTALLROOT = @{var:prefix}
+
+BINDIR = $(INSTALLROOT)/bin
+LIBDIR = $(INSTALLROOT)/@{var:libdir}
+HEADERDIR = $(INSTALLROOT)/@{var:includedir}/botan
+DOCDIR = $(INSTALLROOT)/@{var:docdir}/Botan-$(VERSION)
+
+OWNER = @{var:install_user}
+GROUP = @{var:install_group}
+DATA_MODE = 644
+EXEC_MODE = 755
+
+CONFIG_SCRIPT = botan-config
+
+##################################################
+# 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 $(EXEC_MODE)
+RANLIB = @ranlib
+RM = @rm -f
+RM_R = @rm -rf
+
+##################################################
+# File Lists #
+##################################################
+CHECK = 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)
+CHECK_FLAGS = $(CHECK_OPT) $(LANG_FLAGS) $(WARN_FLAGS)
+
+LIBRARIES = $(STATIC_LIB)
+
+LIBNAME = libbotan
+STATIC_LIB = $(LIBNAME).a
+
+all: $(LIBRARIES)
+
+##################################################
+# Build Commands #
+##################################################
+@{var:lib_build_cmds}
+@{var:check_build_cmds}
+##################################################
+# Link Commands #
+##################################################
+$(CHECK): $(LIBRARIES) $(CHECKOBJS)
+ $(CXX) $(CHECKOBJS) -L. -lbotan $(LINK_TO) -o $(CHECK)
+
+$(STATIC_LIB): $(LIBOBJS)
+ $(RM) $(STATIC_LIB)
+ $(AR) $(STATIC_LIB) $(LIBOBJS)
+
+##################################################
+# Fake Targets #
+##################################################
+.PHONY = clean distclean install static
+
+static: $(STATIC_LIB)
+
+clean:
+ $(RM_R) @{var:build}/lib/* @{var:build}/checks/*
+ $(RM) $(LIBRARIES) $(SYMLINK) $(CHECK)
+
+distclean: clean
+ $(RM_R) @{var:build}
+ $(RM) Makefile $(CONFIG_SCRIPT)
+
+install: $(LIBRARIES)
+ $(ECHO) "Installing Botan into $(INSTALLROOT)... "
+ $(MKDIR_INSTALL) $(DOCDIR)
+ $(MKDIR_INSTALL) $(HEADERDIR)
+ $(MKDIR_INSTALL) $(LIBDIR)
+ $(MKDIR_INSTALL) $(BINDIR)
+ @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)
diff --git a/misc/config/makefile/unix_shr.in b/misc/config/makefile/unix_shr.in
new file mode 100644
index 000000000..0962e1722
--- /dev/null
+++ b/misc/config/makefile/unix_shr.in
@@ -0,0 +1,134 @@
+##################################################
+# 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:so_obj_flags}
+SO_LINK_CMD = @{var:so_link}
+LINK_TO = @{var:link_to}
+
+##################################################
+# Version Numbers #
+##################################################
+MAJOR = @{var:version_major}
+MINOR = @{var:version_minor}
+PATCH = @{var:version_patch}
+
+VERSION = $(MAJOR).$(MINOR).$(PATCH)
+
+##################################################
+# Installation Settings #
+##################################################
+INSTALLROOT = @{var:prefix}
+
+BINDIR = $(INSTALLROOT)/bin
+LIBDIR = $(INSTALLROOT)/@{var:libdir}
+HEADERDIR = $(INSTALLROOT)/@{var:includedir}/botan
+DOCDIR = $(INSTALLROOT)/@{var:docdir}/Botan-$(VERSION)
+
+OWNER = @{var:install_user}
+GROUP = @{var:install_group}
+DATA_MODE = 644
+EXEC_MODE = 755
+
+CONFIG_SCRIPT = botan-config
+
+##################################################
+# 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 $(EXEC_MODE)
+RANLIB = @ranlib
+RM = @rm -f
+RM_R = @rm -rf
+
+##################################################
+# File Lists #
+##################################################
+CHECK = 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 = libbotan
+STATIC_LIB = $(LIBNAME).a
+
+SHARED_LIB = $(LIBNAME)-$(MAJOR).$(MINOR).$(PATCH).@{var:so_suffix}
+SONAME = $(LIBNAME)-$(MAJOR).$(MINOR).$(PATCH).@{var:so_suffix}
+
+SYMLINK = $(LIBNAME).@{var:so_suffix}
+
+all: $(LIBRARIES)
+
+##################################################
+# Build Commands #
+##################################################
+@{var:lib_build_cmds}
+@{var:check_build_cmds}
+##################################################
+# Link Commands #
+##################################################
+$(CHECK): $(LIBRARIES) $(CHECKOBJS)
+ $(CXX) $(CHECKOBJS) -L. -lbotan $(LINK_TO) -o $(CHECK)
+
+$(STATIC_LIB): $(LIBOBJS)
+ $(RM) $(STATIC_LIB)
+ $(AR) $(STATIC_LIB) $(LIBOBJS)
+
+$(SHARED_LIB): $(LIBOBJS)
+ $(SO_LINK_CMD) $(LINK_TO) $(LIBOBJS) -o $(SHARED_LIB)
+ $(LN) $(SHARED_LIB) $(SYMLINK)
+
+##################################################
+# Fake Targets #
+##################################################
+.PHONY = clean distclean install static shared
+
+static: $(STATIC_LIB)
+
+shared: $(SHARED_LIB)
+
+clean:
+ $(RM_R) @{var:build}/lib/* @{var:build}/checks/*
+ $(RM) $(LIBRARIES) $(SYMLINK) $(CHECK)
+
+distclean: clean
+ $(RM_R) @{var:build}
+ $(RM) Makefile $(CONFIG_SCRIPT)
+
+install: $(LIBRARIES)
+ $(ECHO) "Installing Botan into $(INSTALLROOT)... "
+ $(MKDIR_INSTALL) $(DOCDIR)
+ $(MKDIR_INSTALL) $(HEADERDIR)
+ $(MKDIR_INSTALL) $(LIBDIR)
+ $(MKDIR_INSTALL) $(BINDIR)
+ @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)
+ $(CD) $(LIBDIR); $(LN) $(SHARED_LIB) $(SYMLINK)