|
From: | Kevin Rodgers |
Subject: | Re: help with makefile command line |
Date: | Sat, 29 Mar 2008 09:33:15 -0600 |
User-agent: | Thunderbird 2.0.0.12 (Macintosh/20080213) |
stan wrote:
Richard G Riley wrote:"Balaji V. Iyer" <bviyer@ncsu.edu> writes:Hello Everyone, I use the compile option extenstively in emacs. When I type "M-x compile" the default line is "make -k" Many times I do not have a make file thus I would lke the default line to be"gcc -ansi -O4 -Wall <c_source_file>" How do I do this? I tried the following command but it doesn't seem to work (If anyonehave a better idea please let me know).(function(lambda () (unless (or (file-exists-p "makefile") (file-exists-p "Makefile")) (setq compile-command (concat "gcc -Wall -O3 -o" (file-name-sans-extension (file-name-nondirectory buffer-file -name)) " " (file-name-nondirectory buffer-file-name))))))<snip>Seems like it might be easier to write a makefile :)
You don't need to write a Makefile, because make has built-in rules that handle this. (add-hook 'c-mode-hook (lambda () (set (make-local-variable 'compile-command) (format "make %s" (file-name-sans-extension (file-name-nondirectory buffer-file-name)))))) Just set the CC=gcc and CFLAGs="-Wall -O3" environment variables, and voila! -- Kevin Rodgers Denver, Colorado, USA
[Prev in Thread] | Current Thread | [Next in Thread] |