Project

General

Profile

Bug #277 » Makefile

autoconf-generated Makefile - roberto (Ollivier Robert), 07/15/2008 09:44 PM

 
SHELL = /bin/sh
NULLCMD = :

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

srcdir = ..
hdrdir = $(srcdir)/include

CC = gcc-mp-4.2
YACC = bison
PURIFY =
AUTOCONF = autoconf

MKFILES = Makefile
BASERUBY = ruby

prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
sbindir = ${exec_prefix}/sbin
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
datarootdir = ${prefix}/share
datadir = ${datarootdir}
arch = i686-darwin8.11.1
sitearch = i686-darwin8.11.1
sitedir = ${libdir}/ruby/site_ruby

TESTUI = console
TESTS =
RDOCTARGET = install-doc

EXTOUT = .ext
RIDATADIR = $(DESTDIR)$(datadir)/ri/$(MAJOR).$(MINOR)/system
arch_hdrdir = $(EXTOUT)/include/$(arch)
VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir):$(srcdir)/enc:$(srcdir)/missing

empty =
OUTFLAG = -o $(empty)
COUTFLAG = -o $(empty)
CFLAGS = -O -pipe -I/opt/local/include -pipe -fno-common ${cflags}
cflags = ${optflags} ${debugflags}
optflags =
debugflags =
warnflags = @warnflags@
XCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) ${cppflags}
LDFLAGS = $(CFLAGS) -L. -L/opt/local/lib
EXTLDFLAGS =
XLDFLAGS = $(EXTLDFLAGS)
EXTLIBS =
LIBS = -lpthread -ldl -lobjc $(EXTLIBS)
MISSING = ${LIBOBJDIR}lgamma_r.o
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
DLDFLAGS = $(EXTLDFLAGS)
SOLIBS =
MAINLIBS =
ARCHMINIOBJS = dmydln.o
BUILTIN_ENCOBJS = ascii.$(OBJEXT) us_ascii.$(OBJEXT) unicode.$(OBJEXT) utf_8.$(OBJEXT)

RUBY_INSTALL_NAME=ruby
RUBY_SO_NAME=$(RUBY_INSTALL_NAME)
EXEEXT =
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
RUBY = $(RUBY_INSTALL_NAME)
MINIRUBY = ./miniruby$(EXEEXT) -I$(srcdir)/lib $(MINIRUBYOPT)
RUNRUBY = $(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT) $(RUNRUBYOPT) --

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

MAJOR= 1
MINOR= 9
TEENY= 0

LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBY_SO = lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)
LIBRUBY_ALIASES= lib$(RUBY_SO_NAME).so
LIBRUBY = $(LIBRUBY_A)
LIBRUBYARG = $(LIBRUBYARG_STATIC)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
LIBRUBYARG_SHARED =

THREAD_MODEL = pthread

PREP = miniruby$(EXEEXT)
ARCHFILE =
SETUP =
EXTSTATIC =
SET_LC_MESSAGES = env LC_MESSAGES=C

CP = cp
MV = mv
RM = rm -f
NM =
AR = ar
ARFLAGS = rcu
RANLIB = ranlib
AS = as
ASFLAGS =
IFCHANGE = $(srcdir)/tool/ifchange
SET_LC_MESSAGES = env LC_MESSAGES=C

OBJEXT = o
ASMEXT = S
DLEXT = bundle
MANTYPE = doc

INSTALLED_LIST= .installed.list
#### End of variables

all:

.DEFAULT: all

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:

miniruby$(EXEEXT):
@$(RM) $@
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE) $(LIBS) $(OUTFLAG)$@

$(PROGRAM):
@$(RM) $@
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) $(OUTFLAG)$@

# We must `rm' the library each time this rule is invoked because "updating" a
# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
# supported.
$(LIBRUBY_A):
@$(RM) $@
$(AR) $(ARFLAGS) $@ $(OBJS) $(DMYEXT)
@-$(RANLIB) $@ 2> /dev/null || true

$(LIBRUBY_SO):
@-$(PRE_LIBRUBY_UPDATE)
$(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(OUTFLAG)$@
@-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link if File.exist? link; \
File.symlink "$(LIBRUBY_SO)", link}' \
$(LIBRUBY_ALIASES) || true

fake.rb: Makefile
@echo ' \
class Object; \
CROSS_COMPILING = RUBY_PLATFORM; \
remove_const :RUBY_PLATFORM; \
remove_const :RUBY_VERSION; \
RUBY_PLATFORM = "i686-darwin8.11.1"; \
RUBY_VERSION = "1.9.0"; \
end; \
if RUBY_PLATFORM =~ /mswin|bccwin|mingw/; \
class File; \
remove_const :ALT_SEPARATOR; \
ALT_SEPARATOR = "\\"; \
end; \
end; \
' > $@

