# ########################################################################
#
#                       Makefile for libjsw
#
#   Rules:
#
#	all	-- builds library.
#	install -- installs library.
#	clean	-- remove object and other work files.
#


# ########################################################################
# Install Options:
#
PREFIX = /usr


# ########################################################################
# Library Name and Version:
#
LIBPFX = libjsw
LIBVER = 1


# ########################################################################
# Compiler Flags:
#   
#   These are definations to enable or disable certain compile time
#   options. Omitting a defination turns that option off.
#
#   Each argument is of the format -D<option> where <option> is
#   one of the following:
#
#	* None available *
#
#   Other arguments include:
#
#       -O#                     Specifies the optimization level the
#                               compiler is to compile at. This (attempts)
#                               to improve the efficiency of the generated
#                               program when it runs. Available values for
#                               # are from 0 to 2 (some compilers allow
#                               higher values). When in doubt, set # to 2.
#
#       -g                      Compile with debugging information,
#                               this is useful for determining why this
#                               program (if it did) crash. However this
#                               may hinder performance, so don't use
#                               this option unless you are attempting
#                               to debug the program.
#
#	-shared			Compile this program as a shared library.
#
CFLAGS  = -O2 -shared


# ########################################################################
# Dependant Libraries:
#
INC     =
LIB     =
LIB_DIR =


# ########################################################################
# Program Source and Header Files:
#
include Makefile.srclist

CC = gcc


# ########################################################################
# Build Rules:
#
all:
	$(CC) $(SRC) $(CFLAGS) $(LIB) $(LIB_DIR) -o $(LIBPFX).so.$(LIBVER)


# ########################################################################
# Install Rules:
#

INSTALL      = install
INSTBINFLAGS = -m 0755
INSTUIDFLAGS = -m 4755
INSTLIBFLAGS = -m 0644
INSTINCFLAGS = -m 0644
INSTMANFLAGS = -m 0444
INSTCFGFLAGS = -m 0644  
INSTDATFLAGS = -m 0444

COPY      = cp
COPYFLAGS = -i -v

MKDIR      = mkdir
MKDIRFLAGS = -p

LINK       = ln
LINKFLAGS  = -s -f

install:
	$(INSTALL) $(INSTBINFLAGS) $(LIBPFX).so.$(LIBVER) $(PREFIX)/lib
	$(LINK) $(LINKFLAGS) $(LIBPFX).so.$(LIBVER) $(PREFIX)/lib/$(LIBPFX).so
	$(MKDIR) $(MKDIRFLAGS) $(PREFIX)/include
	$(INSTALL) $(INSTINCFLAGS) ../include/jsw.h $(PREFIX)/include
	@echo "---------------------------------------------------------------"
	@echo "Library $(LIBPFX) installed in:"
	@echo " "
	@echo "        $(PREFIX)/lib"
	@echo " "
	@echo "Header files are installed in:"
	@echo " "
	@echo "        $(PREFIX)/include"
	@echo " "
	@echo "To link your programs to this library add -ljsw to the compiler"
	@echo "command."
	@echo " "


# ########################################################################
# Maintainance and Misc Rules:
#
clean:
	rm -f a.out core *.o $(LIBPFX).so.$(LIBVER)


# ########################################################################
