gnu: vpnc: Fix cross-compilation.
* gnu/packages/vpn.scm (vpnc): Fix cross-compilation. [native-inputs]: Add conditional input of `this-package' (vpnc) to reuse the man page and add `pkg-config'. [arguments]: Use G-Expressions. [arguments]: Make use of `make-flags' instead of using substitutions. [arguments]: Remove unneeded deletion of `configure'. [arguments]: Use `pkg-config' to search for libgcrypt. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
		
							parent
							
								
									e8e7b4cdae
								
							
						
					
					
						commit
						bb88505ee8
					
				
					 1 changed files with 62 additions and 18 deletions
				
			
		| 
						 | 
					@ -21,6 +21,7 @@
 | 
				
			||||||
;;; Copyright © 2022 Josselin Poiret <josselin.poiret@protonmail.ch>
 | 
					;;; Copyright © 2022 Josselin Poiret <josselin.poiret@protonmail.ch>
 | 
				
			||||||
;;; Copyright © 2022 Lu hui <luhux76@gmail.com>
 | 
					;;; Copyright © 2022 Lu hui <luhux76@gmail.com>
 | 
				
			||||||
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 | 
					;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 | 
				
			||||||
 | 
					;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
;;; This file is part of GNU Guix.
 | 
					;;; This file is part of GNU Guix.
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
| 
						 | 
					@ -479,25 +480,68 @@ file for more details.")
 | 
				
			||||||
            (sha256 (base32
 | 
					            (sha256 (base32
 | 
				
			||||||
                     "1128860lis89g1s21hqxvap2nq426c9j4bvgghncc1zj0ays7kj6"))))
 | 
					                     "1128860lis89g1s21hqxvap2nq426c9j4bvgghncc1zj0ays7kj6"))))
 | 
				
			||||||
   (build-system gnu-build-system)
 | 
					   (build-system gnu-build-system)
 | 
				
			||||||
   (inputs (list libgcrypt perl vpnc-scripts))
 | 
					   (native-inputs (append (list perl pkg-config vpnc-scripts)
 | 
				
			||||||
 | 
					                          (if (%current-target-system)
 | 
				
			||||||
 | 
					                            (list this-package)
 | 
				
			||||||
 | 
					                            '())))
 | 
				
			||||||
 | 
					   (inputs (list libgcrypt vpnc-scripts))
 | 
				
			||||||
   (arguments
 | 
					   (arguments
 | 
				
			||||||
    `(#:tests? #f ; there is no check target
 | 
					     (list #:tests? #f ;; There is no check target
 | 
				
			||||||
      #:phases
 | 
					           #:make-flags
 | 
				
			||||||
      (modify-phases %standard-phases
 | 
					           #~(list (string-append "CC=" #$(cc-for-target))
 | 
				
			||||||
        (add-after 'unpack 'use-store-paths
 | 
					                   (string-append "ETCDIR=" #$output "/etc/vpnc")
 | 
				
			||||||
          (lambda* (#:key inputs outputs #:allow-other-keys)
 | 
					                   (string-append "PREFIX=" #$output))
 | 
				
			||||||
            (let ((out          (assoc-ref outputs "out"))
 | 
					           #:phases
 | 
				
			||||||
                  (vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
 | 
					           #~(modify-phases %standard-phases
 | 
				
			||||||
              (substitute* "config.c"
 | 
					               (delete 'configure) ;; No configure script.
 | 
				
			||||||
                (("/etc/vpnc/vpnc-script")
 | 
					               (add-after 'unpack 'use-store-paths
 | 
				
			||||||
                 (string-append vpnc-scripts "/etc/vpnc/vpnc-script")))
 | 
					                 (lambda* (#:key inputs #:allow-other-keys)
 | 
				
			||||||
              (substitute* "Makefile"
 | 
					                   (let ((vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
 | 
				
			||||||
                (("ETCDIR=.*")
 | 
					                     (substitute* "config.c"
 | 
				
			||||||
                 (string-append "ETCDIR=" out "/etc/vpnc\n"))
 | 
					                       (("/etc/vpnc/vpnc-script")
 | 
				
			||||||
                (("PREFIX=.*")
 | 
					                        (string-append vpnc-scripts
 | 
				
			||||||
                 (string-append "PREFIX=" out "\n")))
 | 
					                                       "/etc/vpnc/vpnc-script"))))))
 | 
				
			||||||
              #t)))
 | 
					               (add-after 'unpack 'patch-Makefile
 | 
				
			||||||
        (delete 'configure))))          ; no configure script
 | 
					                 (lambda* (#:key target #:allow-other-keys)
 | 
				
			||||||
 | 
					                   (let* ((pkg-config #$(pkg-config-for-target))
 | 
				
			||||||
 | 
					                          (includedir (string-append pkg-config
 | 
				
			||||||
 | 
					                                                     " --variable=includedir"
 | 
				
			||||||
 | 
					                                                     " libgcrypt"))
 | 
				
			||||||
 | 
					                          (cflags (string-append pkg-config
 | 
				
			||||||
 | 
					                                                 " --cflags"
 | 
				
			||||||
 | 
					                                                 " libgcrypt"))
 | 
				
			||||||
 | 
					                          (libdir (string-append pkg-config
 | 
				
			||||||
 | 
					                                                 " --variable=libdir"
 | 
				
			||||||
 | 
					                                                 " libgcrypt"))
 | 
				
			||||||
 | 
					                          (libs (string-append pkg-config
 | 
				
			||||||
 | 
					                                               " --libs"
 | 
				
			||||||
 | 
					                                               " libgcrypt")))
 | 
				
			||||||
 | 
					                     (substitute* "Makefile"
 | 
				
			||||||
 | 
					                       (("\\$\\(shell libgcrypt-config --cflags\\)")
 | 
				
			||||||
 | 
					                        (string-append "-I$(shell " includedir ") "
 | 
				
			||||||
 | 
					                                       "$(shell " cflags ")"))
 | 
				
			||||||
 | 
					                       (("\\$\\(shell libgcrypt-config --libs\\)")
 | 
				
			||||||
 | 
					                        (string-append
 | 
				
			||||||
 | 
					                          "-L$(shell " libdir ") "
 | 
				
			||||||
 | 
					                          "$(shell " libs ")")))
 | 
				
			||||||
 | 
					                     ;; When cross-compiling the manpage can't be generated as the
 | 
				
			||||||
 | 
					                     ;; Makefile needs to execute the resulting `vpnc' binary.
 | 
				
			||||||
 | 
					                     (when target
 | 
				
			||||||
 | 
					                       (substitute* "Makefile"
 | 
				
			||||||
 | 
					                         (("all : \\$\\(BINS\\) vpnc\\.8 vpnc-script")
 | 
				
			||||||
 | 
					                          "all : $(BINS) vpnc-script")
 | 
				
			||||||
 | 
					                         (("install -m644 vpnc\\.8.*") ""))))))
 | 
				
			||||||
 | 
					               (add-after 'unpack 'install-manpage
 | 
				
			||||||
 | 
					                 (lambda* (#:key native-inputs inputs target
 | 
				
			||||||
 | 
					                           #:allow-other-keys)
 | 
				
			||||||
 | 
					                   ;; As the manpage is not generated. Instead install it from
 | 
				
			||||||
 | 
					                   ;; the input vpnc package.
 | 
				
			||||||
 | 
					                   (when target
 | 
				
			||||||
 | 
					                     (let* ((vpnc (assoc-ref native-inputs "vpnc"))
 | 
				
			||||||
 | 
					                            (man (string-append vpnc
 | 
				
			||||||
 | 
					                                                "/share/man/man8/vpnc.8.gz"))
 | 
				
			||||||
 | 
					                            (output (string-append #$output "/share/man/man8")))
 | 
				
			||||||
 | 
					                       (install-file man output))))))))
 | 
				
			||||||
   (synopsis "Client for Cisco VPN concentrators")
 | 
					   (synopsis "Client for Cisco VPN concentrators")
 | 
				
			||||||
   (description
 | 
					   (description
 | 
				
			||||||
    "vpnc is a VPN client compatible with Cisco's EasyVPN equipment.
 | 
					    "vpnc is a VPN client compatible with Cisco's EasyVPN equipment.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue