summaryrefslogtreecommitdiff
path: root/default.bld
blob: 6f9feebe44cb63a0e7e44f20ecf0ec0629312932 (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

if exists("src/parser.yy.cpp") then
{
	unlink("src/parser.yy.cpp");
}
if exists("src/parser.tab.cpp") then
{
	unlink("src/parser.tab.cpp");
}

action "default"
{
	build: ["src/version.h", "src/datafiles.h", "stage"];
}

target "src/version.h"
{
	input ".git";
	profile "build"
	{
		fh = open("src/version.h.tmp", "w");
		fh.write(
"#ifndef VERSION_H\n"
"#define VERSION_H\n"
"\n"
"#define VERSION		\"$(git describe --abbrev=0)\"\n"
"#define FULLVER		\"$(git describe)\"\n"
"#define SHAVER		\"$(git log -n1 --pretty=format:%H)\"\n"
"#define TIMEVER		\"$(git log -n1 --pretty=format:%aD)\"\n"
"\n"
"#endif");
		fh.close();
		if "$(cmp src/version.h.tmp src/version.h 2>&1)" == "" then
		{
			execute("rm src/version.h.tmp");
		}
		else
		{
			execute("mv src/version.h.tmp src/version.h");
		}
	}
}

target "src/datafiles.h"
{
	input ["sml-help.sml"];
	profile "build"
	{
		execute("bin2cpp -d src -f deflate sml-help.sml");
	}
}

CC="g++";
target "stage"
{
	rule "exe";
	input files("src/*.y", "src/*.l", "src/*.cpp", "src/version.h");

	CXXFLAGS="-ggdb -Ilibgats";
	CFLAGS="-ggdb";

	FLEXFLAGS="-osrc/parser.yy.c --header-file=src/parser.yy.h";
	BISONFLAGS="-d";

	LDFLAGS += "-Llibgats -lgats -lbu++ -ldl -lz";
}

/*
rule "bison"
{
	input "*.y";
	output [INPUT.regex("\\.y$", ".tab.c"), INPUT.regex("\\.y$", ".tab.h")];
	profile "build"
	{
		DIR=INPUT.dirName();
		FILE=INPUT.fileName();
		execute("cd ${DIR}; bison -d ${FILE}");
	}
}
*/