-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcompile-config.perl
54 lines (43 loc) · 1.69 KB
/
compile-config.perl
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
######################################################################################
# Emerge code - compile-config.perl #
# Adapted from the GADGET code developed by Volker Springel #
######################################################################################
# #
# This file processes the configurations options in Config.sh, producing two files: #
# codeoptions.h to be included in each source file (via allvars.h) #
# compile_info.c code to be compiled in, which will print the configuration #
# #
######################################################################################
if( @ARGV != 2)
{
print "usage: perl compile-config.perl <Config.sh> <build dir>\n";
exit;
}
open(FILE, @ARGV[0]);
$path = @ARGV[1];
open(OUTFILE, ">${path}/codeoptions.h");
open(COUTF, ">${path}/compile_info.c");
print COUTF "#include <stdio.h>\n";
print COUTF "#include \"../src/allvars.h\"\n\n";
print COUTF "void output_code_options(void)\n\{\n";
$count = 0;
while($line=<FILE>)
{
chop $line;
@fields = split ' ' , $line;
if(substr($fields[0], 0, 1) ne "#")
{
if(length($fields[0]) > 0)
{
@subfields = split '=', $fields[0];
print OUTFILE "#define $subfields[0] $subfields[1]\n";
print COUTF " printf(\"%c%c%c $fields[0]\\n\",SYMBOL,SYMBOL,SYMBOL);\n";
$count = $count + 1;
}
}
}
if ($count<1)
{
print COUTF " printf(\"%c%c%c NONE\\n\",SYMBOL,SYMBOL,SYMBOL);\n";
}
print COUTF "\}\n";