-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfigure
executable file
·85 lines (73 loc) · 2.6 KB
/
configure
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
#! /usr/bin/env perl
use warnings;
use strict;
use version;
use File::Copy;
use Getopt::Long;
use lib 'tools/buildtools';
use ConfigUtil;
# version number
my $major = 0;
my $minor = 1;
my $micro = 0;
# project specified make variables
my %customs =
(
"TARGET" => "tensorlight",
"ABBR" => "TL",
"abbr" => "tl",
"EXPORT_HEADERS" => "src/tl_tensor.h src/tl_check.h src/tl_type.h src/tl_util.h",
"BUILDTOOLS_DIR" => "tools/buildtools",
"SRC_DIR" => "src",
"SRC_SUB_DIRS" => "",
"SRC_EXTRA_CFLAGS" => '-I$(BUILD_DIR)/include/$(TARGET)',
"SRC_REQUIRES" => "",
"TEST_DIR" => "test",
"TEST_SUB_DIRS" => "lightnettest",
"TEST_EXTRA_CFLAGS" => '-DLN_TEST_DIR="\"$(CURDIR)\"" -DLN_BUILD_TEST_DIR="\"$(shell realpath $(OBJDIR))\"" -I../$(SRC_DIR)',
"TEST_REQUIRES" => "check"
);
# make variables that can be set by configure options
my @options =
(
# [ $opt_name, $var_name, $type, $default, $desc ]
[ "build-dir", "BUILD_DIR", "DIR", "build", "building directory" ],
[ "install-dir", "INSTALL_DIR", "DIR", "/usr/local", "installation directory" ],
[ "prefix", "INSTALL_DIR", "DIR", "/usr/local", "same as --install-dir; who comes later counts" ],
[ "pkgconfig-dir", "PKGCONFIG_DIR", "DIR", '$(INSTALL_DIR)/lib/pkgconfig', "pkgconfig directory" ],
[ "with-cuda", "WITH_CUDA", "BOOL", "no", "set to yes if build with CUDA"],
[ "cuda-install-dir", "CUDA_INSTALL_DIR", "DIR", "/usr/local/cuda", "cuda installation directory"],
[ "debug", "DEBUG", "BOOL", "no", "set to yes when debugging" ],
);
# parse configure options
my $options_obj = gen_options(\@options, "Generate configuration makefile for building $customs{TARGET}.");
GetOptions(%{$options_obj->{getopt_args}}) or die $options_obj->{format_usage};
my %opts = %{$options_obj->{options}};
print "configure $customs{TARGET} version $major.$minor.$micro\n";
# check configuration
common_checks(\%opts);
my $output;
$output = `pkg-config --modversion check`;
if (!defined $output or $output eq "") {
err_exit("check is not installed");
}
my $config_str = <<EOC;
.SUFFIXES:
MAJOR = $major
MINOR = $minor
MICRO = $micro
EOC
$config_str .= config_to_str(\%opts);
$config_str .= "\n";
set_extra_bins(\%customs);
set_module_files(\%customs, "SRC");
set_module_files(\%customs, "TEST");
$config_str .= config_to_str(\%customs);
my $conf_file = "config.mk";
if (-e $conf_file) {
copy($conf_file, "$conf_file.bak") or die "Cannot copy $conf_file: $!";
}
open my $conf_fh, '>', $conf_file or die "Cannot open $conf_file: $!";
print $conf_fh $config_str;
close $conf_fh;
print $config_str;