# Makefile for trampoline

#### Start of system configuration section. ####

HOST = @host@
CPU = @HOST_CPU_C_ABI@
OS = @host_os@

# Directories used by "make":
srcdir = @srcdir@

# Directories used by "make install":
prefix = @prefix@
local_prefix = /usr/local
exec_prefix = @exec_prefix@
libdir = @libdir@
includedir = @includedir@
mandir = @mandir@
datadir = @datadir@
datarootdir = @datarootdir@
htmldir = $(datadir)/html

# Programs used by "make":
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
INCLUDES = -I. -I$(srcdir)
ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DASM_UNDERSCORE'; fi`
AR = ar
AR_FLAGS = rc
RANLIB = @RANLIB@
RM = rm -f
LN_S = @LN_S@
@SET_MAKE@

# Programs used by "make install":
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

#### End of system configuration section. ####

SHELL = /bin/sh

OBJECTS = trampoline.o @CPU_OBJECTS@

all : $(OBJECTS) libtrampoline.a trampoline.h $(srcdir)/trampoline.3 $(srcdir)/trampoline.html

trampoline.h : $(srcdir)/trampoline.h.in
	-$(LN_S) $(srcdir)/trampoline.h.in trampoline.h

trampoline.o : $(srcdir)/trampoline.c trampoline.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/trampoline.c

tramp-hppa.o : $(srcdir)/tramp-hppa.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/tramp-hppa.s

tramp-s390.o : $(srcdir)/tramp-s390.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/tramp-s390.s

tramp-powerpc.o : tramp-powerpc.s
	$(CC) @GCC_X_NONE@ -c tramp-powerpc.s

tramp-powerpc.s : $(srcdir)/tramp-powerpc.old.S $(srcdir)/tramp-powerpc.new.S
	case "$(OS)" in \
	  aix3*) syntax=old;; \
	  *) syntax=new;; \
	esac; \
	$(CPP) $(srcdir)/tramp-powerpc.$${syntax}.S > tramp-powerpc.s

tramp-powerpc64.o : tramp-powerpc64.s
	$(CC) @GCC_X_NONE@ -c tramp-powerpc64.s

tramp-powerpc64.s : $(srcdir)/tramp-powerpc64.new.S
	$(CPP) $(srcdir)/tramp-powerpc64.new.S > tramp-powerpc64.s

tramp-ia64.o : $(srcdir)/tramp-ia64.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/tramp-ia64.s

cache-sparc.o : cache-sparc.s
	$(CC) @GCC_X_NONE@ -c cache-sparc.s

cache-sparc.s : $(srcdir)/cache-sparc.S
	$(CPP) $(ASPFLAGS) $(srcdir)/cache-sparc.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' -e 's,\$$,#,g' > cache-sparc.s

cache-sparc64.o : cache-sparc64.s
	$(CC) @GCC_X_NONE@ -c cache-sparc64.s

cache-sparc64.s : $(srcdir)/cache-sparc.S
	$(CPP) $(ASPFLAGS) $(srcdir)/cache-sparc.S | grep -v '^ *#line' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,//.*$$,,' -e 's,\$$,#,g' > cache-sparc64.s

cache-alpha.o : $(srcdir)/cache-alpha.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/cache-alpha.s

cache-hppa.o : $(srcdir)/cache-hppa.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/cache-hppa.s

cache-arm.o : $(srcdir)/cache-arm.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/cache-arm.s

cache-armel.o : $(srcdir)/cache-armel.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/cache-armel.s

cache-powerpc.o : $(srcdir)/cache-powerpc-sysv4.s $(srcdir)/cache-powerpc-macos.s
	case "$(OS)" in \
	  macos* | darwin*) syntax=macos;; \
	  *) syntax=sysv4;; \
	esac; \
	$(CC) @GCC_X_NONE@ -c $(srcdir)/cache-powerpc-$${syntax}.s ; mv cache-powerpc-$${syntax}.o cache-powerpc.o

cache-convex.o : $(srcdir)/cache-convex.s
	$(CC) @GCC_X_NONE@ -c $(srcdir)/cache-convex.s

libtrampoline.a : $(OBJECTS)
	$(RM) libtrampoline.a
	$(AR) $(AR_FLAGS) libtrampoline.a $(OBJECTS)
	$(RANLIB) libtrampoline.a

install : all force
	mkdir -p $(DESTDIR)$(prefix)
	mkdir -p $(DESTDIR)$(exec_prefix)
	mkdir -p $(DESTDIR)$(libdir)
	$(INSTALL_DATA) libtrampoline.a $(DESTDIR)$(libdir)/libtrampoline.a
	mkdir -p $(DESTDIR)$(includedir)
	$(INSTALL_DATA) trampoline.h $(DESTDIR)$(includedir)/trampoline.h
	mkdir -p $(DESTDIR)$(mandir)
	mkdir -p $(DESTDIR)$(mandir)/man3
	$(INSTALL_DATA) $(srcdir)/trampoline.3 $(DESTDIR)$(mandir)/man3/trampoline.3
	mkdir -p $(DESTDIR)$(datadir)
	mkdir -p $(DESTDIR)$(htmldir)
	$(INSTALL_DATA) $(srcdir)/trampoline.html $(DESTDIR)$(htmldir)/trampoline.html

installdirs : force
	mkdir -p $(DESTDIR)$(prefix)
	mkdir -p $(DESTDIR)$(exec_prefix)
	mkdir -p $(DESTDIR)$(libdir)
	mkdir -p $(DESTDIR)$(includedir)
	mkdir -p $(DESTDIR)$(mandir)
	mkdir -p $(DESTDIR)$(mandir)/man3
	mkdir -p $(DESTDIR)$(datadir)
	mkdir -p $(DESTDIR)$(htmldir)

uninstall : force
	$(RM) $(DESTDIR)$(libdir)/libtrampoline.a
	$(RM) $(DESTDIR)$(includedir)/trampoline.h
	$(RM) $(DESTDIR)$(mandir)/man3/trampoline.3
	$(RM) $(DESTDIR)$(htmldir)/trampoline.html

test1.o : $(srcdir)/test1.c trampoline.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/test1.c

test1 : test1.o $(OBJECTS)
	$(CC) $(CFLAGS) @GCC_X_NONE@ test1.o $(OBJECTS) -o test1

test2.o : $(srcdir)/test2.c trampoline.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/test2.c

test2 : test2.o $(OBJECTS)
	$(CC) $(CFLAGS) @GCC_X_NONE@ test2.o $(OBJECTS) -o test2

check1 : all test1
	./test1

check : all test1 test2
	./test1
	./test2
	touch tests.passed.$(HOST)

extracheck : check

mostlyclean : clean

clean : force
	$(RM) $(OBJECTS) tramp-powerpc.s cache-sparc.s cache-sparc64.s libtrampoline.a core
	$(RM) test1.o test1 test2.o test2

distclean : clean
	$(RM) config.status config.log config.cache Makefile config.h trampoline.h tests.passed.*

maintainer-clean : distclean

force :


