#
# Makefile for Checker
# 
# If you already have morecore(), remove morecore.o from OBJS
#

# Your compiler
CC = gcc
AS = as

CONFPATH = ../config/i386/Linux/
VPATH = $(CONFPATH)

# 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$(CONFPATH)
CFLAGS = -O2 -Wall -g

# LIB is the name of the library file
LIB= libchkrlib.a
LIBOBJ= libchkrlib.o

OBJS  = vprintf.o getenv.o getcwd.o mktemp.o _quicksort.o qsort.o dirent.o \
	strings.o syscall.o

SYSOBJS= __access.o __close.o __getpid.o __kill.o __lseek.o __lstat.o \
	__open.o __read.o __sbrk.o __stat.o __unlink.o __write.o libc_exit.o \
	mmap.o munmap.o

TARGET=$(LIBOBJ)

all: $(TARGET)

$(LIB): .depend $(OBJS)
	$(AR) usvc $(LIB) $(OBJS)
#	ranlib $(LIB)

$(LIBOBJ): .depend $(OBJS)
	$(LD) -r -o $(LIBOBJ) $(OBJS)

syscall.o: .depend $(SYSOBJS)
	ld -o syscall.o -r $(SYSOBJS)

.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 $(LIB) .depend *~
	$(RM) -f $(LIB)

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

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