# makefile for whatis,whatisin,apropos
#
# version: 
#
# $Id$
#
# $Log$
#
# compiler (use second set for MiNT):
SYSINC		= g:/mint/include
SYSLIB		= g:/mint/lib
SPECL		= -nostdlib $(SYSLIB)/crt0.o
CC		= gcc -z -Wall -v -I$(SYSINC)
LD		= gcc -z -Wall -v -L$(SYSLIB) $(SPECL)
LIBS32		= -liio -lgnu
LIBS16		= -liio16 -lgnu16
USRLIBS		=
# if -mshort, use LIBS16...
LIBS		= $(USRLIBS) $(LIBS32)

# compile/link options:
DEFS		= #-DCHECK_MAGIC
OPT		= -O -fomit-frame-pointer
DEBUG		= #-DDEBUG
PROF		=
# use -mshort for 16-bit version (make sure to change libs)
ARCH		=
MISC		=
CFLAGS		= $(DEBUG) $(PROF) $(ARCH) $(MISC) $(OPT) $(DEFS)
LDFLAGS		= $(DEBUG) $(PROF) $(ARCH) $(MISC)

# targets, etc:
SECT		= 1
SUBSECT		=
TARG1		= whatis.ttp
TARG2		= whatisin.ttp
TARG3		= apropos.ttp
TARGETS		= $(TARG1) $(TARG2) $(TARG3)
FIXSTK1		= fixstk 16K
FIXSTK2		= fixstk 16K
FIXSTK3		= fixstk 16K
GVERSION1	= gversion -v 2.0.1
GVERSION2	= gversion -v 2.0.1
GVERSION3	= gversion -v 2.0.1

# commands used here:
NROFF		= nroff
NRFLAGS		= -manx -T -rO1
ECHO		= echo
CP		= cp -p
COMPRESS	= compress
RM		= rm -f

# headers, sources, and objects:
HEADERS		= whatis.h
SRCS1		= whatis.c
SRCS2		= whatisin.c
SRCS3		= apropos.c
COMSRC		= common.c
SRCS		= $(SRCS1) $(SRCS2) $(SRCS3) $(COMSRC)
OBJS1		= whatis.o
OBJS2		= whatisin.o
OBJS3		= apropos.o
COMOBJ		= common.o
OBJS		= $(OBJS1) $(OBJS2) $(OBJS3) $(COMOBJ)



# distribution files (add others as needed):
OTHERS		= readme makefile $(MANSRC) todo
DISTFILES	= $(OTHERS) $(SRCS) $(HEADERS)
LOG		= compile.err

# install directories, etc:
BINDIR		= g:/gnu/bin
MANDIR		= d:/usr/man/man$(SECT)

# for test target:
RUNPARM		=
RUNOUT		=



# directions...
#
directions:
		@$(ECHO) type make all to built $(TARGETS)
		@$(ECHO) type make clean to remove objects
		@$(ECHO) type make clobber to remove objects and $(TARGETS)


# main target (make all)...
#
all:		$(TARGETS) mkwhatis.ttp


$(TARG1):	$(COMOBJ) $(OBJS1)
		$(LD) $(LDFLAGS) -o $(TARG1) $(OBJS1) $(COMOBJ) $(LIBS)
		$(FIXSTK1) $(TARG1)
#		$(GVERSION1) $(TARG1)
		@$(ECHO) done making $(TARG1)

$(TARG2):	$(COMOBJ) $(OBJS2)
		$(LD) $(LDFLAGS) -o $(TARG2) $(OBJS2) $(COMOBJ) $(LIBS)
		$(FIXSTK2) $(TARG2)
#		$(GVERSION2) $(TARG2)
		@$(ECHO) done making $(TARG2)

$(TARG3):	$(COMOBJ) $(OBJS3)
		$(LD) $(LDFLAGS) -o $(TARG3) $(OBJS3) $(COMOBJ) $(LIBS)
		$(FIXSTK3) $(TARG3)
#		$(GVERSION3) $(TARG3)
		@$(ECHO) done making $(TARG3)



mkwhatis.ttp:	mkwhatis.o
		$(LD) $(LDFLAGS) -o mkwhatis.ttp mkwhatis.o $(LIBS)
		fixstk 16K mkwhatis.ttp
		gversion -v 2.0.1 mkwhatis.ttp


# others...
#
clean:
		$(RM) $(OBJS) $(LOG)

clobber:	clean
		$(RM) $(TARGETS)



# dependencies...
#
$(COMOBJ):	$(HEADERS)
$(OBJS1):	$(HEADERS)
$(OBJS2):	$(HEADERS)
$(OBJS3):	$(HEADERS)

