#-*- Makefile -*-
include $(RHOME)/src/gnuwin32/MkRules

all: implibs $(RHOME)/library/tcltk/libs/tcltk.dll

ifdef DEBUG
  DLLFLAGS=
  DEBUGFLAG=-g -Wall
else
  DLLFLAGS=-s
  DEBUGFLAG=-Wall
endif

DLLNAME = tcltk
implibs: libtcl$(TCL_VERSION).a libtk$(TCL_VERSION).a
libtcl$(TCL_VERSION).a: tcl$(TCL_VERSION).def
libtk$(TCL_VERSION).a: tk$(TCL_VERSION).def
tcl$(TCL_VERSION).def: tcl.def
	$(SED) -e 's/@VER@/$(TCL_VERSION)/' $< > $@
tk$(TCL_VERSION).def: tk.def
	$(SED) -e 's/@VER@/$(TCL_VERSION)/' $< > $@


OBJS = init.o tcltk.o tcltk_win.o
CFLAGS = -I$(RHOME)/src/include $(DEBUGFLAG) -O2 -I "$(TCL_HOME)"/include -DWin32

DLLLIBS = -L$(RHOME)/src/gnuwin32 -lR -L. -ltcl$(TCL_VERSION) -ltk$(TCL_VERSION)

RESFLAGS=--include-dir $(RHOME)/src/include
tcltk_res.o: tcltk_res.rc $(RHOME)/src/include/Rversion.h

$(DLLNAME).a: $(OBJS) #
	$(RM) -f $@
	$(AR) cr $@ *.o
	$(RANLIB) $@

$(DLLNAME).dll : $(DLLNAME).a tcltk_res.o
$(RHOME)/library/tcltk/libs/tcltk.dll: $(RHOME)/library/tcltk/libs $(DLLNAME).dll
	$(CP) $(DLLNAME).dll $@

$(RHOME)/library/tcltk/libs:
	$(MKDIR) $@

clean:
	$(RM) $(DLLNAME).dll *.a $(OBJS) $(DLLNAME).def
