#	Copyright (c) 1984, 1986, 1987, 1988 AT&T
#	  All Rights Reserved

#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#	The copyright notice above does not evidence any
#	actual or intended publication of such source code.

#ident	"@(#)libm:makefile	2.5"
#	MC68000 MATH LIBRARY MAKEFILE
#
#

#
# makefile for libm
#
# Note that the object list given in FILES is in the order in which the files
# should be added to the archive when it is created.  If the files are not
# ordered correctly, linking of libm fails on the pdp11 and is slowed down
# on other machines.

SGS=	mc68
OWN=	sgs		#file owner
GRP=	sgs		#file group
PROT=	775		#protections

ROOT=
LIBDIR=	$(ROOT)/lib
LIB=	$(LIBDIR)
# LIBP=/lib/libp
VARIANT =
USRINC=	$(ROOT)/usr/include
LIBNAME = lib$(VARIANT)m.a
AR=ar
FILES =\
	$(LIBNAME)(asin.o)\
	$(LIBNAME)(atan.o)\
	$(LIBNAME)(erf.o)\
	$(LIBNAME)(fabs.o)\
	$(LIBNAME)(floor.o)\
	$(LIBNAME)(fmod.o)\
	$(LIBNAME)(gamma.o)\
	$(LIBNAME)(hypot.o)\
	$(LIBNAME)(jn.o)\
	$(LIBNAME)(j0.o)\
	$(LIBNAME)(j1.o)\
	$(LIBNAME)(pow.o)\
	$(LIBNAME)(log.o)\
	$(LIBNAME)(sin.o)\
	$(LIBNAME)(sinh.o)\
	$(LIBNAME)(sqrt.o)\
	$(LIBNAME)(tan.o)\
	$(LIBNAME)(tanh.o)\
	$(LIBNAME)(exp.o)\
	$(LIBNAME)(matherr.o)

build:	$(LIBNAME) # profiledlib

# Note:  The funny define of write is designed to cause the
#	compiler to generate null code where error messages
#	are usually produced.  This is because the simplest
#	68000 run-time environments would not have a write
#	system call available.  For UNIX target systems the -D
#	should be removed.

$(LIBNAME): $(FILES)
	$(CC) -c $(CFLAGS) -I$(USRINC) -Dwrite= $(?:.o=.c)
	$(AR) r $(LIBNAME) $?
#	rm $?

$(FILES): $(USRINC)/math.h $(USRINC)/values.h $(USRINC)/errno.h \
		$(USRINC)/sys/errno.h

.c.a:;

profiledlib:
	make -f libm.mk -e libp.$(LIBNAME) LIBNAME=libp.$(LIBNAME) \
						CFLAGS="-p $(CFLAGS)"

install:	libm.a
		-rm -f $(LIBDIR)/libm.a
		cp libm.a $(LIBDIR)
		chmod $(PROT) $(LIBDIR)/libm.a
		chmod -x $(LIBDIR)/libm.a
		chgrp $(GRP) $(LIBDIR)/libm.a
		chown $(OWN) $(LIBDIR)/libm.a

#--------------------------

save:    	$(LIBDIR)/libm.a
		-rm -f $(LIBDIR)/libm.a.back
		cp $(LIBDIR)/libm.a $(LIBDIR)/libm.a.back

#--------------------------

uninstall:	$(LIBDIR)/libm.a.back
		-rm -f $(LIBDIR)/libm.a
		cp $(LIBDIR)/libm.a.back $(LIBDIR)/libm.a

#--------------------------

clean:
	-rm -f *.o

clobber:	clean
	-rm -f $(LIBNAME) # libp.$(LIBNAME)
