# Makefile for hacked MiNTlib for Heat-n-Serve/Sozobon C, version 1.33i
# and above.  This makefile works with the make provided with 1.40, and
# less well with the make provided with 1.33i

# Where to install libraries.
LIBDIR = c:\sozobon\lib

# You might want any or all of these; Sozobon's make predefines most of them.
AR = ar
# CP = cp
# RM = rm -f

# 1.33i's top apparently takes about 30 minutes on doprnt.c; if you don't
# want to wait that long, use the alternate definition of NOOPT. (1.40's 
# top doesn't seem to have this problem)
CFLAGS = -O -D__NO_FLOAT__ -DNDEBUG
# NOOPT = -D__NO_FLOAT__ -DNDEBUG
NOOPT = $(CFLAGS)

# If you prefer more "standard" Unix-like names for your library files, use
# the alternate definitions of CRT0 and LIBC -- assuming, of course, that
# your cc has been modified to recognize those names!
# CRT0 = crt0.o
# LIBC = libc.a
CRT0 = dstart.o
LIBC = dlibs.a
LIBS = $(CRT0) $(LIBC) libtermcap.a

.PHONY : all clean realclean install
all : $(LIBS)

# These are in alphabetical order to make it easy to find one.
OBJECTS = \
	abort.o abs.o access.o alarm.o alloca.o alphasor.o atexit.o atol.o \
	bcmp.o bcopy.o binmode.o bsearch.o bzero.o \
	calloc.o chdir.o chmod.o clock.o close.o console.o crtinit.o ctime.o \
	ctype.o defmode.o \
	difftime.o dirent.o doprnt.o dup.o \
	eprintf.o exec.o \
	fclose.o fcntl.o fdopen.o fflush.o fgetc.o fgets.o filbuf.o \
	findfile.o fopen.o fopenp.o fork.o fprintf.o fputc.o fputs.o \
	fread.o fscanf.o fseek.o fsetpos.o ftw.o fungetc.o fwrite.o \
	getbuf.o getcwd.o getdtabl.o getenv.o getgroup.o gethostn.o \
	getlogin.o getopt.o getpages.o getpass.o getpid.o getpw.o getrusag.o \
	gets.o getuid.o getw.o grp.o heapbase.o inistack.o \
	ioctl.o initsig.o isatty.o \
	ident.o il.o ic.o iw.o ig.o ip.o \
	kill.o killpg.o \
	linea.o link.o lmalloc.o localtim.o lockf.o lseek.o ltoa.o \
	main.o malloc.o memccpy.o memchr.o memcmp.o memcpy.o memset.o \
	mkdir.o mknod.o mktemp.o \
	nice.o \
	open.o osbind.o \
	pause.o perror.o pipe.o popen.o psignal.o putenv.o \
	qsort.o \
	raise.o rand.o random.o read.o realloc.o regexp.o regsup.o \
	rename.o rmdir.o \
	sbrk.o scandir.o scanf.o select.o setbuf.o setjmp.o setlocal.o \
	setrlimi.o setvbuf.o sgtty.o sigactio.o sigblock.o siglist.o signal.o \
	sleep.o \
	sozolong.o sozulong.o spawn.o spawnve.o spawnvp.o sprintf.o sscanf.o \
	stat.o statfs.o stksiz.o strcat.o strchr.o strcmp.o strcoll.o strcpy.o \
	strcspn.o strdup.o strerror.o strftime.o \
	stricmp.o strlen.o strlwr.o strncat.o strncmp.o strnicmp.o \
	strncpy.o strpbrk.o strrchr.o strrev.o strspn.o strstr.o strtok.o \
	strtol.o strtoul.o symlink.o sysconf.o system.o sysvar.o \
	textio.o thread.o time.o timeoday.o tmpfile.o tmpnam.o ttyname.o \
	uname.o unlink.o unx2dos.o utime.o utmp.o \
	vfork.o \
	wait.o wait3.o waitpid.o write.o wtmp.o
#	div.o

# If you're using 1.33i's make, this command will fail spectacularly
# for the first build; you'll have to build it by hand, a few files
# at a time.  After that, if you only change a few files at a time,
# you shouldn't have problems.
$(LIBC) : $(OBJECTS)
	$(AR) rv $@ $?

doprnt.o: doprnt.c
	$(CC) $(NOOPT) -c $?

libtermcap.a : termcap.o
	$(AR) rv $@ $?

# this is ugly, but I can't think of a way around it without risking the TOS
# "copy file to itself" bug.  If you have CRT0 = crt0.o, this rule will
# never be used anyway.
dstart.o : crt0.o
	$(CP) $? $@

clean :
	$(RM) *.o

realclean : clean
	$(RM) $(LIBS)

install : $(LIBS)
	$(CP) $(LIBC) $(LIBDIR)
	$(CP) $(CRT0) $(LIBDIR)
	$(CP) libtermcap.a $(LIBDIR)
