[erlang-questions] rebar make

jixiuf <>
Tue Apr 10 04:45:34 CEST 2012

how about :

(defun erlang-root-by-makefile ()
  "Look for Makefile file to find project root of erlang application.
if found return the directory or nil
  (let ((erlang-root (locate-dominating-file default-directory "Makefile")))
    (if erlang-root
        (expand-file-name erlang-root)
      (setq erlang-root (locate-dominating-file default-directory "makefile"))
      (if erlang-root
          (expand-file-name erlang-root)

(defun erlang-make()
  "run make command at project root directory"
  (let ((project-root ( erlang-root-by-makefile))
        (compile-command compile-command))
    (when project-root
      (setq compile-command (concat "make --directory=" project-root))
      ;; copy src/*.app.src to ebin/*.app
      ;; if you do this in your Makefile  ,you may delete the (dolist)
      (dolist (filename (directory-files (expand-file-name "src/" project-root)))
         ((string=  (file-name-extension filename) "app")
          (copy-file (expand-file-name (concat "src/" filename) project-root)
                     (expand-file-name (concat "ebin/" filename) project-root) t) )
         ((string=  (file-name-extension filename) "src")
          (copy-file (expand-file-name (concat "src/" filename) project-root)
                     (expand-file-name (concat "ebin/" (file-name-sans-extension  filename)) project-root) t))))
    (call-interactively 'compile)

More information about the erlang-questions mailing list