-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_tools_am
executable file
·126 lines (122 loc) · 6.06 KB
/
gen_tools_am
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
#!/usr/bin/env perl
my $default_ggo_flags = "-u -N -e";
my %tools_ggo_flags = (
BNFunc => '-C -N -e',
BNServer => '-C -N -e',
Dat2Graph => '-C -N -e',
Explainer => '-C -N -e',
OntoFitter => '-C -u -N -e',
OntoShell => '-C -N -e',
OntoTrimmer => '-C -N -e',
);
my $tools_common_cflags1 = "\$(SLEIPNIR_CFLAGS)";
my $tools_common_cflags2 = " \$(LOG4CPP_CFLAGS) \$(PTHREAD_CFLAGS)";
my $tools_common_libs1 = "\$(SLEIPNIR_LIBS)";
my $tools_common_libs2 = " \$(LOG4CPP_LIBS) \$(PTHREAD_LIBS)";
# packages are: SMILE, SVM_PERF, READLINE, PTHREADS, BOOST, VOWPAL_WABBIT, LIBSVM
# ordering is important for linking
my %tools_other_packages = (
BNConverter => ['SMILE'],
BNCreator => ['SMILE'],
BNEvaluator => ['SMILE'],
BNServer => ['SMILE', 'BOOST'],
BNTester => ['SMILE'],
BNTruster => ['SMILE'],
BNUnraveler => ['SMILE'],
BNWeaver => ['SMILE'],
BNs2Txt => ['SMILE'],
SpeciesConnector => ['SMILE'],
# BNWrangler => ['SMILE'],
Contexter => ['SMILE'],
Counter => ['SMILE'],
DSLConverter => ['SMILE'],
Data2DB => ['SMILE'],
DBCombiner => ['GSL'],
SeekTest => ['GSL'],
SeekReader => ['GSL'],
SeekEvaluator => ['GSL'],
SeekPrep => ['GSL'],
SeekMiner => ['GSL'],
SeekServer => ['GSL'],
SeekPValue => ['GSL'],
SeekGeneRecommender => ['GSL'],
SeekAggregatedDataset => ['GSL'],
SeekIterative => ['GSL'],
PCLServer => ['GSL'],
Dab2Dad => ['SMILE'],
Dab2DB => ['SMILE'],
Data2Svm => ['SVM_PERF'],
Edges2Posteriors => ['SMILE'],
MEFIT => ['SMILE'],
OntoShell => ['READLINE'],
SVMer => ['SVM_PERF'],
SVMperfer => ['SVM_PERF'],
SVMfe => ['SVM_PERF'],
SVMmulticlass => ['SVM_MULTICLASS'],
SVMhierarchy => ['SVM_HIERARCHY'],
SVMperfing => ['SVM_PERF'],
LibSVMer => ['LIBSVM'],
VWer => ['VOWPAL_WABBIT'],
);
if (opendir(TOOLSDIR, "tools")) {
my $dent;
while ($dent = readdir(TOOLSDIR)) {
next if ($dent =~ /^\.\.?$/);
if (-d "tools/$dent") {
if (opendir(TOOLDIR, "tools/$dent")) {
my @src_files;
my @header_files;
my $ggo_file;
my $dent2;
while ($dent2 = readdir(TOOLDIR)) {
next if ($dent2 =~ /^cmdline\.[ch]$/);
if ($dent2 =~ /\.(c|cpp)$/) {
push(@src_files, $dent2);
} elsif ($dent2 =~ /\.h$/) {
push(@header_files, $dent2);
} elsif ($dent2 =~ /\.ggo$/) {
$ggo_file = $dent2;
}
}
close(TOOLDIR);
if (open(AM_MAKEFILE, "> tools/$dent/Makefile.am")) {
print AM_MAKEFILE "bin_PROGRAMS = $dent\n";
my $extra_cflags = "";
my $extra_libs = "";
my $pkgs = $tools_other_packages{$dent};
for (my $i = 0; $i <= $#$pkgs; $i++) {
$extra_cflags .= " \$(".$pkgs->[$i]."_CFLAGS)";
$extra_libs .= " \$(".$pkgs->[$i]."_LIBS)";
}
print AM_MAKEFILE "AM_CPPFLAGS = ".$tools_common_cflags1.$extra_cflags.$tools_common_cflags2."\n";
print AM_MAKEFILE "LDADD = ".$tools_common_libs1.$extra_libs.$tools_common_libs2."\n";
# print AM_MAKEFILE "AM_CPPFLAGS = \$(SLEIPNIR_CFLAGS) \$(SMILE_CFLAGS) \$(SVM_PERF_CFLAGS) \$(GENGETOPT_CFLAGS) \$(LOG4CPP_CFLAGS) \$(BOOST_CFLAGS) \$(READLINE_CFLAGS)\n";
# print AM_MAKEFILE "LDADD = \$(SLEIPNIR_LIBS) \$(SMILE_LIBS) \$(SVM_PERF_LIBS) \$(GENGETOPT_LIBS) \$(LOG4CPP_LIBS) \$(BOOST_LIBS) \$(READLINE_LIBS)\n";
if ($ggo_file) {
print AM_MAKEFILE "\nif WITH_GENGETOPT\n";
print AM_MAKEFILE "gengetopt = \$(prog_gengetopt)\n";
print AM_MAKEFILE "BUILT_SOURCES = cmdline.c cmdline.h\n";
print AM_MAKEFILE "cmdline.c cmdline.h: $ggo_file\n";
# print AM_MAKEFILE "cmdline.c: $ggo_file\n";
print AM_MAKEFILE "\t\$(gengetopt) -i".$ggo_file." --default-optional ";
if ($tools_ggo_flags{$dent}) {
print AM_MAKEFILE $tools_ggo_flags{$dent};
} else {
print AM_MAKEFILE $default_ggo_flags;
}
print AM_MAKEFILE "\nendif\n";
push(@src_files, "cmdline.c");
push(@header_files, "cmdline.h");
}
print AM_MAKEFILE $dent."_SOURCES = ", join(" ", @src_files), " \\\n\t", join(" ", @header_files), "\n";
close(AM_MAKEFILE);
}
} else {
die;
}
}
}
close(TOOLSDIR);
} else {
die;
}