#pragma ident  "@(#)Makefile 1.19     04/05/07 SMI"

ARCH=		`uname -m`

INC=	-I. -I../include

OS: sh = \
	if  [ `expr  \`uname -r\` : 5\*` = 0 ] ; then \
		echo "4.x" ; \
	else \
		echo "SYSV" ; \
	fi

# choose the correct C compiler, 'acc' for 4.x and 'cc' for Solaris 2 (SVR4)
TMP_CC= $(OS:4.x=acc)
CC= $(TMP_CC:SYSV=cc)

AWK=	awk
CPP=	cpp
CPP_FLAGS=   $(INC)

FLAGS=	-c $(INC)

TMP_CFLAGS= $(OS:4.x=-g $(FLAGS) -D$(ARCH))
CFLAGS= $(TMP_CFLAGS:SYSV=-g $(FLAGS) -DSYSV)

TMP_LFLAGS= $(OS:4.x= -latm)
LFLAGS= $(TMP_LFLAGS:SYSV= -latm -lsocket -lnsl)

LPATH=	-L. -L../lib

raw_cfiles =	raw.c xdump.c
raw_ofiles =	$(raw_cfiles:.c=.o)

music_cfiles =	music.c xdump.c
music_ofiles =	$(music_cfiles:.c=.o)

dltst_cfiles =	dltst.c xdump.c
dltst_ofiles =	$(dltst_cfiles:.c=.o)

tstqcc_cfiles =	tstqcc.c xdump.c
tstqcc_ofiles =	$(tstqcc_cfiles:.c=.o)

alntest_cfiles = alntest.c
alntest_ofiles = $(alntest_cfiles:.c=.o)

DEFAULT =	raw dltst tstqcc alntest

default:	$(DEFAULT)

raw: $(raw_ofiles) ../lib/libatm.a
	$(CC) -o $@ $(raw_ofiles) $(LPATH) $(LFLAGS)

music: $(music_ofiles) ../lib/libatm.a
	$(CC) -mt -o $@ $(music_ofiles) $(LPATH) $(LFLAGS)

dltst: $(dltst_ofiles) ../lib/libatm.a
	$(CC) -o $@ $(dltst_ofiles) $(LPATH) $(LFLAGS)

tstqcc: $(tstqcc_ofiles) ../lib/libatm.a
	$(CC) -o $@ $(tstqcc_ofiles) $(LPATH) $(LFLAGS)

alntest: $(alntest_ofiles) ../lib/libatm.a
	$(CC) -o $@ $(alntest_ofiles) $(LPATH) $(LFLAGS)

music.o:	music.c
	$(CC) $(CFLAGS) -mt music.c

.c.o:
	$(CC) $(CFLAGS) $*.c

clean:
	rm -f $(DEFAULT) *.o 

stamp:
	sccs edit SCCS
	echo $$comments | sccs delta SCCS
