-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate
executable file
·86 lines (70 loc) · 1.47 KB
/
update
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/perl
# ----------------
# libddg -- update
# ----------------
#
# Running this script updates dependency lists in the Makefile -- it
# assumes that include and source files are in ./include/ and ./src/,
# respectively. (Note that any existing dependency information will
# be overwritten!)
#
`g++ -I./include -I./src -MM src/*.cpp > ___dep`;
@objs = ();
open( IN, "<", "___dep" );
open( OUT, ">", "___dep2" );
while( <IN> )
{
if( /\\/ )
{
chomp;
s/\\//g;
}
if( /^(.*)\.o:/ )
{
$objName = $1;
push( @objs, $objName );
}
print OUT;
}
close( IN );
close( OUT );
open( MKIN, "<", "Makefile" );
open( MKOUT, ">", "___Makefile" );
$inHead = 1;
while( <MKIN> )
{
if( $inHead )
{
print MKOUT $_;
}
if( /^## !!/ )
{
$inHead = 0;
}
}
print MKOUT "\nOBJS =";
foreach( @objs )
{
print MKOUT " obj/$_.o";
}
print MKOUT "\n\n";
print MKOUT "all: \$\(TARGET\)\n\n";
print MKOUT "\$\(TARGET\): \$\(OBJS\)\n";
print MKOUT "\t\$\(LD\) \$\(LFLAGS\) \$\(OBJS\) \$\(LIBS\) -o \$\(TARGET\)\n\n";
open( IN, "<", "___dep2" );
while( <IN> )
{
/^(.*)\.o:/;
$objName = $1;
$_ =~ s/\s+/ /g;
print MKOUT "obj/" . $_ . "\n";
print MKOUT "\t\$\(CC\) \$\(CFLAGS\) -c src/$objName.cpp -o obj/$objName.o\n\n";
}
close( IN );
print MKOUT "\nclean:\n";
print MKOUT "\trm -f \$\(OBJS\)\n";
print MKOUT "\trm -f \$\(TARGET\)\n";
print MKOUT "\trm -f \$\(TARGET\).exe\n\n";
`rm ___dep`;
`rm ___dep2`;
`mv ___Makefile Makefile`;