Makefile: $(srcdir)/Makefile.in $(srcdir)/enc/Makefile.in

$(MKFILES): config.status $(srcdir)/common.mk
MAKE=$(MAKE) $(SHELL) ./config.status
@{ \
echo "all:; -@rm -f conftest.mk"; \
echo "conftest.mk: .force; @echo AUTO_REMAKE"; \
echo ".force:"; \
} > conftest.mk || exit 1; \
$(MAKE) -f conftest.mk | grep '^AUTO_REMAKE$$' >/dev/null 2>&1 || \
{ echo "Makefile updated, restart."; exit 1; }

config.status: $(srcdir)/configure $(srcdir)/enc/Makefile.in
MINIRUBY="$(MINIRUBY)" $(SHELL) ./config.status --recheck

$(srcdir)/configure: $(srcdir)/configure.in
cd $(srcdir) && $(AUTOCONF)

# Things which should be considered:
# * with gperf v.s. without gperf
# * ./configure v.s. ../ruby/configure
# * GNU make v.s. HP-UX make # HP-UX make invokes the action if lex.c and keywords has same mtime.
# * svn checkout generate a file with mtime as current time
# * XFS has a mtime with fractional part
lex.c: keywords
if cmp -s $(srcdir)/lex.c.src $?; then \
cp $(srcdir)/lex.c.blt $@; \
else \
gperf -C -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? > $@.tmp && \
mv $@.tmp $@ && \
cp $? $(srcdir)/lex.c.src && \
cp $@ $(srcdir)/lex.c.blt; \
fi

.c.o:
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $<

.s.o:
$(AS) $(ASFLAGS) -o $@ $<

.c.S:
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -S $<

clean-local::
@$(RM) ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output

distclean-local::
@$(RM) ext/config.cache $(RBCONFIG)

ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c

bin: $(PROGRAM) $(WPROGRAM)
lib: $(LIBRUBY)
dll: $(LIBRUBY_SO)

.SUFFIXES: .inc

RUBYLIB = -
RUBYOPT = -

STATIC_RUBY = static-ruby

EXTCONF = extconf.rb
RBCONFIG = ./.rbconfig.time
LIBRUBY_EXTS = ./.libruby-with-ext.time
RDOCOUT = $(EXTOUT)/rdoc

DMYEXT = dmyext.$(OBJEXT)
NORMALMAINOBJ = main.$(OBJEXT)
MAINOBJ = $(NORMALMAINOBJ)
EXTOBJS =
DLDOBJS = $(DMYEXT)
MINIOBJS = $(ARCHMINIOBJS) dmyencoding.$(OBJEXT) miniprelude.$(OBJEXT)

COMMONOBJS = array.$(OBJEXT) \
bignum.$(OBJEXT) \
class.$(OBJEXT) \
compar.$(OBJEXT) \
complex.$(OBJEXT) \
dir.$(OBJEXT) \
enum.$(OBJEXT) \
enumerator.$(OBJEXT) \
error.$(OBJEXT) \
eval.$(OBJEXT) \
load.$(OBJEXT) \
proc.$(OBJEXT) \
file.$(OBJEXT) \
gc.$(OBJEXT) \
hash.$(OBJEXT) \
inits.$(OBJEXT) \
io.$(OBJEXT) \
marshal.$(OBJEXT) \
math.$(OBJEXT) \
numeric.$(OBJEXT) \
object.$(OBJEXT) \
pack.$(OBJEXT) \
parse.$(OBJEXT) \
process.$(OBJEXT) \
prec.$(OBJEXT) \
random.$(OBJEXT) \
range.$(OBJEXT) \
rational.$(OBJEXT) \
re.$(OBJEXT) \
regcomp.$(OBJEXT) \
regenc.$(OBJEXT) \
regerror.$(OBJEXT) \
regexec.$(OBJEXT) \
regparse.$(OBJEXT) \
regsyntax.$(OBJEXT) \
ruby.$(OBJEXT) \
signal.$(OBJEXT) \
sprintf.$(OBJEXT) \
st.$(OBJEXT) \
string.$(OBJEXT) \
struct.$(OBJEXT) \
time.$(OBJEXT) \
transcode.$(OBJEXT) \
util.$(OBJEXT) \
variable.$(OBJEXT) \
version.$(OBJEXT) \
blockinlining.$(OBJEXT) \
compile.$(OBJEXT) \
debug.$(OBJEXT) \
iseq.$(OBJEXT) \
vm.$(OBJEXT) \
vm_dump.$(OBJEXT) \
thread.$(OBJEXT) \
cont.$(OBJEXT) \
id.$(OBJEXT) \
$(BUILTIN_ENCOBJS) \
$(MISSING)

