############################################################################
#
# Makefile for yodl.
# You should not need editing here, all configurations are in the Makefile
# in the parent directory.

############################################################################

# Name of binary to build.
PROG = yodl

# What objects do we need.
OBJ = yodl.o sighandler.o parseflags.o usage.o message.o init.o \
      isidentchar.o errorgram.o parse.o userconfirm.o \
      lexer.o lexerpushstr.o lexergetc.o lexerpushchar.o lexereof.o \
	lexerpreread.o lexerpeek.o \
      fileisfile.o fileexpandname.o outputstring.o \
      substmightbe.o checklivedata.o showchildstatus.o \
      gramsymbol.o gramdefinesymbol.o gramparlist.o gramonename.o \
	gramincludefile.o gramonenumber.o gramnoexpand.o \
	gramrenamemacro.o gramundefinesymbol.o gramifdef.o \
	gramdefinemacro.o gramexpand.o gramchar.o gramcomment.o \
	gramtypeout.o gramdefinechartable.o gramusechartable.o \
	gramatexit.o gramdummy.o gramstartdef.o gramenddef.o \
	gramifempty.o gramundefinemacro.o gramnewcounter.o gramcountervalue.o \
	gramsetcounter.o gramaddtocounter.o gramusecounter.o \
	gramfindcounter.o gramerror.o gramwarn.o gramhasident.o \
	gramifzero.o gramparagraph.o gramsubst.o gramnotrans.o \
	gramgetchar.o gramchdir.o gramifstrequal.o gramifstrsub.o \
	gramwarning.o gramnousermacro.o gramsystem.o grampipethrough.o \
	gramuppercase.o gramincludelit.o grampushchartable.o \
	grampopchartable.o \
	../lib/strtabadd.o ../lib/strtabfind.o ../lib/strtabdel.o \
	../lib/strtabfree.o \
	../lib/straddchar.o ../lib/strreplace.o ../lib/strconcat.o \
	  ../lib/strshort.o \
      ../lib/xrealloc.o ../lib/xstrdup.o ../lib/openfile.o \
      ../lib/error.o ../lib/errorsetprogname.o ../lib/output.o \
      ../lib/closefile.o

# How to get to .o from .c
.c.o:
	$(CC) $(CFLAGS) -o $@ -DSTD_INCLUDE=\"$(STD_INCLUDE)\" \
	    -DVER=\"$(VER)\" -DYEARS=\"$(YEARS)\" $(NEEDSTRERROR) \
	    -DTMPDIR=\"$(TMPDIR)\" -DMAINTAINER="\"$(MAINT)\"" \
	    $(NEEDOPT) $<

# Entry point.
all: $(PROG)

# How to make program
$(PROG): $(OBJ)
	$(CC) -o $(PROG) $(OBJ)

# How to install binary.
install: $(BINDIR)/yodl

$(BINDIR)/yodl: yodl
	$(INSTALL) yodl $(BINDIR)

# Cleaning up.
clean::
	rm -f *.o *.bak core '#*#' *~ yodl out .debug .prof

.debug: .debug.in ../../Makefile
	sed 's:__BASH__:$(BASH):' < .debug.in > .debug
	chmod +x .debug

debug: $(PROG) .debug
	@echo ''
	@echo 'Debug-able yold executable now in src/yodl/yodl.'
	@echo ''
	./.debug

# Profiling the yodl program. Also only for me.
.prof: .prof.in ../../Makefile
	sed 's:__BASH__:$(BASH):' < .prof.in > .prof
	chmod +x .prof

prof: $(PROG) .prof
	./.prof

# Extra deps.
yodl.o: yodl.c yodl.h ../../config.h
fileexpandname.o: fileexpandname.c ../../config.h
gramsymbol.o: gramsymbol.c yodl.h
init.o: init.c yodl.h
parseflags.o: parseflags.c ../../config.h
usage.o: usage.c ../../config.h ../../Makefile
sighandler.o: sighandler.c ../../Makefile
