# Don't edit Makefile! Use conf-* for configuration.

SHELL=/bin/sh

default: it

auto-str: \
load auto-str.o unix.a byte.a
	./load auto-str unix.a byte.a 

auto-str.o: \
compile auto-str.c buffer.h readwrite.h exit.h
	./compile auto-str.c

auto_home.c: \
auto-str conf-home
	./auto-str auto_home `head -1 conf-home` > auto_home.c

auto_home.o: \
compile auto_home.c
	./compile auto_home.c

buffer.o: \
compile buffer.c buffer.h
	./compile buffer.c

buffer_2.o: \
compile buffer_2.c readwrite.h buffer.h
	./compile buffer_2.c

buffer_copy.o: \
compile buffer_copy.c buffer.h
	./compile buffer_copy.c

buffer_get.o: \
compile buffer_get.c buffer.h byte.h error.h
	./compile buffer_get.c

buffer_put.o: \
compile buffer_put.c buffer.h str.h byte.h error.h
	./compile buffer_put.c

byte.a: \
makelib byte_copy.o byte_cr.o str_len.o
	./makelib byte.a byte_copy.o byte_cr.o str_len.o

byte_copy.o: \
compile byte_copy.c byte.h
	./compile byte_copy.c

byte_cr.o: \
compile byte_cr.c byte.h
	./compile byte_cr.c

check: \
it instcheck
	./instcheck

choose: \
warn-auto.sh choose.sh conf-home
	cat warn-auto.sh choose.sh \
	| sed s}HOME}"`head -1 conf-home`"}g \
	> choose
	chmod 755 choose

compile: \
warn-auto.sh conf-cc
	( cat warn-auto.sh; \
	echo exec "`head -1 conf-cc`" '-c $${1+"$$@"}' \
	) > compile
	chmod 755 compile

crt.o: \
compile crt.c crt.h
	./compile crt.c

error.o: \
compile error.c error.h
	./compile error.c

error_str.o: \
compile error_str.c error.h
	./compile error_str.c

hier.o: \
compile hier.c auto_home.h
	./compile hier.c

install: \
load install.o hier.o auto_home.o unix.a byte.a
	./load install hier.o auto_home.o unix.a byte.a 

install.o: \
compile install.c buffer.h strerr.h error.h open.h readwrite.h exit.h
	./compile install.c

instcheck: \
load instcheck.o hier.o auto_home.o unix.a byte.a
	./load instcheck hier.o auto_home.o unix.a byte.a 

instcheck.o: \
compile instcheck.c strerr.h error.h readwrite.h exit.h
	./compile instcheck.c

it: \
prog install instcheck

load: \
warn-auto.sh conf-ld
	( cat warn-auto.sh; \
	echo 'main="$$1"; shift'; \
	echo exec "`head -1 conf-ld`" \
	'-o "$$main" "$$main".o $${1+"$$@"}' \
	) > load
	chmod 755 load

makelib: \
warn-auto.sh systype
	( cat warn-auto.sh; \
	echo 'main="$$1"; shift'; \
	echo 'rm -f "$$main"'; \
	echo 'ar cr "$$main" $${1+"$$@"}'; \
	case "`cat systype`" in \
	sunos-5.*) ;; \
	unix_sv*) ;; \
	irix64-*) ;; \
	irix-*) ;; \
	dgux-*) ;; \
	hp-ux-*) ;; \
	sco*) ;; \
	*) echo 'ranlib "$$main"' ;; \
	esac \
	) > makelib
	chmod 755 makelib

open_read.o: \
compile open_read.c open.h
	./compile open_read.c

open_trunc.o: \
compile open_trunc.c open.h
	./compile open_trunc.c

prog: \
psibound rho

psibound: \
load psibound.o zpseriesexp.o crt.o ../zpfft-0.50/zpfft.a \
../primegen-0.97/primegen.a math.lib
	./load psibound zpseriesexp.o crt.o ../zpfft-0.50/zpfft.a \
	../primegen-0.97/primegen.a  `cat math.lib`

psibound.o: \
compile psibound.c ../primegen-0.97/primegen.h uint32.h uint64.h \
zpseriesexp.h ../zpfft-0.50/zpfft.h crt.h
	./compile psibound.c

rho: \
load rho.o math.lib
	./load rho  `cat math.lib`

rho.o: \
compile rho.c
	./compile rho.c

setup: \
it install
	./install

str_len.o: \
compile str_len.c str.h
	./compile str_len.c

strerr_die.o: \
compile strerr_die.c buffer.h exit.h strerr.h
	./compile strerr_die.c

strerr_sys.o: \
compile strerr_sys.c error.h strerr.h
	./compile strerr_sys.c

systype: \
find-systype.sh trycpp.c x86cpuid.c
	sh find-systype.sh > systype

tar: \
VERSION FILES README TODO CHANGES VERSION FILES SYSDEPS TARGETS \
Makefile conf-home conf-cc conf-ld psibound.c crt.h crt.c \
zpseriesexp.h zpseriesexp.c math.lib auto-str.c auto_home.h buffer.c \
buffer.h buffer_2.c buffer_copy.c buffer_get.c buffer_put.c byte.h \
byte_copy.c byte_cr.c choose.sh error.c error.h error_str.c exit.h \
find-systype.sh hier.c install.c instcheck.c open.h open_read.c \
open_trunc.c readwrite.h str.h str_len.c strerr.h strerr_die.c \
strerr_sys.c trycpp.c tryulong32.c tryulong64.c uint32.h1 uint32.h2 \
uint64.h1 uint64.h2 warn-auto.sh x86cpuid.c
	maketar `tr "ABCDEFGHIJKLMNOPQRSTUVWXYZ " \
	"abcdefghijklmnopqrstuvwxyz-" < VERSION` . `cat FILES` > tar
	chmod 400 tar

uint32.h: \
tryulong32.c compile load uint32.h1 uint32.h2
	( ( ./compile tryulong32.c && ./load tryulong32 && \
	./tryulong32 ) >/dev/null 2>&1 \
	&& cat uint32.h2 || cat uint32.h1 ) > uint32.h
	rm -f tryulong32.o tryulong32

uint64.h: \
choose compile load tryulong64.c uint64.h1 uint64.h2
	./choose clr tryulong64 uint64.h1 uint64.h2 > uint64.h

unix.a: \
makelib error.o open_read.o open_trunc.o error_str.o strerr_sys.o \
buffer.o buffer_put.o buffer_2.o strerr_die.o buffer_get.o \
buffer_copy.o
	./makelib unix.a error.o open_read.o open_trunc.o \
	error_str.o strerr_sys.o buffer.o buffer_put.o buffer_2.o \
	strerr_die.o buffer_get.o buffer_copy.o

zpseriesexp.o: \
compile zpseriesexp.c zpseriesexp.h ../zpfft-0.50/zpfft.h
	./compile zpseriesexp.c
