################################################################################
# File: Makefile                                                               #
################################################################################
# Makefile for the socketcc library sample application.  This will first make  #
# the sample code into a usable echo program.                                  #
################################################################################
# Written By: Jason But                                                        #
# Copyright:  CTIE - Monash University 2001                                    #
#                                                                              #
# Notes:                                                                       #
#    Version 1.00 - Original Version of application.                           #
################################################################################

################################################################################
# Module compile information.                                                  #
################################################################################
#     ECHO_SRC     - Source filename of echo application.                      #
#     ECHO_TARGET  - Final target filename of echo applicaiton.                #
################################################################################
ECHO_SRC = myecho.cpp
ECHO_TARGET = myecho

################################################################################
# Linker and associated flags.                                                 #
################################################################################
GCC = gcc -lsocketcc

################################################################################
# Makeup of introduction message.                                              #
################################################################################
INFO_LINE =  "===============================================================\n"
INFO_TITLE = "  myecho : Sample Application that uses the SocketCC library.\n"
INFO_VER = " Version      : 1.0\n"
INFO_DEV = " Developed By : CTIE - Monash University\n"

INFO_PROG = $(INFO_LINE)$(INFO_TITLE)$(INFO_LINE)$(INFO_VER)$(INFO_DEV)$(INFO_LINE)

################################################################################
# Descriptions of certain make tasks.                                          #
################################################################################
DESC_ALL =         "Compile and make $(ECHO_TARGET).\n"
DESC_CLEAN =       "Remove any files created for a clean install.\n"

################################################################################
# ALL                                                                          #
################################################################################
# make all and make library perform the same task of resolving to making the   #
# target libary file.                                                          #
################################################################################
all:                pre-compile-info $(ECHO_TARGET)

################################################################################
# make pre-compile-info echos pre-compilation information to the screen.       #
################################################################################
pre-compile-info:
	@echo -e $(INFO_PROG)

################################################################################
# make LIB_TARGET depends on the on all the substituent object files.  These   #
# are linked to create the final target.                                       #
################################################################################
$(ECHO_TARGET):      $(ECHO_SRC)
	@(                                                                          \
        echo -e "Compiling and Linking $(ECHO_SRC) --> $(ECHO_TARGET)...";      \
        $(GCC) -o $(ECHO_TARGET) $(ECHO_SRC);                                   \
        echo Done;                                                              \
        echo                                                                    \
    )

################################################################################
# CLEAN                                                                        #
# MRPROPER                                                                     #
################################################################################
# Remove any files created for a clean install.                                #
################################################################################
clean mrproper::    pre-compile-info
	@(                                                                          \
        echo Removing $(ECHO_TARGET)...;                                        \
        rm -f $(ECHO_TARGET);                                                   \
    )

################################################################################
# HELP                                                                         #
################################################################################
# Help messages.                                                               #
################################################################################
HLP_HELP =    "help\tthis screen.\n"
HLP_ALL =     "all\t"$(DESC_ALL)
HLP_CLEAN =   "clean\t"$(DESC_CLEAN)

HLP_COMMANDS = $(HLP_HELP)$(HLP_ALL)$(HLP_CLEAN)

################################################################################
# make help resolves to echoing available make options.                        #
################################################################################
help:               pre-compile-info
	@echo Makefile Help
	@echo
	@echo Usage: make [help all clean]
	@echo
	@echo -e $(HLP_COMMANDS)

################################################################################
# End of File: Makefile                                                        #
################################################################################