OBJS = dln.$(OBJEXT) \
encoding.$(OBJEXT) \
prelude.$(OBJEXT) \
$(COMMONOBJS)

GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)

PRELUDE_SCRIPTS = $(srcdir)/prelude.rb $(srcdir)/enc/prelude.rb $(srcdir)/gem_prelude.rb
PRELUDES = prelude.c miniprelude.c golf_prelude.c

SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--extout="$(EXTOUT)" \
--mflags="$(MFLAGS)" \
--make-flags="$(MAKEFLAGS)"
EXTMK_ARGS = $(SCRIPT_ARGS) --extension $(EXTS) --extstatic $(EXTSTATIC) --
INSTRUBY_ARGS = $(SCRIPT_ARGS) \
--data-mode=$(INSTALL_DATA_MODE) \
--prog-mode=$(INSTALL_PROG_MODE) \
--installed-list $(INSTALLED_LIST)
INSTALL_PROG_MODE = 0755
INSTALL_DATA_MODE = 0644

PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil' -- \
$(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)

TESTSDIR = $(srcdir)/test
TESTWORKDIR = testwork

BOOTSTRAPRUBY = $(BASERUBY)

COMPILE_PRELUDE = $(MINIRUBY) -I$(srcdir) -rrbconfig $(srcdir)/tool/compile_prelude.rb

VCS = svn

all: $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY) encs
@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS)
prog: $(PROGRAM) $(WPROGRAM)

loadpath: $(PREP)
$(MINIRUBY) -e 'p $$:'

$(PREP): $(MKFILES)

miniruby$(EXEEXT): config.status $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE)

GORUBY = go$(RUBY_INSTALL_NAME)
golf: $(LIBRUBY) $(GOLFOBJS)
$(MAKE) $(MFLAGS) MAINOBJ="$(GOLFOBJS)" PROGRAM=$(GORUBY)$(EXEEXT) program

program: $(PROGRAM)

$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)

$(LIBRUBY_A): $(OBJS) $(DMYEXT) $(ARCHFILE)

$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) $(LIBRUBY_A) $(PREP) $(LIBRUBY_SO_UPDATE) $(BUILTIN_ENCOBJS)

$(LIBRUBY_EXTS):
@exit > $@

$(STATIC_RUBY)$(EXEEXT): $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A)
@$(RM) $@
$(PURIFY) $(CC) $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)$@ $(LDFLAGS) $(XLDFLAGS)

ruby.imp: $(COMMONOBJS)
@$(NM) -Pgp $(COMMONOBJS) | awk 'BEGIN{print "#!"}; $$2~/^[BD]$$/{print $$1}' | sort -u -o $@

install: install-nodoc $(RDOCTARGET)
install-all: install-nodoc install-doc

install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
pre-install-nodoc:: pre-install-local pre-install-ext
do-install-nodoc: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
post-install-nodoc:: post-install-local post-install-ext

install-local: pre-install-local do-install-local post-install-local
pre-install-local:: pre-install-bin pre-install-lib pre-install-man
do-install-local: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
post-install-local:: post-install-bin post-install-lib post-install-man

install-ext: pre-install-ext do-install-ext post-install-ext
pre-install-ext:: pre-install-ext-arch pre-install-ext-comm
do-install-ext: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext
post-install-ext:: post-install-ext-arch post-install-ext-comm

install-arch: pre-install-arch do-install-arch post-install-arch
pre-install-arch:: pre-install-bin pre-install-ext-arch
do-install-arch: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=bin --install=ext-arch
post-install-arch:: post-install-bin post-install-ext-arch

install-comm: pre-install-comm do-install-comm post-install-comm
pre-install-comm:: pre-install-lib pre-install-ext-comm pre-install-man
do-install-comm: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man
post-install-comm:: post-install-lib post-install-ext-comm post-install-man

install-bin: pre-install-bin do-install-bin post-install-bin
pre-install-bin:: install-prereq
do-install-bin: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=bin
post-install-bin::
@$(NULLCMD)

install-lib: pre-install-lib do-install-lib post-install-lib
pre-install-lib:: install-prereq
do-install-lib: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=lib
post-install-lib::
@$(NULLCMD)

install-ext-comm: pre-install-ext-comm do-install-ext-comm post-install-ext-comm
pre-install-ext-comm:: install-prereq
do-install-ext-comm: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext-comm
post-install-ext-comm::
@$(NULLCMD)

install-ext-arch: pre-install-ext-arch do-install-ext-arch post-install-ext-arch
pre-install-ext-arch:: install-prereq
do-install-ext-arch: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext-arch
post-install-ext-arch::
@$(NULLCMD)

install-man: pre-install-man do-install-man post-install-man
pre-install-man:: install-prereq
do-install-man: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
post-install-man::
@$(NULLCMD)

