# milo/lib/Makefile
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file COPYING in the main directory of this archive for more
# details.

CC		= mips-linux-gcc -Wa,-mips3
AS		= mips-linux-as -mips3
AR		= mips-linux-ar
LD		= mips-linux-ld
STRIP		= mips-linux-strip
MAKE		= make

CFLAGS		= -I../include -I/usr/mips-linux/include -O2 -mips3 -mcpu=r4000 \
		  -D__KERNEL__

LDFLAGS		= -N -oformat ecoff-littlemips

LIBOBJS		= console.o vsprintf.o ctype.o glue.o fprintf.o sleep.o \
		  dumptlb.o seek.o errno.o exit.o open.o close.o read.o write.o \
		  get_nlist.o getenv.o setenv.o unsetenv.o putenv.o printf.o \
		  stdfd.o malloc.o mallocinit.o mallocdebug.o __main.o\
		  strerror.o errlist.o getopt.o getopt1.o perror.o puts.o \
		  fflush.o getchar.o cachectl.o arc.o

all:		dummy libstand.a

ifeq (.depend,$(wildcard .depend))
include .depend
endif

libstand.a:	$(LIBOBJS)
		$(AR) rcs libstand.a $(LIBOBJS)

cachectl.o:	cachectl.S
		$(CC) $(CFLAGS) -c cachectl.S
clean:
		-rm -f *.[o] *.bak

distclean:	clean
		-rm -f .depend libstand.a

depend dep:
		for i in *.c; do echo -n "./";$(CPP) $(CFLAGS) -M $$i;done \
			> .tmpdepend
		mv .tmpdepend .depend

ifeq (.depend,$(wildcard .depend))
dummy:

else
.depend:
	@echo "Generating dependencies..."
	@echo
	$(MAKE) depend
	@echo
	@echo "Successful. Try re-making (ignore the error that follows)"
	@echo
	exit 1

dummy:	.depend

endif
