/* ## This file is formatted with a tab-width of 3 */

CSOURCES    = mcvert.c hqxify.c unpack.c
HSOURCES    = mactypes.h
SOURCES     = $(CSOURCES) $(HSOURCES) Makefile README
sharSOURCES = $(SOURCES) mcvert.1
OBJECTS     = mcvert.o hqxify.o unpack.o
ALL         = mcvert mcvert.man
EVERYTHING  = $(ALL) shar mcvert.ps
CLEAN       = $(OBJECTS) $(ALL)
BINDIR      = /mit/sipb/bin
MANDIR      = /mit/sipb/man
MANEXT      = 1

VERSION=188

BIN = .

/* ## */
/* ## *LAST* Defintion Always Wins ## */
/* ## */

/* ### C Compiler */
#ifdef sgi
CC= gcc
#endif

/* ### Bind Time Library Selection */
/* # for RS/6000 */
#ifdef _AIX
LIBS= -lbsd
#endif

/* ### Machine CFLAGS */
#if 0
/* # for machines without <timeb.h> and ftime() */
CFLAGS_M= -DTIMEVAL
/* # for machines with ulong pre-defined (eg, IBM RS/6000's AIX) */
CFLAGS_M= -DULONG
#endif
#ifdef _AIX
CFLAGS_M= -DULONG
#endif
#ifdef sgi
CFLAGS_M= -DTIMEVAL -DULONG
#endif

/* ### Debugging/optimization CFLAGS */
#if 0
/* # debugging */
CFLAGS_D = -g
#endif
/* # optimization */
CFLAGS_D = -O


/* ### Byteorder(3n) routines [eg, htonl()] CFLAGS */
#if 0
/* # uncommon case (none known, actually): without byteorder support */
CFLAGS_N = -DNOBYTEORDER
/* # common case: with byteorder support */
CFLAGS_N =
#endif

/* ### All CFLAGS */
CFLAGS=$(CFLAGS_M) $(CFLAGS_D) $(CFLAGS_N) -DVERSION=$(VERSION)
LFLAGS=$(CFLAGS_M) $(CFLAGS_N) -DVERSION=$(VERSION)

all: $(ALL)
everything: $(EVERYTHING)

mcvert: $(OBJECTS)
	$(CC) $(CFLAGS) $(OBJECTS) $(LIBS) -o $(BIN)/mcvert

lint: $(HSOURCES) $(CSOURCES)
	lint $(LFLAGS) $(CSOURCES)

$(OBJECTS): mactypes.h Makefile

print: $(SOURCES)
	lpr -p -P$(PRINTER) $(SOURCES)

shar : mcvert-$(VERSION).shar
mcvert-$(VERSION).shar : $(sharSOURCES)
	shar $(sharSOURCES) > $@

clean:
	rm -f $(CLEAN)

man: mcvert.man
mcvert.man: mcvert.1
	nroff -man mcvert.1 | sed 's/.//g' > $@
mcvert.ps: mcvert.1
	groff -man mcvert.1 > $@

depend:
	makedepend $(CFLAGS) -- $(CSOURCES)

Makefile: Imakefile
	-rm -f Makefile.bak
	-mv Makefile Makefile.bak
	imake -I. -TImakefile -f /dev/null

install: mcvert
	install -c -s mcvert $(DESTDIR)$(BINDIR)/mcvert
	install -c -m 0444 mcvert.1 $(DESTDIR)$(MANDIR)/man$(MANEXT)/mcvert.$(MANEXT)
