# 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
CPPFLAGS = -I. -I.. -I../lib
CFLAGS = -O2 -Wall -g

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

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

OBJS1 = mcheck.o mtrace.o

TARGET=$(LIB) $(LIBMCHECK)

all: $(TARGET)

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

$(LIBMCHECK): mcheck-init.o
	$(AR) uvc $(LIBMCHECK) mcheck-init.o

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

obj: $(OBJS)

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

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

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