Unix Programming - Simple Makefile question

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > February 2004 > Simple Makefile question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Simple Makefile question
bucket79

2004-02-19, 6:33 pm

Hi. I just got a simple question about makefile
There's file 1_1.c and INC, LIB declaration is fine.
and i wanna make executable 1_1.out
so this makefile will work fine

OBJ = 1_1.out

..SUFFIXES: .c .o

all:$(OBJ)

..c.o:
$(CC) -c $(INC) $<
..o.out:
$(CC) -o $@ $? $(LIB)
rm $<

but what if i wanna make excutable 1_1 ?
i mean, how can i set a implicit rule like .c.o when output file has no
extension
i already tested

..o:
..o.:

but it doesn't work either, surely
Wolfgang Kaufmann

2004-02-19, 11:33 pm

* Thus spoke bucket79 <bucket79@daum.net>:

Hallo,

> Hi. I just got a simple question about makefile
> There's file 1_1.c and INC, LIB declaration is fine.
> and i wanna make executable 1_1.out

[...]
> but what if i wanna make excutable 1_1 ?
> i mean, how can i set a implicit rule like .c.o when output file has no
> extension


Do you mean something like:

| CC = g++
| LD = g++
| CC_FLAGS = -Wall -W -ggdb -pg -c -g -DNDEBUG
| LD_FLAGS = -ggdb -o $(EXEC)
| ##EXEC = 1_1.out
| EXEC = 1_1
|
| SOURCES = foo.cpp bar.cpp
|
| ALL_OBJS = foo.o bar.o
|
| all : $(ALL_OBJS)
| $(LD) $(LD_FLAGS) $(ALL_OBJS)
|
| %.o : %.c
| $(CC) $(CC_FLAGS) $(LD) -o $@ $<



Wolfgang.
--
"I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
-- Maurice Wilkes, 1947
bucket79

2004-02-22, 1:33 pm

Wolfgang Kaufmann <wk-usenet-200402@theparallax.com> wrote in message news:<slrnc3c14o.2qm.wk-usenet-200402@news.theparallax.net>...
> * Thus spoke bucket79 <bucket79@daum.net>:
>
> Hallo,
>
> [...]
>
> Do you mean something like:
>
> | CC = g++
> | LD = g++
> | CC_FLAGS = -Wall -W -ggdb -pg -c -g -DNDEBUG
> | LD_FLAGS = -ggdb -o $(EXEC)
> | ##EXEC = 1_1.out
> | EXEC = 1_1
> |
> | SOURCES = foo.cpp bar.cpp
> |
> | ALL_OBJS = foo.o bar.o
> |
> | all : $(ALL_OBJS)
> | $(LD) $(LD_FLAGS) $(ALL_OBJS)
> |
> | %.o : %.c
> | $(CC) $(CC_FLAGS) $(LD) -o $@ $<
>
>
>
> Wolfgang.



thanks for reply
but i wanna know the case not using variables like LD_FLAGS but
implicty rule like .c.o

ps. sorry, i posted my original message in wrong thread
i pushed 'reply' button rather than 'post new message' ;(
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com