* Making "make" auto-strip and auto-clean
@ 2006-02-26 4:05 Shriramana Sharma
2006-02-26 8:56 ` wwp
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Shriramana Sharma @ 2006-02-26 4:05 UTC (permalink / raw)
To: Linux C Programming List
I would like make to always
1. strip the executable it created
2. remove the *.o files it created
after it has compiled the target executable. How do I do this? What do I add
to the makefile? The current default command I am using is:
pan: pan.o libswe.a
gcc -g -O2 -o pan pan.o -L. -lswe -lm
Thanks.
--
Tux #395953 resides at http://samvit.org
playing with KDE 3.51 on SUSE Linux 10.0
$ date [] CCE +2006-02-26 W08-7 UTC+0530
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Making "make" auto-strip and auto-clean
2006-02-26 4:05 Making "make" auto-strip and auto-clean Shriramana Sharma
@ 2006-02-26 8:56 ` wwp
2006-02-26 12:21 ` Shriramana Sharma
2006-02-26 14:10 ` leslie.polzer
2006-02-26 15:54 ` Glynn Clements
2 siblings, 1 reply; 5+ messages in thread
From: wwp @ 2006-02-26 8:56 UTC (permalink / raw)
To: linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 692 bytes --]
Hello Shriramana Sharma,
On Sun, 26 Feb 2006 09:35:27 +0530 Shriramana Sharma <samjnaa@gmail.com> wrote:
> I would like make to always
>
> 1. strip the executable it created
> 2. remove the *.o files it created
>
> after it has compiled the target executable. How do I do this? What do I
> add to the makefile? The current default command I am using is:
>
> pan: pan.o libswe.a
> gcc -g -O2 -o pan pan.o -L. -lswe -lm
First, if you always want to strip, no need to add -g.
Then:
all: pan strip clean
pan: pan.o libswe.a
gcc -O2 -o $@ pan.o -L. -lswe -lm
strip: pan
strip $<
clean:
-rm -f pan.o
Or something similar..
Regards,
--
wwp
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Making "make" auto-strip and auto-clean
2006-02-26 4:05 Making "make" auto-strip and auto-clean Shriramana Sharma
2006-02-26 8:56 ` wwp
@ 2006-02-26 14:10 ` leslie.polzer
2006-02-26 15:54 ` Glynn Clements
2 siblings, 0 replies; 5+ messages in thread
From: leslie.polzer @ 2006-02-26 14:10 UTC (permalink / raw)
To: Shriramana Sharma; +Cc: Linux C Programming List
[-- Attachment #1: Type: text/plain, Size: 693 bytes --]
Hello Shiramana,
On Sun, Feb 26, 2006 at 09:35:27AM +0530, Shriramana Sharma wrote:
> I would like make to always
>
> 1. strip the executable
> 2. remove the *.o files it created
>
> after it has compiled the target executable. How do I do this? What
> do I add to the makefile? The current default command I am using is:
>
> pan: pan.o libswe.a gcc -g -O2 -o pan pan.o -L. -lswe -lm
I'm not sure I understand your question.
Here's my answer, though:
pan: pan.o libswe.a
gcc -g -O2 -o pan pan.o -L. -lswe -lm
strip pan
rm -f *.o
Leslie
--
gpg --keyserver pgp.mit.edu --recv-keys 0x52D70289
http://nic-nac-project.de/~skypher/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Making "make" auto-strip and auto-clean
2006-02-26 4:05 Making "make" auto-strip and auto-clean Shriramana Sharma
2006-02-26 8:56 ` wwp
2006-02-26 14:10 ` leslie.polzer
@ 2006-02-26 15:54 ` Glynn Clements
2 siblings, 0 replies; 5+ messages in thread
From: Glynn Clements @ 2006-02-26 15:54 UTC (permalink / raw)
To: Shriramana Sharma; +Cc: Linux C Programming List
Shriramana Sharma wrote:
> I would like make to always
>
> 1. strip the executable it created
> 2. remove the *.o files it created
>
> after it has compiled the target executable. How do I do this? What do I add
> to the makefile?
CC = gcc
CFLAGS = -g -O2
LDFLAGS = -L.
LOADLIBES = -lswe -lm
default: pan strip clean
pan: pan.o libswe.a
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LOADLIBES)
strip: pan
strip $<
clean:
rm -f *.o
That way, "make" with no arguments will build the executable, strip it
and remove the object files, while you can perform individual steps by
specifying specific targets. E.g. to build the executable without
stripping or cleaning (once the project becomes non-trivial, you
/will/ want to do this), you can use "make pan".
A Makefile isn't supposed to just run a specific sequence of commands
every time; you can use a script for that. It's meant to allow you to:
+ Perform incremental recompilation (which requires leaving the
object files around).
+ Perform partial compilation (which requires breaking the
build process into individual targets).
+ Compile with non-default settings (which requires using variables
instead of hardcoding programs and options into the commands).
+ Handle large numbers of files without having to write a rule for
every file (by using pattern rules and automatic variables).
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-02-26 15:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-26 4:05 Making "make" auto-strip and auto-clean Shriramana Sharma
2006-02-26 8:56 ` wwp
2006-02-26 12:21 ` Shriramana Sharma
2006-02-26 14:10 ` leslie.polzer
2006-02-26 15:54 ` Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).