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: stan
Subject: Re: help with makefile command line
Date: Fri, 28 Mar 2008 15:33:25 -0500
User-agent: slrn/0.9.8.0 (Linux)

Richard G Riley wrote:
> stan <smoore@exis.net> writes:
>
>> Richard G Riley wrote:
>>> stan <smoore@exis.net> writes:
>>>
>>>> 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 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))))))
>>>> <snip>
>>>>
>>>> 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
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
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
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.
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.

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
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.

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.

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)
>
>>>
>>>>
>>>> Another idea, if you don't like what Eli suggested earlier is to come up
>>>> with a makefile template and use auto insert. I have a template that I
>>>> only need to basically change the list of files in and it save a lot of
>>>> time during the compile, run. scream. debug, edit cycle.
>>>>
>>>> Finally, you can edit the compile command for all time but it seems like
>>>> a bad idea.
>>>
>>> I'm not sure I understand. I have makefiles for most of my projects. If
>>> I don't have one it builds a compile and link command based on the c
>>> file name which is what you requested.
>>>
>>> Sorry I can't be more help. Did you try my code?
>>
>> See above. I didn't snip this time for fear of losing you again :)


reply via email to

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