summaryrefslogtreecommitdiff
path: root/mbld/opts.myr
blob: bef9aca85a5b558b75917001de36c71829782ca2 (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
use std

use "config.use"

pkg bld =
	var opt_arch 	: byte[:]
	var opt_sys	: byte[:]
	var opt_runtime	: byte[:]
	var opt_genasm	: bool
	var opt_incpaths	: byte[:][:]
	var opt_instroot	: byte[:]
	var opt_manpath	: byte[:]
	var opt_destdir	: byte[:]
	var opt_outdir	: byte[:]
	var opt_debug	: bool

	/* undocumented/unsupported opts */
	var opt_mc	: byte[:]
	var opt_muse	: byte[:]

	var sysarchstr	: byte[:]
	var archstr	: byte[:]
	var sysstr	: byte[:]

	const initopts	: (-> void)
;;

var opt_arch 	= ""
var opt_sys	= ""
var opt_binname	= ""
var opt_libname	= ""
var opt_runtime	= ""
var opt_incpaths	/* FIXME: taking a constant slice is a nonconstant initializer */
var opt_instroot	= ""
var opt_manpath	= ""
var opt_destdir	= ""
var opt_debug	= false
var opt_mc	= "6m"
var opt_as	= "as"
var opt_muse	= "muse"
var opt_ld	= "ld"
var opt_ar	= "ar"
var opt_genasm  = false

/* derived */
var sysarchstr	= ""
var archstr	= ""
var sysstr	= ""

const initopts = {
	var si

	std.getsysinfo(&si)
	match si.system
	| "Linux":	opt_sys = "linux"
	| "Darwin":	opt_sys = "osx"
	| "FreeBSD":	opt_sys = "freebsd"
	| "Plan9":	opt_sys = "plan9"
	| unknown:	std.fatal(1, "unknown system \"%s\"\n", unknown)
	;;

	match si.arch
	| "x86_64":	opt_arch = "x64"
	| "amd64":	opt_arch = "x64"
	| unknown:	std.fatal(1, "unknown architecture \"%s\"\n", unknown)
	;;

	opt_incpaths = [][:]
	opt_instroot = config.Instroot
	opt_manpath = config.Manpath
	opt_destdir = std.getenvv("DESTDIR", "")
	opt_mc = std.getenvv("MYR_MC", "6m")
	opt_muse = std.getenvv("MYR_MUSE", "muse")
	opt_runtime = std.getenvv("MYR_RT", "")
	if opt_runtime.len == 0
		opt_runtime = std.pathjoin([opt_instroot, config.Libpath, config.Runtime][:]) 
	;;

	sysarchstr = std.fmt("+%s-%s", opt_sys, opt_arch)
	sysstr = std.fmt("+%s", opt_sys)
	archstr = std.fmt("+%s", opt_arch)
}