USER = lifestlr
GROUP= users

################################################
# Put the name of the executable to be created

		NAME	=	index


################################################
# Match these to your system configuration

		ROOTDIR =	/html2cpp
		BINDIR	=	$(ROOTDIR)/bin
		OBJDIR	=	$(ROOTDIR)/obj
		##
		##  For the INSTALL to work properly, this has to be the
		## the location of you CGI-Bin directory
		CGIBINDIR =	/var/httpd/cgi-bin/$(USER)

################################################
# This will be filled in with the 'NAME = ' statement

		HTMLDOC	=	$(NAME).html
		HTMLCPP =	$(NAME).c
		HTMLOBJ =	$(OBJDIR)/$(NAME).o

################################################
# You shouldn't need to change below this line #
#############################################################################
		SRC1	=	counter.c 
		SRC2	=	cgiframe.c 
		SRC3	=	process_query.c
		SOURCES	=	$(SRC1) $(SRC2) $(SRC3) $(HTMLCPP) 
		OBJ1	=	$(OBJDIR)/counter.o 
		OBJ2	=	$(OBJDIR)/cgiframe.o 
		OBJ3	=	$(OBJDIR)/process_query.o
		OBJECTS	=	$(OBJ1) $(OBJ2) $(OBJ3) $(HTMLOBJ)
		HEADERS	=	prototypes.h

		MAKEHTML=	html2cpp $(HTMLDOC) $(HTMLCPP)
#-------==============================================================-------#

all:	clean compile link end

convert:
	@echo "Converting HTML Document...."
	@( if test ! -e "$(BINDIR)/html2cpp"; then make html2cpp; fi )
	@$(MAKEHTML)

compile:
	@echo "Compiling...."
	@( if test ! -d "$(OBJDIR)"; then mkdir $(OBJDIR); fi )
	@g++ -c $(SRC1) -o $(OBJ1)
	@g++ -c $(SRC2) -o $(OBJ2)
	@g++ -c $(SRC3) -o $(OBJ3)
	@g++ -c $(HTMLCPP) -o $(HTMLOBJ)

clean:
	@echo "Cleaning...."
	@rm -f $(OBJDIR)/$(OBJECTS)
	@rm -f $(BINDIR)/$(NAME)

link:
	@echo "Linking...."
	@( if test ! -d "$(BINDIR)"; then mkdir $(BINDIR); fi )
	@g++ $(OBJ1) $(OBJ2) $(OBJ3) $(HTMLOBJ) -o $(BINDIR)/$(NAME)

end:
	@echo "All Finished...."
	@echo "@>--,'---- Have a nice day"


html2cpp:
	@echo "Building Converter...."
	@( if test ! -d "$(BINDIR)"; then mkdir $(BINDIR); fi )
	@g++ html2cpp.c -o /$(BINDIR)/html2cpp

install:
	@echo "Installing...."
	@cp $(BINDIR)/$(NAME) $(CGIBINDIR)
	@chown $(USER).$(GROUP) $(CGIBINDIR)/$(NAME)
	@echo "Finished installing.... Go check it out!"

uninstall:
	@echo "Uninstalling...."
	@( if test ! -e "$(CGIBINDIR)/$(NAME)"; then echo "Nothing to do for uninstall"; fi )
	@( if test -e "$(CGIBINDIR)/$(NAME)"; then rm -f $(CGIBINDIR)/$(NAME); fi )
	@echo "Finished uninstall...  Have a good day"
