Eu mudei o makefile um pouco. A principal diferença é
dbug:
@$(MAKE) CFLAGS="$(DBCFLAGS)" LDFLAGS="$(DBLDFLAGS)"
Então, se você executar make dbug
CFLAGS e LDFLAGS serão redefinidos novamente.
CC := gcc
CFLAGS = -O2 -c -Wall -Werror
DBCFLAGS = $(CFLAGS) -O0 -DDEBUG -g
LDFLAGS =
DBLDFLAGS = $(LDFLAGS) -g
LAB := lab4
PROJDIRS := .
SRCFILES := $(shell find $(PROJDIRS) -maxdepth 1 -type f -name "*.c")
HDRFILES := $(shell find $(PROJDIRS) -maxdepth 1 -type f -name "*.h")
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
TSTFILES := $(patsubst %.c,%_t,$(SRCFILES))
AUXFILES := makefile README
ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
-include $(DEPFILES) $(TSTDEPFILES)
.PHONY: all clean dist check testdrivers todolist
all: $(LAB)
dbug:
@$(MAKE) CFLAGS="$(DBCFLAGS)" LDFLAGS="$(DBLDFLAGS)"
$(LAB): $(OBJFILES)
$(CC) $(LDFLAGS) $(OBJFILES) -o $@
%.o: %.c makefile
$(CC) $(CFLAGS) $< -o $@
todolist:
-@for file in $(ALLFILES:makefile=); do grep -H -e TODO -e FIXME $$file; done; true
dist:
@tar czf /mnt/backup/cis27/$(LAB)-'date +%m%d%y.%H%M'.tar.gz $(ALLFILES)
clean:
-rm *.o *~ *.d