# 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
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 fprintf.o dumptlb.o get_nlist.o printf.o stdfd.o \
		  __main.o strerror.o getopt.o getopt1.o puts.o string.o

ifeq (../.full,$(wildcard ../.full))
LIBOBJS		+= glue.o sleep.o seek.o errno.o exit.o open.o close.o read.o write.o setenv.o \
		  unsetenv.o putenv.o malloc.o mallocinit.o mallocdebug.o __main.o errlist.o \
		  getchar.o cachectl.o arc.o string.o fflush.o getenv.o perror.o
endif

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]

distclean:	clean
		if [ -f ../.full ]; then rm -f libstand.a; fi
		-rm -f .depend *.bak *~

depend:
		set -e;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
