aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/make.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rosa/make.go')
-rw-r--r--internal/rosa/make.go66
1 files changed, 58 insertions, 8 deletions
diff --git a/internal/rosa/make.go b/internal/rosa/make.go
index 1c0e52d6..877648c0 100644
--- a/internal/rosa/make.go
+++ b/internal/rosa/make.go
@@ -5,7 +5,10 @@ import (
"strings"
)
-var _make = H("make")
+var (
+ _make = H("make")
+ _makeEarly = H("make-early")
+)
// MakeHelper wraps the make program and its surrounding build system.
type MakeHelper struct {
@@ -14,6 +17,8 @@ type MakeHelper struct {
// Command to generate the build system.
Generate string
+ // Runs before configure.
+ ScriptConfigureEarly string
// Runs before make.
ScriptMakeEarly string
// Runs before check.
@@ -36,7 +41,15 @@ type MakeHelper struct {
Host string
// Target triple, zero value is equivalent to the Rosa OS triple.
Build string
+ // Do not clear program prefix/suffix.
+ DefaultName bool
+ // Do not pass sysroot to autoconf configure script.
+ OmitSysroot bool
+ // Omit the target argument.
+ AutoTarget bool
+ // Use the dependency-free [GenericHelper] make.
+ Early bool
// Extra make targets.
Make []string
// Whether to skip the check target.
@@ -52,16 +65,21 @@ type MakeHelper struct {
var _ Helper = new(MakeHelper)
// tools returns make and other optional dependencies.
-func (attr *MakeHelper) tools() P {
+func (attr *MakeHelper) tools(Toolchain) P {
+ h := _make
+ if attr != nil && attr.Early {
+ h = _makeEarly
+ }
+
if attr == nil || !attr.OmitDefaults {
return P{
- _make,
+ h,
_awk,
_coreutils,
}
}
- return P{_make}
+ return P{h}
}
// inputs is a noop.
@@ -101,26 +119,58 @@ func (attr *MakeHelper) script(t Toolchain, name string) string {
if attr == nil {
attr = new(MakeHelper)
}
+ cross, arch := t.cross(), t.Arch()
+ sysroot := "/system/" + arch
var configure string
+ target := t.triple()
+ if cross {
+ configure += `
+export CC='clang --target=` + target + ` --sysroot=` + sysroot + `'
+export CXX='clang++ --target=` + target + ` --sysroot=` + sysroot + `'
+export PKG_CONFIG_SYSROOT_DIR='` + sysroot + `'
+export PKG_CONFIG_LIBDIR='` + sysroot + `/system/lib/pkgconfig:` + sysroot + `/system/share/pkgconfig'
+`
+ }
+ configure += attr.ScriptConfigureEarly
+
if !attr.SkipConfigure {
- configure = attr.ConfigureName
- if configure == "" {
+ if attr.ConfigureName == "" {
configure += `/usr/src/` + name + `/configure`
+ } else {
+ configure += attr.ConfigureName
}
if attr.ForceAutoconf || attr.ConfigureName == "" {
configure += ` \
--prefix=/system`
- host := `"${ROSA_TRIPLE}"`
+ host := target
+ build := host
+ if cross {
+ build = triple(t.native().Arch())
+ }
+
if attr.Host != "" {
host = attr.Host
}
if attr.Host != `""` {
+ if !attr.DefaultName {
+ configure += ` \
+ --program-prefix='' \
+ --program-suffix=''`
+ }
+ if !attr.OmitSysroot && cross {
+ configure += ` \
+ --with-sysroot='/system/` + arch + `'`
+ }
configure += ` \
--host=` + host
+
+ if !attr.AutoTarget {
+ configure += ` \
+ --target=` + host
+ }
}
- build := `"${ROSA_TRIPLE}"`
if attr.Build != "" {
build = attr.Build
}