what-where: no-install
no-install: no-install-nodoc no-install-doc
what-where-all: no-install-all
no-install-all: no-install-nodoc

what-where-nodoc: no-install-nodoc
no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc
pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext
dont-install-nodoc: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
post-no-install-nodoc:: post-no-install-local post-no-install-ext

what-where-local: no-install-local
no-install-local: pre-no-install-local dont-install-local post-no-install-local
pre-no-install-local:: pre-no-install-bin pre-no-install-lib pre-no-install-man
dont-install-local: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
post-no-install-local:: post-no-install-bin post-no-install-lib post-no-install-man

what-where-ext: no-install-ext
no-install-ext: pre-no-install-ext dont-install-ext post-no-install-ext
pre-no-install-ext:: pre-no-install-ext-arch pre-no-install-ext-comm
dont-install-ext: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext
post-no-install-ext:: post-no-install-ext-arch post-no-install-ext-comm

what-where-arch: no-install-arch
no-install-arch: pre-no-install-arch dont-install-arch post-no-install-arch
pre-no-install-arch:: pre-no-install-bin pre-no-install-ext-arch
dont-install-arch: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=bin --install=ext-arch
post-no-install-arch:: post-no-install-lib post-no-install-man post-no-install-ext-arch

what-where-comm: no-install-comm
no-install-comm: pre-no-install-comm dont-install-comm post-no-install-comm
pre-no-install-comm:: pre-no-install-lib pre-no-install-ext-comm pre-no-install-man
dont-install-comm: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man
post-no-install-comm:: post-no-install-lib post-no-install-ext-comm post-no-install-man

what-where-bin: no-install-bin
no-install-bin: pre-no-install-bin dont-install-bin post-no-install-bin
pre-no-install-bin:: install-prereq
dont-install-bin: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=bin
post-no-install-bin::
@$(NULLCMD)

what-where-lib: no-install-lib
no-install-lib: pre-no-install-lib dont-install-lib post-no-install-lib
pre-no-install-lib:: install-prereq
dont-install-lib: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=lib
post-no-install-lib::
@$(NULLCMD)

what-where-ext-comm: no-install-ext-comm
no-install-ext-comm: pre-no-install-ext-comm dont-install-ext-comm post-no-install-ext-comm
pre-no-install-ext-comm:: install-prereq
dont-install-ext-comm: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext-comm
post-no-install-ext-comm::
@$(NULLCMD)

what-where-ext-arch: no-install-ext-arch
no-install-ext-arch: pre-no-install-ext-arch dont-install-ext-arch post-no-install-ext-arch
pre-no-install-ext-arch:: install-prereq
dont-install-ext-arch: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext-arch
post-no-install-ext-arch::
@$(NULLCMD)

what-where-man: no-install-man
no-install-man: pre-no-install-man dont-install-man post-no-install-man
pre-no-install-man:: install-prereq
dont-install-man: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
post-no-install-man::
@$(NULLCMD)

install-doc: rdoc pre-install-doc do-install-doc post-install-doc
pre-install-doc:: install-prereq
do-install-doc: $(PROGRAM)
$(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
post-install-doc::
@$(NULLCMD)

rdoc: $(PROGRAM) PHONY
@echo Generating RDoc documentation
$(RUNRUBY) "$(srcdir)/bin/rdoc" --all --ri --op "$(RDOCOUT)" "$(srcdir)"

what-where-doc: no-install-doc
no-install-doc: pre-no-install-doc dont-install-doc post-no-install-doc
pre-no-install-doc:: install-prereq
dont-install-doc:: $(PREP)
$(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
post-no-install-doc::
@$(NULLCMD)

CLEAR_INSTALLED_LIST = clear-installed-list

install-prereq: $(CLEAR_INSTALLED_LIST)

clear-installed-list:
@exit > $(INSTALLED_LIST)

clean: clean-ext clean-local clean-enc
clean-local::
@$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
@$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time
@$(RM) *.inc $(GOLFOBJS) y.tab.c y.output encdb.h transdb.h
clean-ext: $(PREP)
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) clean
clean-enc:
@-$(MAKE) -f enc.mk $(MFLAGS) clean

distclean: distclean-ext distclean-local distclean-enc
distclean-local:: clean-local
@$(RM) $(MKFILES) $(arch_hdrdir)/ruby/config.h rbconfig.rb yasmdata.rb encdb.h
@$(RM) config.cache config.log config.status config.status.lineno $(PRELUDES)
@$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP)
distclean-ext: $(PREP)
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) distclean
# -$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h
# -rmdir -p $(arch_hdrdir)/ruby
distclean-enc: clean-enc
@-$(MAKE) -f enc.mk $(MFLAGS) distclean

