
# ------------------------------------------------------------------------
# 	Makefile for static version of BLT library
# ------------------------------------------------------------------------

# ------------------------------------------------------------------------
# 	C Compiler options 
# ------------------------------------------------------------------------

BLT_LIBRARY =	@BLT_LIBRARY@
TCLLIBPATH   =	@TCL_LIB_DIR@/tcl@TCL_VERSION@
CC =		@CC@
CFLAGS =	@CFLAGS@ 
DEFINES =	@DEFINES@ -DWIN32
EXTRA_CFLAGS =	@GCCFLAGS@
LDFLAGS =	@LDFLAGS@ @LD_RUN_PATH@
SHLIB_LD =	@SHLIB_LD@ 
SHLIB_LD_FLAGS = @SHLIB_LD_FLAGS@ 
version =	@BLT_MAJOR_VERSION@@BLT_MINOR_VERSION@
cyg_prefix =	@BLT_LIB_PREFIX@

# ------------------------------------------------------------------------
# 	Source and targer installation directories 
# ------------------------------------------------------------------------

bindir =	$(exec_prefix)/bin
exec_prefix =	@exec_prefix@
incdir =	$(prefix)/include
libdir = 	@libdir@
scriptdir =	@BLT_LIBRARY@

prefix =	@prefix@
srcdir =	@srcdir@

instdirs = $(prefix) $(exec_prefix) $(bindir) $(scriptdir) $(libdir) $(incdir)

# ------------------------------------------------------------------------
# 	Directories containing Tcl and Tk include files and libraries
# ------------------------------------------------------------------------

INCLUDES =	-I. -I$(srcdir) -I$(srcdir)/../win @INCLUDES@

# ------------------------------------------------------------------------
#       Libraries directives for Tcl, Tk, X11, and BLT
# ------------------------------------------------------------------------

LIBS =		@LIB_SPECS@ @EXTRA_LIB_SPECS@ 
TCL_ONLY_LIBS = @TCL_ONLY_LIB_SPECS@ @EXTRA_LIB_SPECS@

# ------------------------------------------------------------------------
# 	You don't need to edit anything beyond this point
# ------------------------------------------------------------------------

N_OBJS       =	bltTed.o
V3_OBJS       =	bltTri.o bltGrMt.o 

TK_OBJS       =	tkButton.o tkFrame.o tkScrollbar.o 

GRAPH_OBJS =	bltGrAxis.o \
		bltGrBar.o \
		bltGrElem.o \
		bltGrGrid.o \
		bltGrHairs.o \
		bltGrLegd.o \
		bltGrLine.o \
		bltGrMarker.o \
		bltGrMisc.o \
		bltGrPen.o \
		bltGrPs.o \
		bltGraph.o 

TCL_ONLY_OBJS =	bltAlloc.o \
		bltArrayObj.o \
		bltBgexec.o \
		bltChain.o \
		bltDebug.o \
		bltHash.o \
		bltList.o \
		bltNsUtil.o \
		bltParse.o \
		bltPool.o \
		bltSpline.o \
		bltSwitch.o \
		bltTree.o \
		bltTreeCmd.o \
		bltUtil.o \
		bltVecCmd.o \
		bltVecMath.o \
		bltVecObjCmd.o \
		bltVector.o \
		bltWatch.o  \
		bltWinPipe.o \
		bltWinUtil.o \
		bltWinDde.o \
		pure_api.o

DEMO_OBJS     =	tkConsole.o bltWinMain.o

OBJS =		$(GRAPH_OBJS) \
		$(TCL_ONLY_OBJS) \
		bltBeep.o \
		bltBind.o \
		bltBitmap.o \
		bltBusy.o \
		bltCanvEps.o \
		bltConfig.o \
		bltContainer.o \
		bltDragdrop.o \
		bltHierbox.o \
		bltHtext.o \
		bltImage.o \
		bltWinImage.o \
		bltPs.o \
		bltTable.o \
		bltTabnotebook.o \
		bltTabset.o \
		bltText.o \
		bltTile.o \
		bltTreeView.o \
		bltTreeViewCmd.o \
		bltTreeViewEdit.o \
		bltTreeViewColumn.o \
		bltTreeViewStyle.o \
		bltWinDraw.o \
		bltWinPrnt.o \
		bltWindow.o \
		bltObjConfig.o \
		bltWinop.o \
		$(TK_OBJS) $(N_OBJS) 

NOT_YET       =	bltContainer.o bltCutBuffer.o bltColor.o

# GNU Make-specific macro
SRCS =		$(patsubst %.o,$(srcdir)/%.c,$(OBJS)) 

bltwish =	${cyg_prefix}bltwish$(version).exe
bltsh =		${cyg_prefix}bltsh$(version).exe
headers =	$(srcdir)/blt.h \
		$(srcdir)/bltBind.h \
		$(srcdir)/bltChain.h \
		bltHash.h \
		$(srcdir)/bltList.h \
		$(srcdir)/bltPool.h \
		$(srcdir)/bltTree.h \
		$(srcdir)/bltVector.h 

lib_a =		libBLT$(version).a
tcl_only_lib_a =  libBLTlite$(version).a
lib_so =	$(cyg_prefix)BLT$(version).dll
tcl_only_lib_so =  $(cyg_prefix)BLTlite$(version).dll

