aboutsummaryrefslogtreecommitdiff
path: root/share/autoinclude/general-rules.bld
blob: 30a4376265f90037276b3be675943f97062947cd (plain)
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
//
// 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
	{
		DIR = INPUT.dirName();
	}
	else
	{
		DIR = OBJ_DIR;
	}

	return DIR + "/" + INPUT.fileName().replace(".cpp", ".o");
}

function cToObj()
{
	if OBJ_DIR == null then
	{
		DIR = INPUT.dirName();
	}
	else
	{
		DIR = OBJ_DIR;
	}

	return DIR + "/" + INPUT.fileName().replace(".c", ".o");
}

rule "exe"
{
	input "*.o";
	profile "build"
	{
		execute("${CXX} -o ${OUTPUT} ${INPUT} ${LDFLAGS}");
	}
}

rule "lib"
{
	input "*.o";
	profile "build"
	{
		execute("${AR} cr ${OUTPUT} ${INPUT}");
	}
}

rule "cpp"
{
	input "*.cpp";
	output INPUT.cppToObj();
//	output replace(".cpp", ".o");
	requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${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();
//	output replace(".c", ".o");
	requires getMakeDeps("${CC} ${CFLAGS} -M ${INPUT}");
	profile "build"
	{
		execute("${CC} ${CFLAGS} -c -o ${OUTPUT} ${INPUT}");
	}
}

rule "bison"
{
	input "*.y";
	output [INPUT.replace(".y", ".tab.c"), INPUT.replace(".y", ".tab.h")];
	profile "build"
	{
		BASE = INPUT.replace(".y", "");
		execute("${BISON} -b${BASE} ${INPUT}");
		// if you add a -v bison will produce a .output file
	}
}

rule "flex"
{
	input "*.l";
	output INPUT.replace(".l", ".yy.c");
	output INPUT.replace(".l", ".yy.h");
	profile "build"
	{
		execute("${FLEX} ${FLEXFLAGS} ${INPUT}");
	}
}