##########################################################################
## ^FILE: Makefile - make file for the CmdLine C++ library
##
## ^DESCRIPTION:
##    This is the makefile that is used to build and install the CmdLine
##    library. In order to get CmdLine to build on your system you may
##    need to change some of the "variables" mentioned below. You may also
##    need to redefine some of the commands that are used.
##
## ^TARGETS:
##    all     : make the library and the test program
##    library : make the library
##    test    : make the test program
##    install : build and install the library and its include files
##    clean   : remove all intermediate files generated by the build
##    clobber : remove all files generated by the build
##
## ^VARIABLES:
##    OS         : specify the host operating system (default=unix)
##    STYLE      : specify the desired command-line syntax (default=unix)
##    FLAG       : debugging/optimization flags to the compiler (default=-g)
##    TESTDEFS   : #defines used for testing
##    USRDEFS    : #defines used for building (default=unix)
##    OPTIONS    : any other compiler flags to use
##
## ^HISTORY:
##    04/10/92	Brad Appleton	<bradapp@enteract.com>	Created
###^^#####################################################################

include ../../Config.mk

###
# operating-system dependent stuff
###
# OSDEFS=$(DEF)$(OS) $(DEF)$(.UNIVERSE)_universe
STYLE=$(OS)

###
# compilation options
###
INCLUDES=$(INC)$(CURDIR)
FLAG=$(OPT)
# FLAG=$(DBG)
TESTDEFS=
# USRDEFS=$(DEF)DEBUG_CMDLINE
DEFINES=$(OSDEFS) $(USRDEFS) $(TESTDEFS) $(DEF)$(STYLE)_style
OPTIONS=
CFLAGS=$(FLAG) $(INCLUDES) $(DEFINES) $(OPTIONS)

###
# libraries
###
LIBRARY=lib$(LIBNAME)$(LIBEXT)

###
# files used
###
OBJS=argiter$(OBJEXT) cmdarg$(OBJEXT) cmdargs$(OBJEXT) \
   cmdline$(OBJEXT) dump$(OBJEXT)  fifolist$(OBJEXT) \
   parse$(OBJEXT) patchlevel$(OBJEXT) private$(OBJEXT) \
   strindent$(OBJEXT) $(STYLE)$(OBJEXT) usage$(OBJEXT)

###
# target dependencies
###
all: library test

library: $(LIBRARY)

test: cmdtest$(EXECEXT)

cmdtest$(EXECEXT): cmdtest$(OBJEXT) $(OBJS)
	$(CC) $(EXE) $@ cmdtest$(OBJEXT) $(LIBRARY)

$(LIBRARY): $(OBJS)
	$(AR) $@ $(OBJS)
	$(RANLIB) $@

###
# maintenance dependencies
###
install: $(LIBRARY) $(LIBDIR) $(INCDIR) cmdline.h cmdargs.h
	-$(RM) $(LIBDIR)$(LIBRARY) $(INCDIR)cmdline.h $(INCDIR)cmdargs.h
	$(CP) $(LIBRARY) $(LIBDIR)$(LIBRARY)
	$(CP) cmdline.h $(INCDIR)cmdline.h
	$(CP) cmdargs.h $(INCDIR)cmdargs.h

clean:
	-$(RM) *$(OBJEXT) core .exrc *~ \#*\#

clobber: clean
	-$(RM) *$(LIBEXT) cmdtest tags TAGS

###
# object dependencies
###
argiter$(OBJEXT) : argiter$(CEXT) cmdline.h

cmdarg$(OBJEXT) : cmdarg$(CEXT) cmdline.h

cmdargs$(OBJEXT) : cmdargs$(CEXT) cmdargs.h cmdline.h exits.h fifolist.h

cmdline$(OBJEXT) : cmdline$(CEXT) cmdline.h cmdargs.h arglist.h fifolist.h \
   states.h

cmdtest$(OBJEXT) : cmdtest$(CEXT) cmdargs.h cmdline.h

dump$(OBJEXT) : dump$(CEXT) cmdline.h arglist.h fifolist.h states.h

fifolist$(OBJEXT) : fifolist$(CEXT) cmdline.h fifolist.h

parse$(OBJEXT) : parse$(CEXT) exits.h states.h cmdline.h arglist.h \
   fifolist.h

patchlevel$(OBJEXT) : patchlevel$(CEXT) cmdline.h

private$(OBJEXT) : private$(CEXT) cmdline.h states.h arglist.h fifolist.h

strindent$(OBJEXT) : strindent$(CEXT) cmdline.h

unix$(OBJEXT) : unix$(CEXT) exits.h cmdline.h states.h

usage$(OBJEXT) : usage$(CEXT) cmdline.h states.h arglist.h fifolist.h
