#
# Makefile for Tampa Network Operating System (TNOS)
#

#######################
#  Version Variables  #
#######################

VERSION = 1
RELEASE = 0
LEVEL = 0

# This defines whether this is a beta-test version or not. Make it blank
# for release level compiles
BETA = # -DBETA

ifdef BETA
# This is either 'a' for alpha, 'b' for beta, 'pl' for a interim patch
# level, or ignored for release level compiles
SUBTYPE = b

# This will be ignored for release level compiles
SUBLEVEL = 1
endif

VERS = $(BETA) -DVERSION=\"$(VERSION).$(RELEASE)$(LEVEL)$(SUBTYPE)$(SUBLEVEL)\"


#######################
#  Compiler Variables #
#######################

#
# Define whether or not you are using GCC 2.6.x which support ELF and a.out
# 
USEELF = 1
# Use this for GCC 2.5.x or for 2.6.x a.out-only compiler setup
#USEELF =

#
# Define whether or not you wish to compile an ELF executable
#
# !!! Currently (libc-5.0.9) this DOESN'T produce a useable executable !!!
#MAKEELF = 1
# Use this to be safe, not sorry ;-)
MAKEELF =

#
# Linking type - uncomment ONLY one of these
#
# use static linking
LTYPE = -static
# use dynamic linking
#LTYPE =


#######################
# Commands/Parameters #
#######################

# Executable command names
ifdef USEELF
ifndef MAKEELF
CC = gcc -b i486-linuxaout
else
CC = gcc -DMAKEELF
endif
endif
RM = rm -f
MKDIR = mkdir
CHMOD = chmod
DIRMODE= 0755


#######################
# Warnings -- friends #
#######################

#
# Warnings --- disable for less noise, enable for more certainty :-)
#
WARNINGS = -W -Wall -Wpointer-arith -Wcast-qual -Wcast-align \
	   -Wuninitialized -Wtraditional -Wshadow -Werror \
	   -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs \
	   -Wcomment -Wenum-clash -Winline -Wid-clash-31 \
	   $(TOUGHWARNINGS)


TOUGHWARNINGS = # -Wwrite-strings -Wconversion # -Wredundant-decls 



#######################
# Debugging Variables #
#######################

DEBUG =  -g3


#######################
# Directory Pathlists #
#######################

BINDIR=/usr/local/bin
DAEMONDIR=/usr/net/daemons
MANDIR=/usr/man/man1
CBOOK_DIR=/usr/callbook



CFLAGS = -O2 $(WARNINGS) $(DEBUG) $(VERS)
LIB = -lgdbm
ADDED = util.c



BINFILES = convert_appl convert_indiv callbook cbsd analysis cbsmail

all: $(BINFILES)

convert_appl: convert_appl.c $(ADDED) cbs.h
	$(CC) $(CFLAGS) convert_appl.c $(ADDED) -o convert_appl $(LIB)

convert_indiv: convert_indiv.c $(ADDED) cbs.h
	$(CC) $(CFLAGS) convert_indiv.c $(ADDED) -o convert_indiv $(LIB)

callbook: callbook.c $(ADDED) cbs.h
	$(CC) $(CFLAGS) callbook.c $(ADDED) -o callbook $(LIB)

analysis: analysis.c $(ADDED) cbs.h
	$(CC) $(CFLAGS) analysis.c $(ADDED) -o analysis $(LIB)

cbsd: cbsd.c cbs.h
	$(CC) $(CFLAGS) cbsd.c -o cbsd

cbsmail: cbsmail.c
	$(CC) $(CFLAGS) cbsmail.c -o cbsmail

clean:
	$(RM) $(BINFILES)

install: all
	install -m $(DIRMODE) callbook $(BINDIR)
	install -m $(DIRMODE) cbsd $(DAEMONDIR)
	test -d $(CBOOK_DIR) || $(MKDIR) $(CBOOK_DIR)
	$(CHMOD) 777 $(CBOOK_DIR)
	install -m $(DIRMODE) convert_appl $(CBOOK_DIR)
	install -m $(DIRMODE) daily-update $(CBOOK_DIR)
	install -m $(DIRMODE) ftp-fcc-data $(CBOOK_DIR)
	install -m $(DIRMODE) convert_indiv $(CBOOK_DIR)
	install -m $(DIRMODE) analysis $(CBOOK_DIR)
	install -m $(DIRMODE) cbsmail $(CBOOK_DIR)
	test -e $(BINDIR)/callbook_www || \
		ln -s $(BINDIR)/callbook $(BINDIR)/callbook_www


tar.gz:
	-$(RM) cbs$(VERSION).$(RELEASE)$(LEVEL)$(SUBTYPE)$(SUBLEVEL).t*
	tar cvf cbs$(VERSION).$(RELEASE)$(LEVEL)$(SUBTYPE)$(SUBLEVEL).tar *
	gzip cbs$(VERSION).$(RELEASE)$(LEVEL)$(SUBTYPE)$(SUBLEVEL).tar
