########################################################
##
##      File:  Makefile
##   Project:  Tcl in Modules
##   Created:  Tue Sep  3 10:03:54 1991
##    Author:  John L. Furlani
##		<john.furlani@East.Sun.COM>
##  Revision:  1.2
##  Last Mod:  12/12/91
##
##
##  Description of File:
##	 Makefile for modulecmd
##
########################################################
##
##	Installation
##
#######
##
##  Where modulecmd is placed for install rule
BINDIR=../bin

##
##  Location of the Tcl Source Directory with compiled library
TCLSRCDIR=../tcl6.2

##
##	Compilers
##
CC=gcc

##
##	Where are the Object Files Kept?
##		In OBJDIR!
##
OBJDIR=.OBJ

##
##	Special Suffixes
##
.SUFFIXES:	.C .defs.h .o

##
##	Rule to build an object file in the OBJ directory
##		from source in the current directory
##
$$(OBJDIR)/%.o :	%.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<

##
##	All Source Files C, C++ and Headers
##
##	Keep alphabetic...
##
CFILES= main.c \
	init.c \
	cmdModule.c \
	cmdSetenv.c \
	cmdPath.c \
	cmdAlias.c \
	cmdInfo.c \
	cmdConflict.c \
	cmdMisc.c \
	LocateModule.c \
	utility.c

HFILES= global.h


OBJFILES= $(CFILES:%.c=$(OBJDIR)/%.o)

##
##	Libraries to Link With
##
LDLIBS= -ltcl
LDFLAGS= -L$(TCLSRCDIR)

##
##	Special Defines and Include Directories
##
DEFINES=
INCLUDES= -I. -I$(TCLSRCDIR)
CPPFLAGS= $(DEFINES) $(INCLUDES)

##
##	Default CFLAGS
##
CFLAGS= -O

##
##	Flags for "debug" rule
##
DEBUG_FLAGS= -g

##
##	Name of the Program we're building
##
PROGNAME=./modulecmd

##
##	If rule is debug -- turn on debug flags
##
debug := CFLAGS = $(DEBUG_FLAGS)

##
##	If rule is profile -- assume debug and add profiling
##
profile := CFLAGS = $(DEBUG_FLAGS) -p

all:	$(PROGNAME)
##
##	Build the Program
##
$(PROGNAME):	$(OBJFILES) $(TCLSRCDIR)/libtcl.a
	$(CC) $(CFLAGS) -o $@ $(OBJFILES) $(LDFLAGS) $(LDLIBS)

##
##	Install Myself
##
install:
	-mkdir $(BINDIR)
	install -m 0755 $(PROGNAME) $(BINDIR)

##
##	How to clean up after myself
##
clean:
	rm -f *.o core y.tab.c lex.yy.c $(OBJDIR)/*.o $(PROGNAME)

##
##	Dependencies
##
GLOBAL_HEADERS=global.h $(TCLSRCDIR)/tcl.h $(TCLSRCDIR)/tclHash.h
main.c:		$(GLOBAL_HEADERS)
init.c:		$(GLOBAL_HEADERS)
utility.c:	$(GLOBAL_HEADERS) $(TCLSRCDIR)/regexp.h
LocalModule.c:	$(GLOBAL_HEADERS)
cmdAlias.c:	$(GLOBAL_HEADERS)
cmdConflict.c:	$(GLOBAL_HEADERS)
cmdInfo.c:	$(GLOBAL_HEADERS)
cmdMisc.c:	$(GLOBAL_HEADERS)
cmdModule.c:	$(TCLSRCDIR)/regexp.h $(GLOBAL_HEADERS)
cmdPath.c:	$(TCLSRCDIR)/regexp.h $(GLOBAL_HEADERS)
cmdSetenv.c:	$(GLOBAL_HEADERS)


