# Makefile for Checker
# 
#

# Your compiler
CC = gcc
AS = as

# Flags for your compiler.
# Those are for Gcc
# O2 means high optimization and Wall enables (nearly) all warnings.
# please, do not add -fomit-frame-pointer
CWARNINGS = -Wall -Wstrict-prototypes
CPPFLAGS = -I. -I.. -I../lib
CFLAGS = -O2 -g $(CWARNINGS)

# LIB is the name of the library file
# LIBOBJ is an object file, that contains all the library for safety link.
LIB= libmalloc.o

OBJS  = malloc.o free.o realloc.o checker.o garbage.o maccess.o calloc.o \
        memalign.o
#	mstats.o cfree.o 

OBJS1 = mcheck.o mtrace.o

TARGET=$(LIB)

all: $(TARGET)

$(LIB): .depend $(OBJS)
	$(LD) -r -o $(LIB) $(OBJS)
#	$(AR) usvc $(LIB) $(OBJS)
#	ranlib $(LIB)

.depend: Makefile
	@echo "You have not make the dependency file"	# have a beep
	@echo "Try 'make dep'"

try_malloc : try_malloc.o ../libchecker.o # $(LIB) ../lib/vprintf.o
	gcc -o try_malloc try_malloc.o ../libchecker.o libtermcap.a
#	gcc -o try_malloc try_malloc.o $(LIB) -g libtermcap.a ../lib/vprintf.o

clean:
	$(RM) -f core *.o a.out 
	$(RM) -f $(LIBMCHECK) $(LIB) 
	$(RM) -f .depend *~ try_malloc

dep:
	$(CPP) -M *.c $(CPPFLAGS) > .depend

.PHONY: dep clean all

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
