aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/make.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-02-11 23:51:10 +0900
committerOphestra <cat@gensokyo.uk>2026-02-12 01:19:40 +0900
commit1791b604b525cd67f3b6c393a1364688762aa2e0 (patch)
tree84b622364fb5530d97edecb1beccfee9d59ed602 /internal/rosa/make.go
parent59ff6db7ec627bd8237b9508ef78c65204971cfc (diff)
internal/rosa/make: configurable configure and install
This makes the helper useful for non-autotools build systems. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/make.go')
-rw-r--r--internal/rosa/make.go82
1 files changed, 49 insertions, 33 deletions
diff --git a/internal/rosa/make.go b/internal/rosa/make.go
index f330a0ad..63f65410 100644
--- a/internal/rosa/make.go
+++ b/internal/rosa/make.go
@@ -51,6 +51,8 @@ type MakeAttr struct {
// Remain in working directory set up during ScriptEarly.
InPlace bool
+ // Whether to skip running the configure script.
+ SkipConfigure bool
// Flags passed to the configure script.
Configure [][2]string
// Extra make targets.
@@ -61,10 +63,14 @@ type MakeAttr struct {
SkipCheck bool
// Name of the check target, zero value is equivalent to "check".
CheckName string
+ // Replaces the default install command.
+ ScriptInstall string
// Suffix appended to the source pathname.
SourceSuffix string
+ // Passed through to [Toolchain.New], before source.
+ Paths []pkg.ExecPath
// Passed through to [Toolchain.New].
Flag int
}
@@ -87,34 +93,39 @@ func (t Toolchain) NewViaMake(
build = attr.Build
}
- var configureFlags string
- if len(attr.Configure) > 0 {
- const sep = " \\\n\t"
- configureFlags += sep + strings.Join(
- slices.Collect(func(yield func(string) bool) {
- for _, v := range attr.Configure {
- s := v[0]
- if v[1] == "" || (v[0] != "" &&
- v[0][0] >= 'a' &&
- v[0][0] <= 'z') {
- s = "--" + s
- }
- if v[1] != "" {
- s += "=" + v[1]
- }
- if !yield(s) {
- return
- }
- }
- }),
- sep,
- )
- }
+ var configure string
+ if !attr.SkipConfigure {
+ configure += `
+/usr/src/` + name + `/configure \
+ --prefix=/system`
- var buildFlag string
- if attr.Build != `""` {
- buildFlag = ` \
+ if attr.Build != `""` {
+ configure += ` \
--build=` + build
+ }
+
+ if len(attr.Configure) > 0 {
+ const sep = " \\\n\t"
+ configure += sep + strings.Join(
+ slices.Collect(func(yield func(string) bool) {
+ for _, v := range attr.Configure {
+ s := v[0]
+ if v[1] == "" || (v[0] != "" &&
+ v[0][0] >= 'a' &&
+ v[0][0] <= 'z') {
+ s = "--" + s
+ }
+ if v[1] != "" {
+ s += "=" + v[1]
+ }
+ if !yield(s) {
+ return
+ }
+ }
+ }),
+ sep,
+ )
+ }
}
makeTargets := make([]string, 1, 2+len(attr.Make))
@@ -148,15 +159,20 @@ func (t Toolchain) NewViaMake(
panic("cannot remain in root")
}
+ scriptInstall := attr.ScriptInstall
+ if scriptInstall == "" {
+ scriptInstall = "make DESTDIR=/work install"
+ }
+ scriptInstall += "\n"
+
return t.New(name+"-"+version, attr.Flag, stage0Concat(t,
attr.NonStage0,
finalExtra...,
- ), nil, attr.Env, scriptEarly+`
-/usr/src/`+name+`/configure \
- --prefix=/system`+buildFlag+configureFlags+attr.ScriptConfigured+`
+ ), nil, attr.Env, scriptEarly+configure+attr.ScriptConfigured+`
make "-j$(nproc)"`+strings.Join(makeTargets, " ")+`
-make DESTDIR=/work install
-`+attr.Script, pkg.Path(AbsUsrSrc.Append(
- name+attr.SourceSuffix,
- ), attr.Writable, source))
+`+scriptInstall+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{
+ pkg.Path(AbsUsrSrc.Append(
+ name+attr.SourceSuffix,
+ ), attr.Writable, source),
+ })...)
}