all: jumpas mkimage mkstubs getsize jumpas verify mkcompat

jumpas: jumpas.o utils.o fixassy.o
	$(CC) -o $@ jumpas.o utils.o fixassy.o $(MISC_OBJS) $(LIBS)

mkimage: mkimage.o utils.o
	$(CC) -o $@ mkimage.o utils.o $(MISC_OBJS) $(LIBS)

mkcompat: mkcompat.o utils.o mkcompat.h
	$(CC) -o $@ mkcompat.o utils.o $(MISC_OBJS) $(LIBS)

mkcompat.c: mkcompat.h

mkcompat.h: ../doc/table_description gentable
	./genheader ../doc/table_description >$@

gentable: gentable.c
	$(HOST_CC) -o $@ gentable.c
	[ -h genheader ] || ln -s $@ genheader

mkstubs: mkstubs.o utils.o
	$(CC) -o $@ mkstubs.o utils.o $(MISC_OBJS) $(LIBS)

getsize: getsize.o utils.o
	$(CC) -o $@ getsize.o utils.o $(MISC_OBJS) $(LIBS)


jumpas.o: jumpas.c utils.h
	$(CC) $(CFLAGS) -c jumpas.c

verify: verify.o utils.o $(MD)
	$(CC) -o $@ verify.o utils.o $(MD) $(MISC_OBJS) $(LIBS)

clean:
	/bin/rm -f *.o jumpas mkimage mkstubs getsize verify mkcompat gentable genheader mkcompat.h *~ #*#

install: all
	strip getsize mkimage mkstubs jumpas verify mkcompat
	if [ ! -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi
	cp getsize mkimage mkstubs mkcompat $(BINDIR)
	cp verify $(BINDIR)/verify-shlib
	if [ -d $(BINDIR)/../jump ]; then true; else mkdir $(BINDIR)/../jump; fi
	cp jumpas $(BINDIR)/../jump/as
	if [ -f /usr/bin/mkimage ]; then rm -f /usr/bin/mkimage; fi
	if [ -f /usr/bin/mkstubs ]; then rm -f /usr/bin/mkstubs; fi
	if [ -f /usr/bin/getsize ]; then rm -f /usr/bin/getsize; fi
	if [ -f /usr/bin/verify-shlib ]; then rm -f /usr/bin/verify-shlib; fi
	cd $(BINDIR); /bin/rm -f getvars getfuncs libinfo; \
	ln -s mkcompat getvars; \
	ln -s mkcompat getfuncs; \
	ln -s mkcompat libinfo
