Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What to do with package that requires autotools and configure and make to build... #386

Closed
hartzell opened this issue Jun 11, 2019 · 8 comments · Fixed by #387
Closed

What to do with package that requires autotools and configure and make to build... #386

hartzell opened this issue Jun 11, 2019 · 8 comments · Fixed by #387

Comments

@hartzell
Copy link
Contributor

I hesitate to ask, but.... I've been reading my mail in vm for a very long time. Its definitely moribund, if not mostly dead, but it works.

I've switched nearly all of my emacs set up to use use-package (aka straight-use-package), but I'm still wiring up my vm by hand from a copy of it's 8.2.0b release.

While this might be a job for Miracle Max the Wizard ("mostly dead", obligatory Princess Bride ref), I wanted to see what I could do about it.

I was fascinated to discover that straight would happily 'use-package' it, but not in the least surprised that it didn't work.

It turns out that it's mirrored here: https://github.com/emacsmirror/vm and that's what straight's picking up. That tree, however, seems to need to have autotools called on it, then configure (with a bit of extra info to tie it into bbdb in my case).

And then, there are a couple bits that don't actually work; they removed the bundled vcard.el for reasons their commit doesn't specify, but didn't commit it out of the Makefile.in. Nor the vm-vcard.el that was using it..... There's also a use of &optional &rest ... that irritates emacs and that I've fixed before by just removing the &optional).

So, at a minimum seems like I should fork the repo, fix those bits, then have straight use my fork (and branch).

For experimenting, I've cloned the repo, run autoconf and then configure. It makes successfully, albeit without the bbdb bits. So in addition to asking about a straight-approved way of calling autoconf and then make, I suppose I should also ask if there's a non-ugly way to get at the path where straight has built bbdb for me?

Thanks

@raxod502
Copy link
Member

There is no user-facing way to get the build directory currently; see #274. You can use

(straight--build-dir "vm")

Perhaps you want something like

(defun my-vm-build (package &rest _)
  (when (string= package "vm")
    (let ((default-directory (straight--build-dir "vm")))
      (straight--get-call "autoconf")
      (straight--get-call "./configure")
      (straight--get-call "make"))))

(add-hook 'straight-use-package-pre-build-functions #'my-vm-build)

although it is completely untested -- you will have to spend some time playing around with things to get it to work how you want.

See #115 (as per https://github.com/dimitri/el-get/blob/5534e20b8a9d071f43285161a453924cc42ccd5b/recipes/vm.rcp) and #72 for proper support.

@hartzell
Copy link
Contributor Author

Neat, thank you. I have it [almost working], with this, which grabs the right branch of my fork of the project and builds it with the extra args to hook up bbd. BUT, see below

(defun my-vm-build (package &rest _)
  (when (string= package "vm")
    (let ((default-directory (straight--repos-dir "vm")))
      (straight--get-call "autoconf")
      (straight--get-call (concat default-directory "/configure")
                          (concat "--with-other-dirs=" (straight--build-dir "bbdb")))
      (straight--get-call "make"))))
(add-hook 'straight-use-package-pre-build-functions #'my-vm-build)

(use-package vm
  :straight (vm :type git :host github :repo "emacsmirror/vm"
                :fork (:host github
                             :repo "hartzell/vm"
                             :branch "wip")
                :no-byte-compile t
)
  :init
  (require 'cl)
  :commands (vm)
  :config
  ;;  [elided]
)

My first attempt, without the :no-byte-compile t bit, would hang up. If I killed it after a while, the next time I started emacs thigns seemed ok.

I ended up inserting (debug) at various points in the straight code and setting debug-on-quit to t and eventually figuring out that it was the byte compilation step and that I could disable it with the relevant knob.

But, there are a bunch of elc files sitting in the build directory courtesy of my/your hook function that I'd love to link into the build dir. Any way to do that?

@hartzell
Copy link
Contributor Author

On the other hand, I just set up the symlinks for the elc files between the build and repos directory and didn't notice an appreciable difference in startup times. Perhaps I should just declare victory and move on.....

@raxod502
Copy link
Member

You should be able to link the .elc files using a custom :files directive. It might be desirable to make it so that if the .elc files already exist, then they won't be recompiled even if you don't specify :no-byte-compile t. Feel free to open another issue if that feature is important to you.

Anything else troubling you?

@hartzell
Copy link
Contributor Author

I'll play with files. Thanks for all the hints and suggestions. Straight's great!

@hartzell
Copy link
Contributor Author

hartzell commented Jun 13, 2019

For posterity's sake (as if there are any other vm users running around...), here's what I ended up with:

(defun my-vm-build (package &rest _)
    (when (string= package "vm")
      (let ((default-directory (straight--repos-dir "vm")))
        (straight--get-call "autoconf")
        (straight--get-call (concat default-directory "/configure")
                            (concat "--with-other-dirs=" (straight--build-dir "bbdb")))
        (straight--get-call "make")))
    )
(add-hook 'straight-use-package-pre-build-functions #'my-vm-build)
(use-package vm
  :straight (vm :type git :host github :repo "emacsmirror/vm"
                :fork (:host github
                             :repo "hartzell/vm"
                             :branch "oldie")
                :no-byte-compile t
                :files (:defaults "lisp/*.elc")
                )
  :commands (vm)

  :init
  (require 'cl)
  :config
  ;; Make VM your default mail agent in Emacs
  (setq mail-user-agent 'vm-user-agent)
  ;; [and etc...]
  )

@hartzell
Copy link
Contributor Author

hartzell commented Jun 13, 2019

Ah, so one thing that I've noticed is that the autoconf/config/make cycle seems to get run every time I start up emacs. It'd be nice to use modified from the calling scope within my-vm-build, or something similar. I don't see any ways to do so that don't involve a bit of surgery inside straight-use-package.

Suggestions (I can put something together and PR it if it seems useful). I could pull the bit that provides the value for modified (e.g. lines 4512-4524) into a separate function, call it in straight-use-package and in my hook code? I could pass it (and other things) into the hook call? Other suggestions?

@hartzell hartzell reopened this Jun 13, 2019
@raxod502
Copy link
Member

The fact that the hook is run when the package is unmodified (and hence does not need to be rebuilt) is a bug. Feel free to submit a pull request fixing that. It's an easy change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants