From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard G Riley Newsgroups: gmane.emacs.help Subject: Re: help with makefile command line Date: Sat, 29 Mar 2008 14:18:33 +0100 Organization: http://www.gnu.org/software/emacs/ Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206798043 11829 80.91.229.12 (29 Mar 2008 13:40:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Mar 2008 13:40:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 29 14:41:14 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JfbJ1-0002WJ-QJ for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Mar 2008 14:41:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JfbIQ-0002pI-6A for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Mar 2008 09:40:34 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 132 Original-X-Trace: feeder.motzarella.org U2FsdGVkX1+dcWe5EGuI0RWoDY8UdEPC4hj0oshcmVtldW99I872yIm9+cc1cBdcSmmXlyT61AA72fopjORKckcm/GCxSF8IS3aJ5XjcwrFFfFPqjZz7ABn5Fx5NbEqtcIgSkE9wcoMEW+emLJn9VQ== Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Sat, 29 Mar 2008 13:18:37 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18VLl/WUWdNiQ6cyqZJNsRy7GYv51c6+PUMNwhaLB126A== Cancel-Lock: sha1:v5T4wS+5UmDLJsY4uQ0rkwX6tUc= User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) Original-Xref: shelby.stanford.edu gnu.emacs.help:157419 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:52789 Archived-At: stan writes: > Richard G Riley wrote: >> stan writes: >> >>> Richard G Riley wrote: >>>> stan writes: >>>> >>>>> Richard G Riley wrote: >>>>>> "Balaji V. Iyer" 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 " >>>>>>> >>>>>>> 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)))))) >>>>> >>>>> >>>>> Seems like it might be easier to write a makefile :) >>>> >>>> Sorry. I'm not sure I understand. You snipped all my code. Did it not >>>> work for you? I use it on a daily basis. >>> >>> Sorry I confused with my snip. I'm not the op. I have my setup working >>> pretty much the way I want ( is anyone ever really satisfied?) >> >> But what has your setup and they way you want it got to do with the OP >> wanting auto selection between Makefile and the gcc direct approach? > > The op originally asked how to replace make -k with gcc -ansi -O4 -Wall > file because he didn't have a makefile. He asked for ideas. >>>> >>>> Yes, I do know that. But why would I do that when I can automate it as >>>> above depending on whether there is a Makefile or not? >>> >>> Again, our streams got crossed at my snip. Both of our comments should >>> have been directed to the OP and not each other. >> >> My comments were directed at you. It was your post I replied to >> above. You replied to me. I replied to you. > > I wasn't replying to you, as I said the streams got crossed. You might > note the snip started with your reply and left the op attempted > solution. >> >> I am still not sure what points you were trying to make though. Did you >> understand the OPs want better now? > > I understood from the beginning. Several options were offered by others > that didn't involve hard coding a choosable make or gcc command. Hard Nothing is hard coded that can not be undone at compile time. You can choose not to use mycompile ... > coding the compiler as the op attempted to do seems to me to have the > disadvantage of hard coding the compiler options also. In a case where As most makefiles do - but thats a straw man since you can as easily use system variables in them. As I do. > you dont want the hard coded it seems reasonable to change them on a > session basis, or try some other option. > > Your code also requires changeing the code to get a different set of > options in the generated makefile. Personally I prefer the insert a What generated makefile? It doesn't generate any makefiles. > template approach because I prefer simply editing the template when I > update the baseline. I realize that your code generates a baseline > Makfle that can be modified, I'm refering to changes in the baseline. No it doesn't. > For example I jump between cygwin and linux with diferent baseline > makefiles and with your method I would add to the headache of > maintaining a .emacs for both systems. Hard coding either a gcc command > or a baseline makefile seems to lose flexibility to me. I'm not sure I follow you with this hard coded stuff. Its a baseline. All functions and utilities are "hard coded" - in this case using a makefile on a C project if it exists is hardly hard coding anything. Makefiles are an integral part of C development. > > For me at least your way seems to involve some extra steps when I update > my standard Makefile. I.e. generate the makefile, run to test. locate Again. it doesn't generate any makefile. > problem, modify code, generate makefile, ... With the insert template > method I simply modify Makefile, run to test, locate problem, modify > Makefile. When satisfied, replace template Makefile. Seems like less > steps and cleaner to me. I hardly ever modify a base makefile. I use a template, add the target and source files and bang - its there for pretty much ever. > > What works for me might not be best for others though so I'm a firm > believer in options. The more the merrier most of the time. Yes. I agree. > > I saw the op's issue as how to solve compile without a makefile and you > aparrently see the issue as how to modify .emacs. Different > perspectives, different solution options. That's a good thing.(tm) No. I gave a solution that works with or without a makefile. Most "custom" things in emacs require a modification of a utility el or the .emacs. I'm somewhat confused as to your understanding of the function/example I provided. Anyway, I guess we've done this to death.