Message ID | 20230929091627.7820-14-jean@foundationdevices.com |
---|---|
State | New |
Headers | show |
Series | guix: Add avr as a platform. | expand |
Hi, Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com> writes: > * gnu/packages/cross-base.scm (cross-gcc-arguments): Handle AVR target. > --- > gnu/packages/cross-base.scm | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm > index fc21e7c4fd..10d912b755 100644 > --- a/gnu/packages/cross-base.scm > +++ b/gnu/packages/cross-base.scm > @@ -204,23 +204,38 @@ (define (cross-gcc-arguments target xgcc libc) > #~("--enable-multilib") > #~()) > > + #$@(if (and libc (target-avr? target)) > + #~("--enable-languages=c,c++" > + (string-append "--with-native-system-header-dir=" > + #$libc "/avr/include" )) > #~())) > > (remove > (lambda (flag) > (or (and (string-match "--enable-languages.*" flag) > #$libc) > + (and (string-match "--with-native-system-header-dir.*" > + flag) > + #$libc > + #$(target-avr? target)) > (and (string-match "--disable-multilib" flag) > #$(target-avr? target)))) > #$flags))) > ((#:make-flags flags) > - (if libc > - #~(let ((libc (assoc-ref %build-inputs "libc"))) > + (cond > + ((and (target-avr? target) libc) > + #~(let ((libc (assoc-ref %build-inputs "libc"))) While at it, you may want to use the more modern #$(this-package-input "libc") > ;; FLAGS_FOR_TARGET are needed for the target libraries to receive > ;; the -Bxxx for the startfiles. > - (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") > - #$flags)) > - flags)) > + (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/avr/lib") > + #$flags))) > + (libc > + #~(let ((libc (assoc-ref %build-inputs "libc"))) > + ;; FLAGS_FOR_TARGET are needed for the target libraries to receive > + ;; the -Bxxx for the startfiles. > + (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") > + #$flags))) > + (else flags))) The only thing that needs to be made conditional here is the "/lib" vs "/avr/lib" prefix, so you could let-bind a LIB-PREFIX variable conditionally and keep the rest shared.
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index fc21e7c4fd..10d912b755 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -204,23 +204,38 @@ (define (cross-gcc-arguments target xgcc libc) #~("--enable-multilib") #~()) + #$@(if (and libc (target-avr? target)) + #~("--enable-languages=c,c++" + (string-append "--with-native-system-header-dir=" + #$libc "/avr/include" )) #~())) (remove (lambda (flag) (or (and (string-match "--enable-languages.*" flag) #$libc) + (and (string-match "--with-native-system-header-dir.*" + flag) + #$libc + #$(target-avr? target)) (and (string-match "--disable-multilib" flag) #$(target-avr? target)))) #$flags))) ((#:make-flags flags) - (if libc - #~(let ((libc (assoc-ref %build-inputs "libc"))) + (cond + ((and (target-avr? target) libc) + #~(let ((libc (assoc-ref %build-inputs "libc"))) ;; FLAGS_FOR_TARGET are needed for the target libraries to receive ;; the -Bxxx for the startfiles. - (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") - #$flags)) - flags)) + (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/avr/lib") + #$flags))) + (libc + #~(let ((libc (assoc-ref %build-inputs "libc"))) + ;; FLAGS_FOR_TARGET are needed for the target libraries to receive + ;; the -Bxxx for the startfiles. + (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") + #$flags))) + (else flags))) ((#:phases phases) #~(cross-gcc-build-phases #$target #$phases))))))