#
# Makefile for random number generator
# created by Willi Burmeister <wib@cs.uni-kiel.de>
#
# HISTORY
#
# 21.05.2000  wib  created this file
# 22.05.2000  wib  added all package files
# 25.05.2000  wib  added checkinstall
# 28.05.2000  wib  sysv-make support by Hans-Gehard Weinreich <weinreich@operamail.com>
#                  only compile 64 bit binaries on 64 bit machines
# 19.11.2000  wib  version from file
#

#
# use this one
#
CC = cc

#
# for cc
#
CFLAGS = -D_KERNEL -O
CFLAGS64 = -xarch=v9

#
# for gcc (support for 64 bit binaries?)
#
#CFLAGS = -D_KERNEL -O2
#CFLAGS64 =

#
# version of random.c
#
VERSION = `cat .version`

#
# misc
#
ARCH = `uname -p`
PKG  = ANDIrand
PACK = ${PKG}.pkg

OBJ = random-32.o random-64.o
MOD = random-32 random-64

SCRIPTS  = checkinstall random.init postinstall preremove postremove
PKGFILES = pkginfo prototype copyright devlink.tab
FILES    = $(MOD) $(SCRIPTS) $(PKGFILES)

#
# dependencies
#
all: ${PACK}

random-32.o:	random.c
		$(CC) $(CFLAGS) -o $@ -c $?

random-32:	random-32.o
		ld -r -o $@ $?

random-64.o:	random.c
		if [ -x /usr/bin/isainfo ]; then \
			if [ `/usr/bin/isainfo -b` -eq 64 ]; then \
				$(CC) $(CFLAGS) $(CFLAGS64) -o $@ -c $?; \
			else \
				touch $@; \
			fi; \
		else \
			touch $@; \
		fi

random-64:	random-64.o
		if [ -x /usr/bin/isainfo ]; then \
			if [ `/usr/bin/isainfo -b` -eq 64 ]; then \
				ld -r -o $@ $?; \
			else \
				touch $@; \
			fi; \
		else \
			touch $@; \
		fi

pkginfo:	pkginfo.in
		sed -e "s/^ARCH=/ARCH=${ARCH}/" \
		    -e "s/XVERSION/${VERSION}/" $? > $@

${PACK}:	$(FILES)
		pkgmk -o -d . -f prototype -p `date +%Y%m%d%H%M`
		pkgtrans -s . $@ ${PKG}

clean:
		rm -rf ${PKG} ${PACK}
		rm -f pkginfo $(OBJ) $(MOD)

#
# end of file
#
