#  TERMINFO Program Examples
#  Copyright 2003 by Floyd L. Davidson
#
#  This program is free software; you can redistribute it
#  and/or modify it under the terms of the GNU General Public
#  License as published by the Free Software Foundation;
#  either version 2, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be
#  useful, but WITHOUT ANY WARRANTY; without even the implied
#  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#  PURPOSE.  See the GNU General Public License for details.
#
#  Makefile -- TERMINFO Program Examples
#
#  $Id: Makefile,v 1.1.0.0 2003/11/05 19:39:36 floyd Exp floyd $
#
SHELL = /bin/sh
.SUFFIXES:
.SUFFIXES: .c .o

#
# Turn on just about everything reasonably possible
#
GCC_WRNG =  -Wcast-align -Wcast-qual \
	    -Wshadow -Wnested-externs -Wstrict-prototypes \
            -Waggregate-return -Wmissing-prototypes \
	    -Wbad-function-cast -Wmissing-declarations
#            -Wtraditional

GCC3_WRNG = -Wpointer-arith -Wfloat-equal

#
# Comment out as needed...
#
GCC_OPTIM  = -O -pipe
GCC_SYMTAB = -g
GCC_ANSI   = -ansi
GCC_PEDANT = -pedantic
#
# For gcc 3 pick one of the following:
#
#CCSTD	= -std=gnu89  ${GCC3_WRNG}
#CCSTD	= -std=gnu99  ${GCC3_WRNG}
#CCSTD	= -std=c89    ${GCC3_WRNG}
CCSTD	= -std=c99    ${GCC3_WRNG}

#CCSRC	= -D_POSIX_SOURCE
#CCSRC	= -D_BSD_SOURCE
CCSRC	= -D_GNU_SOURCE

# 
GCC_DEBUG  = ${GCC_SYMTAB} ${GCC_OPTIM} ${GCC_ANSI} ${GCC_PEDANT} -Wall -W

#
# Pick only one of the following to select a compiler
#
#CC	= gcc
#CC	= gcc	  ${CCSTD} ${CCSRC}
#CC	= gcc-3.0 ${CCSTD} ${CCSRC}
CC	= gcc-3.3 ${CCSTD} ${CCSRC}

LD   = ${CC}
LIBS = -lncurses
OPTS = ${GCC_DEBUG} ${GCC_WRNG} ${GCC_FFLAGS}

HDRS    = 
SRCS    = termidemo1.c termidemo2.c

S       = $(SRCS) $(HDRS) Makefile README index.html netrc
OBJS    = $(SRCS:.c=.o)
MANSECT = 1

TARGETS = depend termidemo1 termidemo2

ifeq (depend,$(wildcard depend))
TARGETS = termidemo1 termidemo2
else
TARGETS = depend
endif

all: $(TARGETS)

#
#
termidemo1:	termidemo1.o
		${LD} $< $(LIBS) $(LDOPTS) -o $@

termidemo2:	termidemo2.o
		${LD} $< $(LIBS) $(LDOPTS) -o $@

depend: $(SRCS) $(HDRS)
	${CC} -MM ${SRCS} > depend
	@echo ""
	@echo "**** If \"make\" stops here, run \"make\" again. ****"
        
clean:
	rm -f *.o *[~%] *core

cleanall: clean
	rm -f ${MISC}
	rm -rf Msgs

.c.o:
	$(CC) $(OPTS) -c $<

# bundle with tar
tar:
	tar -czf  termidemo.tgz README COPYING Makefile ${SRCS}
	tar -zvtf termidemo.tgz

# incremental RCS archive 
rcs: 
	ci -f -l ChangeLog
	ci -f -l -m"See ChangeLog for changes."  ${S} 
 
# initialize RCS archive 
initrcs: 
	rcs -i ChangeLog ${S} 
	ci  -l ChangeLog ${S} 
	rcs -b1.1.0.0 ChangeLog ${S} 
	rcs -u1.1 ChangeLog  ${S} 
	ci  -f -l1.1.0.0 ChangeLog ${S} 

#  magically upload everything to my web site
web:
	for i in README COPYING Makefile ${SRCS} ;\
        do ../genhtml $${i} ; done
	../upload

# DO NOT DELETE

foo.o: /usr/include/stdio.h
# /usr/include/stdio.h includes:
#	libio.h
foo.o: /usr/include/libio.h
# /usr/include/libio.h includes:
#	_G_config.h
#	sys/cdefs.h
foo.o: /usr/include/_G_config.h /usr/include/sys/cdefs.h

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