realclean:: realclean-ext realclean-local realclean-enc
realclean-local:: distclean-local
@$(RM) parse.c lex.c revision.h
realclean-ext:: $(PREP)
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) realclean
realclean-enc:: distclean-enc

check: test test-all

btest: miniruby$(EXEEXT) PHONY
$(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(MINIRUBY)" $(OPTS)

btest-miniruby: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
@$(MINIRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(MINIRUBY)" -q

test-sample: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
@$(MINIRUBY) $(srcdir)/rubytest.rb

test-knownbug: miniruby$(EXEEXT) $(PROGRAM) PHONY
$(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM)" $(OPTS) $(srcdir)/KNOWNBUGS.rb

test: test-sample btest-miniruby test-knownbug

test-all:
$(RUNRUBY) "$(srcdir)/test/runner.rb" --basedir="$(TESTSDIR)" --runner=$(TESTUI) $(TESTS)

extconf: $(PREP)
$(MINIRUBY) -run -e mkdir -- -p "$(EXTCONFDIR)"
$(RUNRUBY) -C "$(EXTCONFDIR)" $(EXTCONF) $(EXTCONFARGS)

$(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
@$(MINIRUBY) $(srcdir)/mkconfig.rb -timestamp=$@ \
-install_name=$(RUBY_INSTALL_NAME) \
-so_name=$(RUBY_SO_NAME) rbconfig.rb

encs: enc.mk $(LIBRUBY) $(PREP)
$(MINIRUBY) -run -e mkdir -- -p "$(EXTOUT)/$(arch)/enc/trans" enc/trans
$(MAKE) -f enc.mk RUBY="$(MINIRUBY)" $(MFLAGS)

enc.mk: $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend \
$(srcdir)/lib/mkmf.rb $(PREP)
$(MINIRUBY) $(srcdir)/enc/make_encmake.rb --builtin-encs="$(BUILTIN_ENCOBJS)" $@

.PRECIOUS: $(MKFILES)

.PHONY: test install install-nodoc install-doc dist

PHONY:

parse.c: parse.y $(srcdir)/tool/ytab.sed

.y.c:
$(YACC) $(YFLAGS) -o y.tab.c $<
sed -f $(srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@.new
@$(RM) $@ y.tab.c
@$(MV) $@.new $@

acosh.$(OBJEXT): acosh.c
alloca.$(OBJEXT): alloca.c config.h
crypt.$(OBJEXT): crypt.c
dup2.$(OBJEXT): dup2.c
erf.$(OBJEXT): erf.c
finite.$(OBJEXT): finite.c
flock.$(OBJEXT): flock.c
memcmp.$(OBJEXT): memcmp.c
memmove.$(OBJEXT): memmove.c
mkdir.$(OBJEXT): mkdir.c
strchr.$(OBJEXT): strchr.c
strdup.$(OBJEXT): strdup.c
strerror.$(OBJEXT): strerror.c
strftime.$(OBJEXT): strftime.c
strstr.$(OBJEXT): strstr.c
strtod.$(OBJEXT): strtod.c
strtol.$(OBJEXT): strtol.c
nt.$(OBJEXT): nt.c
x68.$(OBJEXT): x68.c
os2.$(OBJEXT): os2.c
dl_os2.$(OBJEXT): dl_os2.c
ia64.$(OBJEXT): ia64.s
$(CC) $(CFLAGS) -c $<

# when I use -I., there is confliction at "OpenFile"
# so, set . into environment varible "include"
win32.$(OBJEXT): win32.c

###

RUBY_H_INCLUDES = ruby.h config.h defines.h \
intern.h missing.h

array.$(OBJEXT): array.c $(RUBY_H_INCLUDES) \
st.h util.h
bignum.$(OBJEXT): bignum.c $(RUBY_H_INCLUDES) \
st.h
class.$(OBJEXT): class.c $(RUBY_H_INCLUDES) \
st.h signal.h node.h
compar.$(OBJEXT): compar.c $(RUBY_H_INCLUDES) \
st.h
complex.$(OBJEXT): complex.c $(RUBY_H_INCLUDES) \
st.h
dir.$(OBJEXT): dir.c $(RUBY_H_INCLUDES) \
st.h util.h
dln.$(OBJEXT): dln.c $(RUBY_H_INCLUDES) \
st.h dln.h
dmydln.$(OBJEXT): dmydln.c dln.$(OBJEXT)
dmyext.$(OBJEXT): dmyext.c
dmyencoding.$(OBJEXT): dmyencoding.c \
encoding.c $(RUBY_H_INCLUDES) st.h \
encoding.h oniguruma.h regenc.h
encoding.$(OBJEXT): dmyencoding.$(OBJEXT)
enum.$(OBJEXT): enum.c $(RUBY_H_INCLUDES) \
st.h node.h util.h
enumerator.$(OBJEXT): enumerator.c $(RUBY_H_INCLUDES) \
st.h debug.h node.h
error.$(OBJEXT): error.c $(RUBY_H_INCLUDES) \
st.h vm_core.h signal.h node.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
eval.$(OBJEXT): eval.c eval_intern.h \
$(RUBY_H_INCLUDES) st.h node.h \
util.h signal.h vm_core.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h dln.h \
eval_error.c eval_safe.c \
eval_jump.c
load.$(OBJEXT): load.c eval_intern.h \
$(RUBY_H_INCLUDES) st.h node.h \
util.h signal.h vm_core.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h dln.h
file.$(OBJEXT): file.c $(RUBY_H_INCLUDES) \
st.h io.h encoding.h oniguruma.h \
signal.h util.h dln.h
gc.$(OBJEXT): gc.c $(RUBY_H_INCLUDES) \
st.h signal.h node.h re.h \
regex.h oniguruma.h io.h \
encoding.h vm_core.h debug.h \
vm_opts.h id.h thread_$(THREAD_MODEL).h \
gc.h eval_intern.h
hash.$(OBJEXT): hash.c $(RUBY_H_INCLUDES) \
st.h util.h signal.h
inits.$(OBJEXT): inits.c $(RUBY_H_INCLUDES) \
st.h
io.$(OBJEXT): io.c $(RUBY_H_INCLUDES) \
st.h io.h encoding.h oniguruma.h \
signal.h util.h
main.$(OBJEXT): main.c $(RUBY_H_INCLUDES) \
st.h
marshal.$(OBJEXT): marshal.c $(RUBY_H_INCLUDES) \
st.h io.h encoding.h \
oniguruma.h util.h
math.$(OBJEXT): math.c $(RUBY_H_INCLUDES) st.h
numeric.$(OBJEXT): numeric.c $(RUBY_H_INCLUDES) \
st.h encoding.h oniguruma.h
object.$(OBJEXT): object.c $(RUBY_H_INCLUDES) \
st.h util.h debug.h node.h
pack.$(OBJEXT): pack.c $(RUBY_H_INCLUDES) st.h
parse.$(OBJEXT): parse.c parse.y $(RUBY_H_INCLUDES) \
st.h node.h encoding.h \
oniguruma.h id.h regenc.h \
regex.h util.h lex.c keywords \
debug.h
prec.$(OBJEXT): prec.c $(RUBY_H_INCLUDES) st.h
proc.$(OBJEXT): proc.c eval_intern.h \
$(RUBY_H_INCLUDES) st.h node.h \
util.h signal.h vm_core.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h dln.h gc.h
process.$(OBJEXT): process.c $(RUBY_H_INCLUDES) st.h \
signal.h vm_core.h util.h \
node.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
random.$(OBJEXT): random.c $(RUBY_H_INCLUDES) \
st.h
range.$(OBJEXT): range.c $(RUBY_H_INCLUDES) \
st.h
rational.$(OBJEXT): rational.c $(RUBY_H_INCLUDES) \
st.h
re.$(OBJEXT): re.c $(RUBY_H_INCLUDES) \
st.h re.h regex.h oniguruma.h \
encoding.h util.h regint.h \
regenc.h
regcomp.$(OBJEXT): regcomp.c regparse.h \
regint.h config.h defines.h \
regenc.h oniguruma.h st.h
regenc.$(OBJEXT): regenc.c regint.h \
config.h defines.h regenc.h \
oniguruma.h st.h
regerror.$(OBJEXT): regerror.c regint.h \
config.h defines.h regenc.h \
oniguruma.h st.h
regexec.$(OBJEXT): regexec.c regint.h \
config.h defines.h regenc.h \
oniguruma.h st.h
regparse.$(OBJEXT): regparse.c regparse.h \
regint.h config.h defines.h \
regenc.h oniguruma.h st.h
regsyntax.$(OBJEXT): regsyntax.c regint.h \
config.h defines.h regenc.h \
oniguruma.h st.h
ruby.$(OBJEXT): ruby.c $(RUBY_H_INCLUDES) \
st.h node.h encoding.h \
oniguruma.h eval_intern.h util.h \
signal.h vm_core.h debug.h \
vm_opts.h id.h thread_$(THREAD_MODEL).h \
dln.h
signal.$(OBJEXT): signal.c $(RUBY_H_INCLUDES) \
st.h signal.h node.h vm_core.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
sprintf.$(OBJEXT): sprintf.c $(RUBY_H_INCLUDES) st.h \
re.h regex.h oniguruma.h \
encoding.h vsnprintf.c
st.$(OBJEXT): st.c config.h defines.h \
st.h
string.$(OBJEXT): string.c $(RUBY_H_INCLUDES) \
st.h re.h regex.h oniguruma.h \
encoding.h
struct.$(OBJEXT): struct.c $(RUBY_H_INCLUDES) \
st.h
thread.$(OBJEXT): thread.c eval_intern.h \
$(RUBY_H_INCLUDES) st.h node.h \
util.h signal.h vm_core.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h dln.h vm.h \
gc.h thread_$(THREAD_MODEL).c
transcode.$(OBJEXT): transcode.c $(RUBY_H_INCLUDES) st.h \
encoding.h oniguruma.h transcode_data.h
cont.$(OBJEXT): cont.c $(RUBY_H_INCLUDES) \
st.h vm_core.h signal.h node.h \
debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h gc.h \
eval_intern.h util.h dln.h
time.$(OBJEXT): time.c $(RUBY_H_INCLUDES) \
st.h encoding.h
util.$(OBJEXT): util.c $(RUBY_H_INCLUDES) \
st.h util.h
variable.$(OBJEXT): variable.c $(RUBY_H_INCLUDES) st.h \
node.h util.h
version.$(OBJEXT): version.c $(RUBY_H_INCLUDES) st.h \
version.h $(srcdir)/revision.h

compile.$(OBJEXT): compile.c $(RUBY_H_INCLUDES) st.h \
node.h vm_core.h \
signal.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h compile.h \
insns.inc insns_info.inc optinsn.inc
iseq.$(OBJEXT): iseq.c $(RUBY_H_INCLUDES) \
st.h node.h gc.h vm_core.h \
signal.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h insns.inc \
insns_info.inc node_name.inc
vm.$(OBJEXT): vm.c $(RUBY_H_INCLUDES) \
st.h node.h encoding.h \
oniguruma.h gc.h insnhelper.h \
eval_intern.h util.h signal.h \
vm_core.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h dln.h vm.h \
vm_insnhelper.c insns.inc vm_evalbody.c \
vmtc.inc vm.inc insns.def \
vm_method.c vm_eval.c
vm_dump.$(OBJEXT): vm_dump.c $(RUBY_H_INCLUDES) st.h \
node.h vm_core.h \
signal.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h vm.h
debug.$(OBJEXT): debug.c $(RUBY_H_INCLUDES) \
st.h encoding.h oniguruma.h \
debug.h node.h vm_core.h \
signal.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
blockinlining.$(OBJEXT): blockinlining.c $(RUBY_H_INCLUDES) \
st.h node.h vm_core.h \
signal.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
id.$(OBJEXT): id.c $(RUBY_H_INCLUDES) \
st.h id.h
miniprelude.$(OBJEXT): miniprelude.c $(RUBY_H_INCLUDES) \
st.h vm_core.h signal.h \
node.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
prelude.$(OBJEXT): prelude.c $(RUBY_H_INCLUDES) st.h \
vm_core.h signal.h \
node.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
golf_prelude.$(OBJEXT): golf_prelude.c $(RUBY_H_INCLUDES) \
st.h vm_core.h signal.h \
node.h debug.h vm_opts.h id.h \
thread_$(THREAD_MODEL).h
goruby.$(OBJEXT): goruby.c main.c $(RUBY_H_INCLUDES) st.h

ascii.$(OBJEXT): ascii.c regenc.h config.h \
defines.h oniguruma.h
us_ascii.$(OBJEXT): us_ascii.c regenc.h config.h \
defines.h oniguruma.h
unicode.$(OBJEXT): unicode.c regint.h \
config.h defines.h regenc.h \
oniguruma.h st.h
utf_8.$(OBJEXT): utf_8.c regenc.h config.h \
defines.h oniguruma.h

INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc insns_info.inc \
vmtc.inc vm.inc

INSNS2VMOPT = --srcdir="$(srcdir)"

$(INSNS): $(srcdir)/insns.def vm_opts.h
$(RM) $(PROGRAM)
$(BASERUBY) -Ks $(srcdir)/tool/insns2vm.rb $(INSNS2VMOPT) $@

minsns.inc: $(srcdir)/template/minsns.inc.tmpl

opt_sc.inc: $(srcdir)/template/opt_sc.inc.tmpl

optinsn.inc: $(srcdir)/template/optinsn.inc.tmpl

optunifs.inc: $(srcdir)/template/optunifs.inc.tmpl

insns.inc: $(srcdir)/template/insns.inc.tmpl

insns_info.inc: $(srcdir)/template/insns_info.inc.tmpl

vmtc.inc: $(srcdir)/template/vmtc.inc.tmpl

vm.inc: $(srcdir)/template/vm.inc.tmpl

srcs: parse.c lex.c $(srcdir)/ext/ripper/ripper.c

incs: $(INSNS) node_name.inc encdb.h transdb.h $(srcdir)/revision.h

insns: $(INSNS)

node_name.inc: node.h
$(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@

encdb.h: $(PREP)
$(MINIRUBY) $(srcdir)/enc/make_encdb.rb $(srcdir)/enc $@.new
$(IFCHANGE) "$@" "$@.new"

transdb.h: $(PREP)
$(MINIRUBY) $(srcdir)/enc/trans/make_transdb.rb $(srcdir)/enc/trans $@.new
$(IFCHANGE) "$@" "$@.new"

miniprelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $@

prelude.c: $(srcdir)/tool/compile_prelude.rb $(PRELUDE_SCRIPTS) $(PREP)
$(COMPILE_PRELUDE) $(PRELUDE_SCRIPTS) $@

golf_prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/golf_prelude.rb $(PREP)
$(COMPILE_PRELUDE) $(srcdir)/golf_prelude.rb $@

prereq: incs srcs preludes

preludes: miniprelude.c
preludes: golf_prelude.c

docs:
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)

$(srcdir)/revision.h: $(REVISION_FORCE)
@set LC_MESSAGES=C
-@$(SET_LC_MESSAGES) $(VCS) info "$(@D)" | \
sed -n "s/.*Rev:/#define RUBY_REVISION/p" > "$@.tmp"
@$(IFCHANGE) "$@" "$@.tmp"

$(srcdir)/ext/ripper/ripper.c:
cd $(srcdir)/ext/ripper && exec $(MAKE) -f depend $(MFLAGS) top_srcdir=../.. srcdir=.

##

run: miniruby$(EXEEXT) PHONY
$(MINIRUBY) $(srcdir)/test.rb $(RUNOPT)

runruby: $(PROGRAM) PHONY
$(RUNRUBY) $(srcdir)/test.rb

parse: miniruby$(EXEEXT) PHONY
$(MINIRUBY) $(srcdir)/tool/parse.rb $(srcdir)/test.rb

COMPARE_RUBY = $(BASERUBY)
ITEM =
OPTS =

benchmark: $(PROGRAM) PHONY
$(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
--executables="$(COMPARE_RUBY); $(RUNRUBY)" \
--pattern='bm_' --directory=$(srcdir)/benchmark $(OPTS)

benchmark-each: $(PROGRAM) PHONY
$(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
--executables="$(COMPARE_RUBY); $(RUNRUBY)" \
--pattern=$(ITEM) --directory=$(srcdir)/benchmark $(OPTS)

tbench: $(PROGRAM) PHONY
$(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
--executables="$(COMPARE_RUBY); $(RUNRUBY)" \
--pattern='bmx_' --directory=$(srcdir)/benchmark $(OPTS)

aotc: $(PROGRAM) PHONY
./$(PROGRAM) -I$(srcdir)/lib $(srcdir)/bin/ruby2cext $(srcdir)/test.rb

vmasm: vm.$(ASMEXT)

# vm.o : CFLAGS += -fno-crossjumping

run.gdb:
echo b ruby_debug_breakpoint > run.gdb
echo '# handle SIGINT nostop' >> run.gdb
echo '# handle SIGPIPE nostop' >> run.gdb
echo '# b rb_longjmp' >> run.gdb
echo source $(srcdir)/breakpoints.gdb >> run.gdb
echo source $(srcdir)/.gdbinit >> run.gdb
echo run >> run.gdb

gdb: miniruby$(EXEEXT) run.gdb PHONY
gdb -x run.gdb --quiet --args $(MINIRUBY) $(srcdir)/test.rb

# Intel VTune

vtune: miniruby$(EXEEXT)
vtl activity -c sampling -app ".\miniruby$(EXEEXT)","-I$(srcdir)/lib $(srcdir)/test.rb" run
vtl view -hf -mn miniruby$(EXEEXT) -sum -sort -cd
vtl view -ha -mn miniruby$(EXEEXT) -sum -sort -cd | $(RUNRUBY) $(srcdir)/tool/vtlh.rb > ha.lines

dist: $(PREP) $(PROGRAM)
$(SHELL) $(srcdir)/tool/make-snapshot . $(TARNAME)

up:
@$(VCS) up "$(srcdir)"
-@$(MAKE) $(MFLAGS) REVISION_FORCE=PHONY "$(srcdir)/revision.h"

help: PHONY
@echo " Makefile of Ruby"
@echo ""
@echo "targets:"
@echo " all: compile ruby and extensions"
@echo " check: equals make test test-all"
@echo " test: ruby core tests"
@echo " test-all: all ruby tests"
@echo " install: install all ruby distributions"
@echo " install-nodoc: install without rdoc"
@echo " clean: clean built objects"
@echo " golf: for golfers"
(1-1/2)