/* ********************************************************************** *\
 *         Copyright IBM Corporation 1988,1991 - All Rights Reserved      *
 *        For full copyright information see:'andrew/config/COPYRITE'     *
\* ********************************************************************** */
DependTarget(globalrefs._h)

NormalObjectRule()
NormalAsmPPRule()

all:: globals.o entry.o doload.o dofix.o dolist.o

globals.o:  globals.spp globalrefs._h

globalrefs._h:	libc.eplist
		$(AWK) '{printf "\tglobalref(%s)\n", $$2}' libc.eplist >,globalrefs._h
		$(MV) ,globalrefs._h globalrefs._h

libc.eplist:		/lib/libc.a /lib/crt0.o getlist.awk
		$(RM) /tmp/libhack.a
		$(AR) /tmp/libhack.a /lib/crt0.o
		$(NM) -ex /lib/libc.a /tmp/libhack.a | \
			$(TR) "|" " " | \
			$(AWK) -f getlist.awk | \
			grep -v "%_" > ,libc.eplist
		$(MV) ,libc.eplist libc.eplist

InstallLibrary(libcx.a, $(DESTDIR)/lib)
InstallCshScript(makedo.csh,$(DESTDIR)/bin/makedo)

all::		libcx.a

DelList._: libc.eplist
	        	$(AWK) '{print $$1}' libc.eplist | $(SORT) -u > ,DelList._
	       	 $(MV) ,DelList._ DelList._

libcx.a:        /lib/libc.a /lib/crt0.o DelList._ $(COMPILERLIBS)
	        rm -rf new
	        mkdir new
	                -cd new ; ar x $(COMPILERLIBS) ;
	                cd new ; \
	                cp /lib/libc.a libcx.a ; \
	                chmod +w libcx.a ;
	                -cd new ; ar q libcx.a *.o /lib/crt0.o ;
	                cd new ; ar d libcx.a `cat ../DelList._`
	        mv new/libcx.a libcx.a
		rm -rf new

clean::
	$(RM) DelList._ libc.eplist globalrefs._h ,* libcx.a
	rm -fr new /tmp/libhack.a

install::
	rm -rf ../machine
	copy -rom . ../machine
