# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
MKBUILTINS = mkbuiltins$(EXE_SUFFIX)
RANLIB = /usr/bin/ranlib
CFLAGS = -g -I.. -I.
SHELL = /bin/sh
# CC = cc
AR = ar
RM = rm -f
CP = cp
O_SUFFIX=o
A_SUFFIX=a
EXE_SUFFIX=

srcdir = .
VPATH = .:$(srcdir)

.SUFFIXES:
.SUFFIXES: .def .c .$(O_SUFFIX)
# Here is a rule for making .o files from .c files that does not
# force the type of the machine (like -M_MACHINE) into the flags.
.c.$(O_SUFFIX):
	$(RM) $@
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCFLAGS) $<


# How to make a .o file from a .def file.
.def.$(O_SUFFIX):
	$(RM) $@
	./$(MKBUILTINS) $(DIRECTDEFINE) $<
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCFLAGS) $*.c || ( $(RM) $*.c ; exit 2 )
	$(RM) $*.c

# How to make a .c file from a .def file.
.def.c:
	$(RM) $@
	./$(MKBUILTINS) $(DIRECTDEFINE) $<

DEFS =  $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \
	$(srcdir)/builtin.def $(srcdir)/cd.def $(srcdir)/colon.def \
	$(srcdir)/command.def $(srcdir)/declare.def $(srcdir)/echo.def \
	$(srcdir)/enable.def $(srcdir)/eval.def $(srcdir)/getopts.def \
	$(srcdir)/exec.def $(srcdir)/exit.def $(srcdir)/fc.def \
	$(srcdir)/fg_bg.def $(srcdir)/hash.def $(srcdir)/help.def \
	$(srcdir)/history.def $(srcdir)/jobs.def $(srcdir)/kill.def \
	$(srcdir)/let.def $(srcdir)/read.def $(srcdir)/return.def \
	$(srcdir)/set.def $(srcdir)/setattr.def $(srcdir)/shift.def \
	$(srcdir)/source.def $(srcdir)/suspend.def $(srcdir)/test.def \
	$(srcdir)/times.def $(srcdir)/trap.def $(srcdir)/type.def \
	$(srcdir)/ulimit.def $(srcdir)/umask.def $(srcdir)/wait.def \
	$(srcdir)/reserved.def

STATIC_SOURCE = common.c getopt.c bashgetopt.c getopt.h 

OFILES = builtins.$(O_SUFFIX) \
	alias.$(O_SUFFIX) bind.$(O_SUFFIX) break.$(O_SUFFIX) builtin.$(O_SUFFIX) cd.$(O_SUFFIX) colon.$(O_SUFFIX) command.$(O_SUFFIX) \
	common.$(O_SUFFIX) declare.$(O_SUFFIX) echo.$(O_SUFFIX) enable.$(O_SUFFIX) eval.$(O_SUFFIX) exec.$(O_SUFFIX) exit.$(O_SUFFIX) \
	fc.$(O_SUFFIX) fg_bg.$(O_SUFFIX) hash.$(O_SUFFIX) help.$(O_SUFFIX) history.$(O_SUFFIX) jobs.$(O_SUFFIX) kill.$(O_SUFFIX) \
	let.$(O_SUFFIX) read.$(O_SUFFIX) return.$(O_SUFFIX) set.$(O_SUFFIX) setattr.$(O_SUFFIX) shift.$(O_SUFFIX) source.$(O_SUFFIX) \
	suspend.$(O_SUFFIX) test.$(O_SUFFIX) times.$(O_SUFFIX) trap.$(O_SUFFIX) type.$(O_SUFFIX) ulimit.$(O_SUFFIX) umask.$(O_SUFFIX) \
	wait.$(O_SUFFIX) getopts.$(O_SUFFIX) getopt.$(O_SUFFIX) bashgetopt.$(O_SUFFIX)

THINGS_TO_TAR = $(DEFS) $(STATIC_SOURCE) Makefile ChangeLog

CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h

all: $(MKBUILTINS) libbuiltins.$(A_SUFFIX)

libbuiltins.$(A_SUFFIX): $(MKBUILTINS) $(OFILES)
	$(RM) $@
	$(AR) cq $@ $(OFILES)
	-$(RANLIB) $@

builtext.h builtins.c: $(MKBUILTINS) $(DEFS)
	$(RM) builtext.h builtins.c
	./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \
	-noproduction $(DIRECTDEFINE) $(DEFS)

$(MKBUILTINS): $(srcdir)/mkbuiltins.c ../config.h
	$(CC) $(CFLAGS) -o $(MKBUILTINS) $(srcdir)/mkbuiltins.c

ulimit.$(O_SUFFIX): ulimit.def pipesize.h

pipesize.h:	psize.aux
	$(SHELL) $(srcdir)/psize.sh > pipesize.h

psize.aux:	psize.c
	$(CC) $(CFLAGS) -o $@ $(srcdir)/psize.c

documentation: builtins.texi

$(OFILES):	$(MKBUILTINS) ../config.h

builtins.texi: $(MKBUILTINS)
	./$(MKBUILTINS) -documentonly $(DEFS)

clean:
	$(RM) $(OFILES) $(CREATED_FILES) $(MKBUILTINS)

mostlyclean:
	$(RM) $(OFILES) libbuiltins.$(A_SUFFIX)

distclean realclean maintainer-clean: clean
	$(RM) libbuiltins.$(A_SUFFIX)

