DEBUG	=n
OS	=$(shell uname)

ifeq ($(OS),SunOS)
ifeq ($(DEBUG),y)
CFLAGS = -Wall -Wstrict-prototypes -g -DSUN_AUDIO -DARCH_SPARC
else
CFLAGS = -Wall -Wstrict-prototypes -O3 -DSUN_AUDIO -DARCH_SPARC
endif
else
ifeq ($(DEBUG),y)
CFLAGS = -Wall -Wstrict-prototypes -g -O -m486 \
         -malign-loops=2 -malign-jumps=2 -malign-functions=2
else
CFLAGS = -Wall -Wstrict-prototypes -O3 -m486 \
         -malign-loops=2 -malign-jumps=2 -malign-functions=2
endif
endif

AS86	=as86 -0 -a
LD86	=ld86 -0

AS	=as
LD	=ld
LDFLAGS	=
HOSTCC	=gcc
CC	=gcc
MAKE	=make
CPP	=$(CC) -E
AR	=ar
STRIP	=strip

SRC	=soundif.c xgraphif.c faxrx.c gensin.c timefir.c writepgm.c

all:	faxrx gensin timefir writepgm

.c.s:
	$(CC) $(CFLAGS) -S -o $*.s $<
.s.o:
	$(AS) -c -o $*.o $<
.c.o:
	$(CC) $(CFLAGS) -c -o $*.o $<

faxrx:	faxrx.o soundif.o xgraphif.o
	$(CC) $(LDFLAGS) faxrx.o soundif.o xgraphif.o -lm -o faxrx

gensin:	gensin.o
	$(CC) $(LDFLAGS) gensin.o -lm -o gensin

timefir:	timefir.o
	$(CC) $(LDFLAGS) timefir.o -lm -o timefir

writepgm:	writepgm.o
	$(CC) $(LDFLAGS) writepgm.o -o writepgm

clean:
	rm -f core `find . -name '*.[oas]' -print`
	rm -f core `find . -name 'core' -print`

depend dep:
	$(CPP) -M $(CFLAGS) $(SRC) > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif
