help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how does .default work ?


From: Matthias Odisio
Subject: how does .default work ?
Date: Mon, 31 Mar 2003 17:05:55 +0200 (CEST)

Hi all,

After immerging myself in the manual and checking the archive, I'm still 
unable to get the following makefile works as I'd want :

*************************************
.DEFAULT: all
.PHONY: all

DFLAGS := -DVERBOSE

MFLAG := -MM
CPPFLAGS := $(DFLAGS) -ISome_path
CC := gcc
CFLAGS := -g -Wall
LNK := gcc
LDFLAGS := -g -Wall -LSome_another_path

LIBS := -lm -lGL -lGLU
ROBJ := _lib
SRC := file1.c file2.c
OBJ := $(addprefix $(ROBJ)/,$(SRC:.c=.o))

PROG := $(ROBJ)/my_prog

$(ROBJ)/%.o: %.c
        $(CC) -c -o $@ $(CFLAGS) $(CPPFLAGS) $<

%.d: %.c
        @ echo "Generating dependencies for $<"; \
        set -e; $(CC) $(MFLAG) $(CPPFLAGS) $< \
        | sed 's/\($*\)\.o[ :]*/$(ROBJ)\/\1.o $@ : /g' > $@; \
        [ -s $@ ] || rm -f $@

-include $(SRC:.c=.d)

all: $(PROG)
        @ echo '@@@@@ Compilation successful @@@@@'

$(PROG): $(OBJ)
        $(LNK) $(LDFLAGS) -o $@ $^ $(LIBS)
********************************

$ make
        -> only _lib/file1.o is built
$ make all
        -> the whole project is built (_lib/file1.o _lib/file2.o _lib/my_prog)
$ make foo
        -> make: *** No rule to make target `foo'.  Stop.

What should I do so as 'make' and 'make foo' both result in 'make all' ?

Any help would be appreciated!

Regards,

Matthias

PS: Please cc me on reply because I've not subscribed to the mailing list.





reply via email to

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