SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = //d/ruby/latest/ext/BigFloat

topdir = //d/ruby/latest
hdrdir = //d/ruby/latest

CC = gcc

CFLAGS   = -DUSEIMPORTLIB -g -O2 
CPPFLAGS = -I$(topdir) -I$(hdrdir) -I${prefix}/include  
DLDFLAGS =  -L//d/ruby/latest 
LDSHARED = dllwrap --target=cygwin --as=as --dlltool-name=dlltool --driver-name=gcc --export-all -s --def=BigFloat.def

RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = cygwin-$(RUBY_INSTALL_NAME)16

prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
#pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/1.6
pkglibdir = $(libdir)/ruby/1.6
archdir = $(pkglibdir)/i686-cygwin


#### End of system configuration section. ####

LOCAL_LIBS =  
LIBS = -L. -l$(RUBY_SO_NAME) 
OBJS = bigfloat.o
TARGET = BigFloat
DLLIB = $(TARGET).so

RUBY = $(topdir)/miniruby.exe -I$(topdir) -I$(hdrdir)/lib
RM = $(RUBY) -r ftools -e "File::rm_f(*Dir[ARGV.join(' ')])"

EXEEXT = .exe

all:		$(DLLIB)

clean:;		@$(RM) *.o *.so *.sl *.a $(DLLIB)
		@$(RM) *.ilk *.exp *.pdb *.bak

distclean:	clean
		@$(RM) Makefile extconf.h conftest.*
		@$(RM) core ruby$(EXEEXT) *~

realclean:	distclean

install:
	@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(archdir)
	@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)


.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
$(DLLIB): $(OBJS)
	$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
###
bigfloat.o: bigfloat.c bigfloat.h $(hdrdir)/ruby.h
