在emacs中管理makefile的方法(很土)

Vim、Emacs配置和使用
回复
yupeng820921
帖子: 94
注册时间: 2009-02-25 19:44

在emacs中管理makefile的方法(很土)

#1

帖子 yupeng820921 » 2009-08-23 16:45

emacs提供了compile指令来进行编译,但它只能从当前目录下找makefile,每次编译的时候都得想办法切换到makefile所在的目录,很不方便。

我自己写了个小程序,让compile总是到指定目录下去寻找makefile,然后执行指定的编译指令。方法很土很直接。

安装很简单,把yp-make.el丢到你放扩展的路径下,在.emacs中加上(require 'yp-make) 就可以了。

在yp-make.el中有一个变量和一个函数,需要你自己修改,下面是我自己用的:

;; modify the number for yourself to select which project you want to build.
(setq yp-make-select 2)

;; you should modify the below function yourself, add your own porject path and compile command
(defun yp-make-do-select ()
(cond
((= 0 yp-make-select)
(setq yp-make-dir "~/lisp/cedet2/Makefile")
(setq yp-make-command "make"))
((= 1 yp-make-select)
(setq yp-make-dir "~/work/arm-linux/Android_install/Source/kernel.git/Makefile")
(setq yp-make-command "make uImage"))
((= 2 yp-make-select)
(setq yp-make-dir "~/work/arm-linux/Android_install/Source/kernel.git/Makefile")
(setq yp-make-command "make clean"))
((= 3 yp-make-select)
(setq yp-make-dir "~/work/arm-linux/android_work/kernel/Makefile")
(setq yp-make-command "make -i uImage ; cp arch/arm/boot/uImage ~/tftpboot/uImage"))
)
)

把你makefile的地址和你希望执行的编译指令,比如“make“ 或"make -i"之类的东西分别赋给yp-make-dir和yp-make-command,然后通过设置yp-make-select选择你想使用哪一组makefile地址和编译指令。

每当你改变yp-make.el的时候,执行yp-make-save-and-execute可以使改动生效并进行编译。
设置好一组make指令之后,执行yp-make-execute可以保存当前buffer然后进行编译。
yp-make-add-select 和 yp-make-dec-select可以增加或减少yp-make-select变量的值然后进行编译。
附件
yp-make.el.gz
(1.52 KiB) 已下载 25 次
anewbie
帖子: 159
注册时间: 2009-02-24 19:39

Re: 在emacs中管理makefile的方法(很土)

#2

帖子 anewbie » 2009-08-23 19:47

不错,顶下原创,另推荐几个现成的。
1 EDE,得读上一会儿文档,但可以和 semantic 配合,比较强大;
2 mk-project.el,比较简单,可以递归向上寻找 makefile.
回复