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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
//
// Really, variables here should default to something that's platform dependant,
// but for now, we use linux, I'll default them to gnu/linux
//
if CXX == null then
{
CXX = "g++";
}
if AR == null then
{
AR = "ar";
}
if CC == null then
{
CC = "cc";
}
if BISON == null then
{
BISON = "bison";
}
if FLEX == null then
{
FLEX = "flex";
}
function cppToObj()
{
if OBJ_DIR == null then
{
return INPUT.regex("\\.cpp$", ".o");
}
else
{
return OBJ_DIR + "/" + INPUT.fileName().regex("\\.cpp$", ".o");
}
}
function cToObj()
{
if OBJ_DIR == null then
{
return INPUT.regex("\\.c$", ".o");
}
else
{
return OBJ_DIR + "/" + INPUT.fileName().regex("\\.c$", ".o");
}
}
rule "exe"
{
input "*.o";
profile "build"
{
execute("${CXX} -o ${OUTPUT} ${INPUT} ${LDFLAGS}");
}
}
rule "so"
{
input "*.o";
profile "build"
{
execute("${CXX} -shared -o ${OUTPUT} ${INPUT} ${LDFLAGS}");
}
}
rule "lib"
{
input "*.o";
profile "build"
{
execute("${AR} cr ${OUTPUT} ${INPUT}");
}
}
rule "cpp"
{
input "*.cpp";
output INPUT.cppToObj();
requires getMakeDeps("${CXX} ${CXXFLAGS} -M -MG ${INPUT}");
profile "build"
{
execute("${CXX} ${CXXFLAGS} -c -o ${OUTPUT} ${INPUT}", "g++");
}
}
// Heh, we're not going to use this one.
rule "c"
{
input "*.c";
output INPUT.cToObj();
requires getMakeDeps("${CC} ${CFLAGS} -M -MG ${INPUT}");
profile "build"
{
execute("${CC} ${CFLAGS} -c -o ${OUTPUT} ${INPUT}");
}
}
rule "bison"
{
input "*.y";
output [INPUT.regex("\\.y$", ".tab.c"), INPUT.regex("\\.y$", ".tab.h")];
profile "build"
{
BASE = INPUT.regex("\\.y", "");
execute("${BISON} -b${BASE} ${BISONFLAGS} ${INPUT}");
// if you add a -v bison will produce a .output file
}
}
rule "flex"
{
input "*.l";
output INPUT.regex("\\.l$", ".yy.c");
output INPUT.regex("\\.l$", ".yy.h");
profile "build"
{
execute("${FLEX} ${FLEXFLAGS} ${INPUT}");
}
}
rule "jar"
{
input "*.class";
profile "build"
{
if exists(OUTPUT) then
{
unlink(OUTPUT);
}
execute("jar cf ${OUTPUT} ${INPUT}");
}
}
rule "class"
{
input "*.java";
output INPUT.regex("\\.java", ".class");
profile "build"
{
execute("javac -cp . ${INPUT}");
}
}
|