#
# Makefile for libiberty directory
#

#CC = gcc -b$(target) -g -nostdinc
#CFLAGS= -I- -I/usr/local/lib/gcc/$(target)/1.92/include -I$(srcdir) -I$(srcdir)/../include

# Most hosts want strerror, but one or two don't, and they override these
# definitions in the host-dependent makefile fragment.
STRERROR_C = strerror.c
STRERROR_O = strerror.o

# Host and target-dependent makefile fragments come in here.
####
# End of host and target-dependent makefile fragments.

srcdir = .
destdir = /usr/local

libdir = $(destdir)/H-$(host_alias)/T-independent/lib

CFILES = getopt.c getopt1.c obstack.c $(STRERROR_C) $(HOST_CFILES)
OFILES = getopt.o getopt1.o obstack.o $(STRERROR_O) $(HOST_OFILES)

TARGETLIB = libiberty.a
RANLIB = ranlib
AR = ar
AR_FLAGS = crv
CFLAGS = -I$(srcdir)/../include $(HDEFINES)

STAGESTUFF = $(TARGETLIB) $(OFILES)

all:	$(TARGETLIB)

install: all
	cp $(TARGETLIB) $(libdir)/$(TARGETLIB).new
	$(RANLIB) $(libdir)/$(TARGETLIB).new
	mv -f $(libdir)/$(TARGETLIB).new $(libdir)/$(TARGETLIB)

$(TARGETLIB): $(OFILES)
	rm -rf $(TARGETLIB)
	$(AR) $(AR_FLAGS) $(TARGETLIB) $(OFILES)
	$(RANLIB) $(TARGETLIB)

.PHONEY: all etags tags ls clean stage1 stage2

stage1: force
	- mkdir stage1
	- mv -f $(STAGESTUFF) stage1

stage2: force
	- mkdir stage2
	- mv -f $(STAGESTUFF) stage2

stage3: force
	- mkdir stage3
	- mv -f $(STAGESTUFF) stage3

stage4: force
	- mkdir stage4
	- mv -f $(STAGESTUFF) stage4

against=stage2

comparison: force
	for i in *.o ; do cmp $$i $(against)/$$i || exit 1 ; done

de-stage1: force
	- (cd stage1 ; mv -f * ..)
	- rmdir stage1

de-stage2: force
	- (cd stage2 ; mv -f * ..)
	- rmdir stage2

de-stage3: force
	- (cd stage3 ; mv -f * ..)
	- rmdir stage3

de-stage4: force
	- (cd stage4 ; mv -f * ..)
	- rmdir stage4

etags tags: TAGS

TAGS: $(CFILES)
	etags $(HFILES) $(CFILES)

ls:
	@echo Makefile $(HFILES) $(CFILES)

# Need to deal with profiled libraries, too.

clean:
	rm -f *.a *.o core errs *~ \#* TAGS *.E

force:

Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
	$(SHELL) ./config.status