alias.$(O_SUFFIX): alias.def
bind.$(O_SUFFIX): bind.def
break.$(O_SUFFIX): break.def
builtin.$(O_SUFFIX): builtin.def
cd.$(O_SUFFIX): cd.def
colon.$(O_SUFFIX): colon.def
command.$(O_SUFFIX): command.def
declare.$(O_SUFFIX): declare.def
echo.$(O_SUFFIX): echo.def
enable.$(O_SUFFIX): enable.def
eval.$(O_SUFFIX): eval.def
exec.$(O_SUFFIX): exec.def
exit.$(O_SUFFIX): exit.def
fc.$(O_SUFFIX): fc.def
fg_bg.$(O_SUFFIX): fg_bg.def
hash.$(O_SUFFIX): hash.def
help.$(O_SUFFIX): help.def
history.$(O_SUFFIX): history.def
jobs.$(O_SUFFIX): jobs.def
kill.$(O_SUFFIX): kill.def
let.$(O_SUFFIX): let.def
read.$(O_SUFFIX): read.def
return.$(O_SUFFIX): return.def
set.$(O_SUFFIX): set.def
setattr.$(O_SUFFIX): setattr.def
shift.$(O_SUFFIX): shift.def
source.$(O_SUFFIX): source.def
suspend.$(O_SUFFIX): suspend.def
test.$(O_SUFFIX): test.def
times.$(O_SUFFIX): times.def
trap.$(O_SUFFIX): trap.def
type.$(O_SUFFIX): type.def
umask.$(O_SUFFIX): umask.def
wait.$(O_SUFFIX): wait.def
getopts.$(O_SUFFIX): getopts.def
reserved.$(O_SUFFIX): reserved.def

common.$(O_SUFFIX): ../shell.h ../command.h ../config.h ../memalloc.h ../general.h
common.$(O_SUFFIX): ../variables.h ../input.h hashcom.h ../bashhist.h
common.$(O_SUFFIX): ../quit.h  ../unwind_prot.h ../maxpath.h ../jobs.h ../builtins.h
common.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
common.$(O_SUFFIX): ../execute_cmd.h ../error.h
alias.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
alias.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
alias.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h common.h ../maxpath.h
bind.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
bind.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
bind.$(O_SUFFIX): ../maxpath.h
bind.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h bashgetopt.h
break.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
break.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
break.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
builtin.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
builtin.$(O_SUFFIX): ../quit.h common.h ../maxpath.h
builtin.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
builtin.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h 
cd.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
cd.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
cd.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h common.h ../maxpath.h
command.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
command.$(O_SUFFIX): ../quit.h bashgetopt.h ../maxpath.h
command.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
command.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h 
declare.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
declare.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
declare.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
echo.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
echo.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
echo.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
enable.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
enable.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
enable.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
eval.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
eval.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
eval.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
exec.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
exec.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
exec.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h common.h ../execute_cmd.h
exec.$(O_SUFFIX): ../maxpath.h ../flags.h
exit.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
exit.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
exit.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
fc.$(O_SUFFIX): ../builtins.h ../command.h bashgetopt.h ../bashhist.h
fc.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
fc.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
fc.$(O_SUFFIX): ../flags.h ../unwind_prot.h ../variables.h ../shell.h ../maxpath.h
fg_bg.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
fg_bg.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
fg_bg.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
getopts.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
getopts.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
getopts.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
hash.$(O_SUFFIX): ../builtins.h ../command.h ../quit.h ../execute_cmd.h
hash.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
hash.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h common.h ../maxpath.h
help.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
help.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
help.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
history.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
history.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
history.$(O_SUFFIX): ../filecntl.h ../shell.h ../unwind_prot.h ../variables.h
history.$(O_SUFFIX): ../bashhist.h ../maxpath.h
inlib.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
inlib.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
inlib.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
jobs.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
jobs.$(O_SUFFIX): ../quit.h bashgetopt.h ../maxpath.h
jobs.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
jobs.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h 
kill.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
kill.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
kill.$(O_SUFFIX): ../shell.h ../trap.h ../unwind_prot.h ../variables.h ../maxpath.h
let.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
let.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
let.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
read.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
read.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
read.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
return.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
return.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
return.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
set.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
set.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
set.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
setattr.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
setattr.$(O_SUFFIX): ../quit.h common.h bashgetopt.h ../maxpath.h
setattr.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
setattr.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h 
shift.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
shift.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
shift.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
source.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
source.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
source.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
suspend.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
suspend.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
suspend.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
test.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
test.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
test.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
times.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
times.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
times.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
trap.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
trap.$(O_SUFFIX): ../quit.h common.h ../maxpath.h
trap.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
trap.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../execute_cmd.h
type.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
type.$(O_SUFFIX): ../quit.h common.h ../maxpath.h
type.$(O_SUFFIX): ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
type.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h 
ulimit.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
ulimit.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
ulimit.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
umask.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
umask.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
umask.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h
wait.$(O_SUFFIX): ../command.h ../config.h ../memalloc.h ../error.h ../general.h
wait.$(O_SUFFIX): ../quit.h ../dispose_cmd.h ../make_cmd.h ../subst.h ../externs.h
wait.$(O_SUFFIX): ../shell.h ../unwind_prot.h ../variables.h ../maxpath.h

bashgetopt.$(O_SUFFIX): ../bashansi.h ../ansi_stdlib.h
mkbuiltins.$(O_SUFFIX): ../bashansi.h ../ansi_stdlib.h
fc.$(O_SUFFIX): ../bashansi.h ../ansi_stdlib.h

#bind.$(O_SUFFIX): $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h
