0

I sometimes want to keep my build directory separate from my source directory (eg I'm using the same source NFS mounted to multiple different build environments). In this configuration I can't use flymake because it can't find the Makefiles. Can anyone recommend a good approach to getting flymake to find the correct build dir and run make -C check-syntax? I feel like this must be a common problem but google has failed me here.

William Pursell
  • 204,365
  • 48
  • 270
  • 300
brendan
  • 2,643
  • 1
  • 20
  • 13

1 Answers1

0

For the record, I ended up doing this (improvements welcome):

(defadvice flymake-find-buildfile
  (around advice-find-makefile-separate-obj-dir
          activate compile)
  "Look for buildfile in a separate build directory"
  (let* ((source-dir (ad-get-arg 1))
     (bld-dir (ac-build-dir source-dir)))
    (ad-set-arg 1 bld-dir)
    ad-do-it))

(defun ac-find-configure (source-dir)
  (locate-dominating-file source-dir "configure"))

(defvar project-build-root nil
  "top build directory of the project")

(defun ac-build-dir (source-dir)
  "find the build directory for the given source directory"
  (condition-case nil
      (let* ((topdir (ac-find-configure source-dir))
         (subdir (file-relative-name (file-name-directory source-dir) topdir))
         (blddir (concat (file-name-as-directory project-build-root) subdir)))
        blddir)
    (error source-dir)))

and setting project-build-root to my build directory in my top source directory .dir-locals.el

brendan
  • 2,643
  • 1
  • 20
  • 13