all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* gcc on xemacs
@ 2005-06-06  6:54 arya.punit
  2005-06-06  7:40 ` Floyd L. Davidson
  2005-06-06 16:54 ` Kevin Rodgers
  0 siblings, 2 replies; 3+ messages in thread
From: arya.punit @ 2005-06-06  6:54 UTC (permalink / raw)


hi,

how do i compile a single c/c++ file using gcc on xemacs in the
minibuffer. on clicking compile in menubar i get "make -k" in
minibuffer, but i want to change this command permanently so that it
displays "gcc -Wall" followed by the current active buffer file.c or
file.cpp. i donot know howto edit that custom settings elisp file in a
texteditor.

thanks anyway.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc on xemacs
  2005-06-06  6:54 gcc on xemacs arya.punit
@ 2005-06-06  7:40 ` Floyd L. Davidson
  2005-06-06 16:54 ` Kevin Rodgers
  1 sibling, 0 replies; 3+ messages in thread
From: Floyd L. Davidson @ 2005-06-06  7:40 UTC (permalink / raw)


arya.punit@gmail.com wrote:
>hi,
>
>how do i compile a single c/c++ file using gcc on xemacs in the
>minibuffer. on clicking compile in menubar i get "make -k" in
>minibuffer, but i want to change this command permanently so that it
>displays "gcc -Wall" followed by the current active buffer file.c or
>file.cpp. i donot know howto edit that custom settings elisp file in a
>texteditor.

That certainly can be done, but it really is not a very good
idea, simply because it is *way* too restrictive.

It means, for example, that you can't change the options given
to gcc, and trust me that -Wall is *not* what you really want to
run gcc with, normally.  You can't compile multi-file programs,
for example.  You can't turn on any of the several other options
that you really should be running gcc with almost by default.

But worse yet, gcc would be the *only* command you could compile
with!  Bad idea.

If you leave it at "make -k" you merely need to have a skeleton
Makefile somewhere that you can copy into any directory where you
want to run a compile.  It could indeed have "gcc -Wall" as the
default command, though I would suggest something like:

  gcc -g -O -pipe -ansi -pedantic -Wall -W \
      -Wcast-align -Wcast-qual -Wshadow -Wnested-externs \
      -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes \
      -Wbad-function-cast -Wmissing-declarations  -c

would be better, and that the top line part would be the minimum
to use as a default.

But even more, gcc is not the only "compile" you might want to do
from within (X)Emacs.  For example, LateX or TeX documents, and
perhaps other programs such as dvi2ps or ghostscript are all things
which lend themselves to processing with a complex set of commands
that can be reduced to "make -k" with a useful Makefile.

By having a generic command like "make -k" you can use either a
nice simple default Makefile, or if the occassion demands, you can
use a very complext Makefile.  That's functionality worth keeping.

-- 
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc on xemacs
  2005-06-06  6:54 gcc on xemacs arya.punit
  2005-06-06  7:40 ` Floyd L. Davidson
@ 2005-06-06 16:54 ` Kevin Rodgers
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2005-06-06 16:54 UTC (permalink / raw)


arya.punit@gmail.com wrote:
 > how do i compile a single c/c++ file using gcc on xemacs in the
 > minibuffer. on clicking compile in menubar i get "make -k" in
 > minibuffer, but i want to change this command permanently so that it
 > displays "gcc -Wall" followed by the current active buffer file.c or
 > file.cpp. i donot know howto edit that custom settings elisp file in a
 > texteditor.

,----[ C-h v compile-command RET ]
| compile-command's value is "make -k "
|
| Documentation:
| *Last shell command used to do a compilation; default for next 
compilation.
|
| Sometimes it is useful for files to supply local values for this variable.
| You might also use mode hooks to specify it in certain modes, like this:
|
|     (add-hook 'c-mode-hook
|        (lambda ()
| 	 (unless (or (file-exists-p "makefile")
| 		     (file-exists-p "Makefile"))
| 	   (set (make-local-variable 'compile-command)
| 		(concat "make -k "
| 		        (file-name-sans-extension buffer-file-name))))))
|
| You can customize this variable.
|
| Defined in `compile'.
`----

I think you want something like:

(add-hook 'c-mode-hook
           (lambda ()
             (set (make-local-variable 'compile-command)
                  (format "gcc -Wall %s.o"
                          (file-name-sans-extension
                           (file-name-nondirectory buffer-file-name))))))

Although make's default rules and macros will work:

(add-hook 'c-mode-hook
           (lambda ()
             (set (make-local-variable 'compile-command)
                  (format "make %s.o"
                          (file-name-sans-extension
                           (file-name-nondirectory buffer-file-name))))))

in conjunction with these shell settings:

CC=gcc; export CC
CFLAGS=-Wall; export CFLAGS

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-06 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06  6:54 gcc on xemacs arya.punit
2005-06-06  7:40 ` Floyd L. Davidson
2005-06-06 16:54 ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.