LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-10-2005, 01:55 PM   #1
cam2004
LQ Newbie
 
Registered: Aug 2004
Posts: 4

Rep: Reputation: 0
Selecting a makefile in emacs


Hello all,

I've been a linux developer for a good while but the environment I've moved to recently means that I have been forced to use emacs on a fairly large C project. I'm finally starting to see what all the fuss is about - its exteremely powerful and I have a nice feeling that wherever I go, knowledge of this setup will be useful to me.

I have one outstanding question though: I am happy about M-x compile to start gcc but I want to point it at a makefile, rather than enter a single make target - is there a way to tell emacs about my makefile?

I should add that I have a fairly clean install of GNU emacs and would rather avoid having to install other macros - though I'm open to suggestions.

NB - although there are dozens of emacs tutorials out there, none of them have answered this question and almost all just mention the basic M-x compile command.

Thanks for any insight,
cam
 
Old 05-10-2005, 05:16 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Not quite sure how your emacs is set-up.

If I do Alt-x compile it prompts me for a compile-command,
which is preset to be make -k?

If it weren't I could overwrite it with exactly that. The only
downside: I need to be in the source-dir with the Makefile
and source.


Cheers,
Tink
 
Old 05-10-2005, 05:55 PM   #3
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
When I work on a project where all source files are in subdirectory relative to the Makefile, I pass the following
to make when compiling from Emacs so that make can find the Makefile:
Code:
-C ..
HTH
 
Old 05-10-2005, 06:31 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Like Tinkster already said, after "M-x compile" you can change the command in the mini-buffer. Like: make -f /path/to/your/Makefile-custom


I've put the added line in my $HOME/.emacs file:
Code:
(define-key ctl-x-map "\M-m" 'compile)
This enables me (after restarting emacs) to use "C-x M-m" as a shortcut for "M-x compile".

Last edited by Hko; 05-10-2005 at 06:32 PM.
 
Old 05-11-2005, 07:19 AM   #5
cam2004
LQ Newbie
 
Registered: Aug 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Hivemind
When I work on a project where all source files are in subdirectory relative to the Makefile, I pass the following
to make when compiling from Emacs so that make can find the Makefile:
Code:
-C ..
HTH
Great - this is the one. I add -C /path/to/dir-with-Makefile and everything is fine.

Next question (!) how do I set this up be my default compile argument?

Thanks a lot for the responses.

cam
 
Old 05-11-2005, 08:04 AM   #6
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
Glad I could help! If you want to change the default compile command from
Code:
make -k
to
Code:
make -k -C ..
you can add the following to your .emacs-file:
Code:
(setq compile-command "make -k -C .. ")
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is the .emacs file in the emacs source code tarball? aizkorri Programming 2 01-13-2007 02:05 PM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM
Makefile with emacs editor problem? varala_kanth Linux - Software 0 04-03-2004 02:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration