help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with makefile command line


From: Richard G Riley
Subject: Re: help with makefile command line
Date: Thu, 27 Mar 2008 18:28:20 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

"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 anyone
> have 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))))))
>  
>  
>  
> Any help is greatly appreciated.
>  
> Thanks,


Here is the section from my .emacs which might be of help to you - see
the f10 binding to mycompile.


,----
| (defun my-c-init()
| 
|   (line-number-mode 1)
| 
|   (setq compilation-window-height 16)
|   (setq compilation-finish-functions
|       (lambda (buf str)
|         (if (string-match "exited abnormally" str)
| 
|             ;;there were errors
|             (message "compilation errors, F11 to goto next error.")
| 
|           ;;no errors, make the compilation window go away in 0.5 seconds
|           ;;        (run-at-time 5.0 nil 'delete-windows-on buf)
|           (message "NO COMPILATION ERRORS!"))))
|     
| 
|   (c-set-style "linux")
| 
|   (setq gdb-show-main t)  
|   (setq gdb-many-windows t)
| 
|   (let ((dl '(
|               ([f1] . jump-man-page)
| ;              ([backtab] . semantic-complete-analyze-inline)
|               ;;            ([f5] . find-tag-noconfirm)
|               ([f6] . find-tag-repeat)
|               ([f7] . pop-tag-mark)
|               ([f2] . gdb-restore-windows)
|               ([f3] . cscope-find-global-definition-no-prompting)
|               ([f4] . repeat)
|               ([f10] . (lambda()(interactive)(mycompile)))
|               ([f11] . next-error)
|               ([f12] . gdb))))
|     (dolist (i dl)
|          
|       (define-key c-mode-base-map (car i) (cdr i))
|       ;;       (define-key c-mode-map (car i) (cdr i))
|       ;;       (define-key c++-mode-map (car i) (cdr i))
|       ))
| 
|   (define-key c-mode-map
|     "\C-c\C-f"
|     'php-search-documentation)
| 
|   (define-key c-mode-map
|     "\C-c\C-m"
|     'php-browse-manual)
| 
|   (define-key c-mode-map
|     "\C-c\C-c"
|     'c-browse-faq)
| 
|   (global-unset-key "\M-/")
|   (show-paren-mode 1)
| 
| )
| 
| (add-hook 'c-mode-common-hook 'my-c-init)
| 
| (defun mycompile()
| 
|   (unless (or (file-exists-p "makefile")
|             (file-exists-p "Makefile"))
|     (set (make-local-variable 'compile-command)
|        (let ((file (file-name-nondirectory buffer-file-name)))
|          (format "%s -o %s %s %s %s %s"
|                  (or (getenv "CC") "gcc")
|                  (file-name-sans-extension file)
|                  (or (getenv "GTKFLAGS") "")
|                  (or (getenv "CPPFLAGS")"-DDEBUG=9")
|                  (or (getenv "CFLAGS") "-std=c99 -pedantic -Wall -Wshadow 
-Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion  
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations 
-Wredundant-decls -Wnested-externs -Winline -g")
|                  file)))
|     
|     )
|   (compile compile-command)
|   )
| 
`----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]