+ ,@(if (%current-target-system)
+ `((add-after 'unpack 'unpack-cross
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (let ((cross-checkout
+ (assoc-ref native-inputs "perl-cross"))
+ (cross-patch
+ (assoc-ref native-inputs "perl-cross-patch")))
+ (rename-file "Artistic" "Artistic.perl")
+ (rename-file "Copying" "Copying.perl")
+ (copy-recursively cross-checkout ".")
+ (format #t "Applying ~a\n" cross-patch)
+ (invoke "patch" "-p1" "-i" cross-patch))
+ (let ((bash (assoc-ref inputs "bash")))
+ (substitute* '("Makefile.config.SH"
+ "cnf/config.guess"
+ "cnf/config.sub"
+ "cnf/configure"
+ "cnf/configure_misc.sh"
+ "miniperl_top")
+ (("! */bin/sh") (string-append "! " bash "/bin/bash"))
+ ((" /bin/sh") (string-append bash "/bin/bash")))
+ (substitute* '("ext/Errno/Errno_pm.PL")
+ (("\\$cpp < errno.c") "$Config{cc} -E errno.c")))
+ #t))
+ (replace 'configure
+ (lambda* (#:key configure-flags outputs inputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (store-directory (%store-directory))
+ (configure-flags
+ (cons*
+ ;; `perl-cross' confuses target and host
+ (string-append "--target=" ,(%current-target-system))
+ (string-append "--prefix=" out)
+ (string-append "-Dcc=" ,(%current-target-system) "-gcc")
+ "-Dbyteorder=1234"
+ (filter (negate
+ (lambda (x) (or (string-prefix? "-d" x)
+ (string-prefix? "-Dcc=" x))))
+ configure-flags)))
+ (bash (assoc-ref inputs "bash"))
+ (coreutils (assoc-ref inputs "coreutils")))
+ (format (current-error-port)
+ "running ./configure ~a\n" (string-join configure-flags))
+ (apply invoke (cons "./configure" configure-flags))
+ (substitute* "config.sh"
+ (((string-append store-directory "/[^/]*-bash-[^/]*"))
+ bash))
+ (substitute* '("config.h")
+ (("^#define SH_PATH .*")
+ (string-append "#define SH_PATH \"" bash "/bin/bash\"\n")))
+ ;;TODO: fix this in setup-configure next rebuild cycle
+ (substitute* "dist/PathTools/Cwd.pm"
+ (((string-append store-directory "/[^/]*-coreutils-[^/]*"))
+ coreutils))
+ #t)))
+ (add-after 'build 'touch-non-built-files-for-install
+ (lambda _
+ ;; `make install' wants to install these although they do
+ ;; not get built...
+ (with-directory-excursion "cpan"
+ (mkdir-p "Pod-Usage/blib/script")
+ (mkdir-p "Pod-Parser/blib/script")
+ (for-each (lambda (file)
+ (call-with-output-file file
+ (lambda (port) (display "" port))))
+ '("Pod-Usage/blib/script/pod2text"
+ "Pod-Usage/blib/script/pod2usage"
+ "Pod-Checker/blib/script/podchecker"
+ "Pod-Parser/blib/script/podselect")))
+ #t)))
+ `((replace 'configure
+ (lambda* (#:key configure-flags #:allow-other-keys)
+ (format #t "Perl configure flags: ~s~%" configure-flags)
+ (apply invoke "./Configure" configure-flags)))))