CC = cc
INCLS = -I.
CFLAGS = -g $(INCLS)
LIBS = -lm

# system independent sources
SYS_INDEP_SRCS = \
	bigint.c \
	gen.c \
	modmin.c \
	pack.c \
	random.c \
	testbase.c \
	testrec.c \
	tests.c \
	ulp.c \
	stress.c

# system dependent sources
SYS_DEP_SRCS = \
	except.c \
	intr.c \
	os.c \
	precision.c \
	round.c

SRCS = \
	$(SYS_INDEP_SRCS) \
	$(SYS_DEP_SRCS)

OBJS = \
	bigint.o \
	except.o \
	fortran.o \
	gen.o \
	intr.o \
	modmin.o \
	os.o \
	pack.o \
	precision.o \
	random.o \
	round.o \
	testbase.o \
	testrec.o \
	tests.o \
	ulp.o \
	stress.o

testbase: $(OBJS)
	$(CC) $(CFLAGS) -o testbase $(OBJS) $(LIBS)

$(SYS_DEP_SRCS):
	echo Need to run config.sh
	exit 1

opt:
	$(MAKE) CFLAGS="-O $(INCLS)"

sun-opt:
	$(MAKE) CFLAGS="-O4 $(INCLS)"

gcc-opt:
	$(MAKE) CC=gcc CFLAGS="-O $(INCLS) -fstrength-reduce -fomit-frame-pointer -finline-functions -fdelayed-branch"

profile:
	make clean
	$(MAKE) CFLAGS="$(CFLAGS) -pg"

clean:
	rm -f testbase gmon.out $(OBJS) errs testbase.lint testbase.gcc-lint

config-clean:
	rm -f $(SYS_DEP_SRCS) config.h precision.h

all-lint: lint gcc-lint

lint:
	lint $(INCLS) $(DEFS) $(SRCS) $(LIBS) >testbase.lint

gcc-lint:
	gcc -Dlint $(CFLAGS) -Wall -c $(DEFS) $(SRCS) >testbase.gcc-lint 2>&1

tags:	$(SRCS) spdp.c
	rm -f tags
	ctags $(SRCS) spdp.c