CC_SWITCHES =	$(EXTRA_CFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES)
INSTALL =	@INSTALL@
INSTALL_DATA =	@INSTALL_DATA@
INSTALL_ROOT =  
RANLIB =	@RANLIB@
SHELL =		/bin/sh
AR =		ar rc
RM =		rm -f
LINT =		lint
LINTFLAGS =	-axhbns
XREF =		cxref
XREFFLAGS =	-dltR
LN_S =		@LN_S@
VPATH =		$(srcdir)

all: $(tcl_only_lib_so) $(lib_so) $(bltsh) $(bltwish) 

$(bltwish): $(lib_a) $(srcdir)/tkConsole.c $(srcdir)/bltWinMain.c
	$(RM) $(bltwish)
	$(CC) $(CC_SWITCHES) $(LDFLAGS) -o $(bltwish) \
		-DTCLLIBPATH=\"$(TCLLIBPATH)\" \
		$(srcdir)/bltWinMain.c $(srcdir)/tkConsole.c \
		$(lib_a) $(LIBS)

$(bltsh): $(tcl_only_lib_a) $(srcdir)/bltWinMain.c
	$(RM) $(bltsh)
	$(CC) $(CC_SWITCHES) $(LDFLAGS) -DTCL_ONLY -o $(bltsh) \
		-DTCLLIBPATH=\"$(TCLLIBPATH)\" \
		$(srcdir)/bltWinMain.c $(tcl_only_lib_a) $(TCL_ONLY_LIBS) 

$(lib_a): $(OBJS) $(srcdir)/bltInit.c
	$(CC) -c $(CC_SWITCHES) -DBLT_LIBRARY=\"$(BLT_LIBRARY)\" \
		$(srcdir)/bltInit.c
	$(RM) $@
	$(AR) $@ $(OBJS) bltInit.o
	$(RANLIB) $@

$(lib_so): $(OBJS)
	$(CC) -c $(CC_SWITCHES) -DBLT_LIBRARY=\"$(BLT_LIBRARY)\" \
		$(srcdir)/bltInit.c
	$(RM) $@
	$(SHLIB_LD) $(SHLIB_LD_FLAGS) -o $@ bltInit.o $(OBJS) $(LIBS) \
		$(EXTRA_SHLIB_FLAGS)

$(tcl_only_lib_a):  $(TCL_ONLY_OBJS) $(srcdir)/bltInit.c
	$(CC) -c $(CC_SWITCHES) -DTCL_ONLY -DBLT_LIBRARY=\"$(BLT_LIBRARY)\" \
		$(srcdir)/bltInit.c
	$(RM) $@
	$(AR) $@ $(TCL_ONLY_OBJS) bltInit.o
	$(RANLIB) $@

$(tcl_only_lib_so):  $(TCL_ONLY_OBJS) $(srcdir)/bltInit.c
	$(CC) -c $(CC_SWITCHES) -DTCL_ONLY -DBLT_LIBRARY=\"$(BLT_LIBRARY)\" \
		$(srcdir)/bltInit.c
	$(RM) $@
	$(SHLIB_LD) $(SHLIB_LD_FLAGS) -o $@ bltInit.o $(TCL_ONLY_OBJS) \
		$(TCL_ONLY_LIBS)

install: mkdirs install-lib install-demo install-headers

install-demo: $(bltwish) $(bltsh)
	$(INSTALL) -m 0755 $(bltwish) $(INSTALL_ROOT)$(bindir)
	$(INSTALL) -m 0755 $(bltsh) $(INSTALL_ROOT)$(bindir)

install-lib: $(lib_a) $(tcl_only_lib_a) $(lib_so) $(tcl_only_lib_so)
	$(INSTALL_DATA) $(lib_a) $(INSTALL_ROOT)$(libdir)
	$(RANLIB) $(INSTALL_ROOT)$(libdir)/$(lib_a)
	$(INSTALL_DATA) $(tcl_only_lib_a) $(INSTALL_ROOT)$(libdir)
	$(RANLIB) $(INSTALL_ROOT)$(libdir)/$(tcl_only_lib_a)
	$(INSTALL) -m 0755 $(lib_so) $(INSTALL_ROOT)$(bindir)
	$(INSTALL) -m 0755 $(tcl_only_lib_so) $(INSTALL_ROOT)$(bindir)

mkdirs:
	@for i in $(instdirs) ; do \
          if test -d $(INSTALL_ROOT)$$i ; then \
            : ; \
          else \
            echo " mkdir $(INSTALL_ROOT)$$i" ; \
            mkdir $(INSTALL_ROOT)$$i ; \
          fi ; \
        done

install-headers:
	@for i in $(headers) ; do \
	    echo "installing $$i..." ; \
	    $(INSTALL_DATA) -m 0444 $$i $(INSTALL_ROOT)$(incdir) ; \
	done

lint:
	$(LINT) $(LINTFLAGS) $(DEFINES) $(INCLUDES) $(SRCS)

xref:
	$(XREF) $(XREFFLAGS) $(DEFINES) $(INCLUDES) $(SRCS)

clean:
	$(RM) $(OBJS) bltInit.o $(lib_a) $(tcl_only_lib_a) \
		$(lib_so) $(tcl_only_lib_so) \
		$(bltsh)* $(bltwish)* .pure* *~

distclean: clean
	$(RM) $(srcdir)/*.bak $(srcdir)/*\~ $(srcdir)/"#"*  Makefile
	$(RM) bltConfig.h bltHash.h Makefile TAGS

.c.o:
	$(CC) -c $(CC_SWITCHES) $<

