LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   makefile for debug and release version (https://www.linuxquestions.org/questions/programming-9/makefile-for-debug-and-release-version-549411/)

nikoladsp 04-27-2007 03:46 AM

makefile for debug and release version
 
hi,
i would like to write one Makefile with capabilities to build debug and release version of one program, ie:

Code:

CC                = g++
BIN                = ./bin
CFLAGS                = -Wall
RM                = rm -rf

       
debug: main.cpp
        CFLAGS="$CFLAGS -g -ggdb3"
        $(CC) $(CFLAGS) -o $(BIN)/cygtestd main.cpp
       
release: main.cpp
        CFLAGS="$CFLAGS -O2"
        $(CC) $(CFLAGS) $(BIN)/cygtest main.cpp
       
clean:
        $(RM) $(BIN)/*.o $(BIN)/*.exe

or something like this...i consulted GNU Makefile, without success :cry: can somebody help?

10x in advance...

ps
i am using eclipse + cygwin.

nikoladsp 04-27-2007 04:30 AM

i will reply to myslef, but with another 2 questions :study:
Code:

CC        = g++
CFLAGS        = -Wall
RM        = rm -rf

BIN        = ./bin
OUT        =
DEBUG        = yes

ifeq ($(DEBUG),yes)
        CFLAGS += -ggdb3
        OUT = $(BIN)/cygtestd.exe
else
        CFLAGS += -O2
        OUT = $(BIN)/cygtest.exe
endif
       
all: main

main: main.o
        $(CC) $(BIN)/main.o -o $(OUT)
       
main.o: main.cpp
        $(CC) $(CFLAGS) -c main.cpp -o $(BIN)/main.o

clean:
        $(RM) $(BIN)/*.o $(OUT)

1. is this solution is OK to use?
2. how to make case-insensitive comparation in ifeq(...)?

10x


All times are GMT -5. The time now is 12:47 AM.