# Makefile.in: -*- Text -*-  Source for configure to make a Makefile from.
#
# Author: Brian J. Fox (bfox@ai.mit.edu).
#
# This file is part of <Meta-HTML>(tm), a system for the rapid deployment
# of Internet and Intranet applications via the use of the Meta-HTML
# language.
#
#  Copyright (c) 1995, 1996, Brian J. Fox (bfox@ai.mit.edu).
#  Copyright (c) 1996, Universal Access Inc. (http://www.ua.com).
#
# Meta-HTML is free software; you can redistribute it and/or modify
# it under the terms of the UAI Free Software License as published
# by Universal Access Inc.; either version 1, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# UAI Free Software License for more details.
#
# You should have received a copy of the UAI Free Software License
# along with this program; if you have not, you may obtain one by
# writing to:
#
# Universal Access Inc.
# 129 El Paseo Court
# Santa Barbara, CA
# 93101

# Items that were filled in by configure.
VPATH	= @srcdir@
srcdir	= @srcdir@
DEFS	= @DEFS@
INSTALL = @INSTALL@
REGEX_IN= @REGEX_IN@
GDBM_IN = @GDBM_IN@
MSQL_IN = @MSQL_IN@
DES_IN	= @DES_IN@
MSQLFUNCS_O = @MSQLFUNCS_O@
CRYPTFUNCS_O = @CRYPTFUNCS_O@
MODFUNCS_O = @MODFUNCS_O@
DES_LIB = @DES_LIB@
DBINC	= $(GDBM_IN) $(MSQL_IN) $(DES_IN)
OS_NAME = @OS_NAME@
OS_LIBS = @OS_LIBS@
prefix	= @prefix@
exec_prefix = @exec_prefix@

bindir	= $(exec_prefix)/bin
libdir	= $(exec_prefix)/lib
incdir	= $(prefix)/include

# The real locations of programs.
RANLIB = @RANLIB@
AR	= ar
MKDIR	= mkdir
TAR	= tar
LN	= ln
CP	= cp
RM	= rm -f
MV	= mv
BASH_SHELL = @BASH_SHELL@
bindir	= $(exec_prefix)/bin
MKDIR = mkdir
TAR = tar

#
# ALL_SUBDIRS is the list of all of the subdirectories within which we
# would like to run various `make's, or ".", which means that there
# are no subdirectories.
ALL_SUBDIRS = .

VERSION = 5.02
DISTNAME = libmhtml-$(VERSION)
WEBBASEDIR = @WEBBASEDIR@

CC = gcc
# PROFILE_FLAGS = -pg
# OPTIMIZE_FLAGS = -O69
DEBUG_FLAGS = -g $(PROFILE_FLAGS)
GCC_WARN = -Wall -Wstrict-prototypes -Wshadow
CFLAGS = $(GCC_WARN) $(OPTIMIZE_FLAGS) $(DEBUG_FLAGS)
LDFLAGS = $(OPTIMIZE_FLAGS) $(DEBUG_FLAGS)
LIBRARIES = $(LIBPATHS) $(REQUIRED_LIBS)
INCLUDES =  @EXTRAINC@ -I. -I.. -I$(LIBDIR) $(REGEX_IN) $(DBINC)

.c.o:
	$(CC) $(CFLAGS) $(DEFS) $(INCLUDES) -I.. -c $<

LIB_CSRC = symbols.c forms.c pages.c pagefuncs.c simplefuncs.c session.c \
	   database.c session_data.c streamfuncs.c dbfuncs.c filefuncs.c \
	   msqlfuncs.c prims.c symdump.c cgi-exec.c parser.c \
	   cryptfuncs.c require.c sessionfuncs.c gsql.c dbmfuncs.c modfuncs.c \
	   cleaner.c rewriter.c lockname.c bootstrapper.c bootstrapcode.c \
	   arrayfuncs.c

LIB_HSRC = symbols.h forms.h pages.h session.h database.h session_data.h \
	   parser.h streamfuncs.h symdump.h sessionfuncs.h \
	   language.h mhtmlstd.h locking.h

LIB_OBJS = symbols.o forms.o pages.o pagefuncs.o simplefuncs.o session.o \
	   database.o session_data.o streamfuncs.o dbfuncs.o filefuncs.o \
	   $(MSQLFUNCS_O) $(CRYPTFUNCS_O) prims.o symdump.o cgi-exec.o \
	   require.o parser.o initfuncs.o sessionfuncs.o dbmfuncs.o \
	   rewriter.o $(MODFUNCS_O) lockname.o bootstrapper.o \
	   bootstrapcode.o dbmfuncs.o cleaner.o arrayfuncs.o flowfuncs.o

XFUNCFILES = $(MSQLFUNCS_O) $(CRYPTFUNCS_O) $(MODFUNCS_O)
FUNCFILES = simplefuncs.o pagefuncs.o streamfuncs.o dbfuncs.o filefuncs.o \
	    prims.o cgi-exec.o require.o sessionfuncs.o $(XFUNCFILES) \
	    dbmfuncs.o rewriter.o cleaner.o arrayfuncs.o flowfuncs.o
T=tagsets
STANDARD_TAGS = \
	$(T)/characters.mhtml $(T)/dirfuns.mhtml $(T)/dump-package.mhtml \
	$(T)/english-numbers.mhtml $(T)/form-to-database.mhtml \
	$(T)/form-to-email.mhtml $(T)/general.mhtml $(T)/locale.mhtml \
	$(T)/make-identifier.mhtml $(T)/menus.mhtml $(T)/message.mhtml \
	$(T)/mhttpd.mhtml $(T)/numbers.mhtml $(T)/pagecount.mhtml \
	$(T)/parse-date.mhtml $(T)/plist.mhtml $(T)/sendmail.mhtml \
	$(T)/session.mhtml $(T)/source.mhtml $(T)/strings.mhtml \
	$(T)/this.mhtml

TARGET_LIB = libmhtml.a
TEST_PROGS = 
TEST_OBJS  = 

LIBDIR = ../libutils
LIBPATHS = -L$(LIBDIR)bprintf -L$(LIBDIR)xmalloc -L$(LIBDIR)wisper 

TARGETS = $(TARGET_LIB)

all: $(TARGETS)

$(TARGET_LIB): $(LIB_OBJS)
	$(RM) $@
	$(AR) cq $@ $(LIB_OBJS)
	if [ "$(RANLIB)" ]; then $(RANLIB) $@; fi

msqlfuncs.o: gsql.c msqlfuncs.c
	$(CC) $(CFLAGS) $(DEFS) -DCOMPILING_MSQLFUNCS $(INCLUDES) \
	  -I.. -c -o msqlfuncs.o gsql.c

forms.o: forms.h
pages.o: pages.c pages.h

initfuncs.o: initfuncs.c
initfuncs.c: $(FUNCFILES) mkinit
	./mkinit $(FUNCFILES) >initfuncs.c

makebootstrap: makebootstrap.c
	$(CC) $(CFLAGS) $(DEFS) $(INCLUDES) -o makebootstrap makebootstrap.c

bootstrapcode.c: makebootstrap bootstrap.lib
	./makebootstrap bootstrap.lib >bootstrapcode.c

bootstrapcode.o: bootstrapcode.c bootstrap.mhtml

bootstrap.lib: bootstrap.mhtml $(STANDARD_TAGS)
	@if [ -x ../mhc/mhc ]; then \
	   ../mhc/mhc -z ../utilities/mklib -o bootstrap.lib bootstrap.mhtml; \
	else \
	  (\
	   echo ""; \
	   echo "WARNING: bootstrap.lib file is older than bootstrap.mhtml,"; \
	   echo "         and ../mhc/mhc isn't built yet."; \
	   echo "         A zero length bootstrap.lib file is being made so"; \
	   echo "         that this build will finish, and then you should"; \
	   echo "         delete the bootstrap.lib file, and remake."; \
	   echo ""; \
	  ); \
	  $(RM) -f $@; touch $@; \
	  exit 0; \
	fi

$(FUNCFILES): language.h mhtmlstd.h

Makefile: Makefile.in
	(cd ..; ./config.status)

install:
	@echo "To install the libmhtml library, type \"make install-libs\"."

install-libs: libmhtml.a
	$(INSTALL) libmhtml.a $(libdir)
	for file in *.h; do \
	  $(INSTALL) $$file $(incdir)/$$file; \
	done

tags TAGS: FORCE
	etags *.c *.h

clean: FORCE
	$(RM) *.o *.a $(TARGETS) initfuncs.c bootstrapcode.c makebootstrap TAGS

distclean realclean: clean
	$(RM) *.o *core* *~ DISTFILES *.bak *.gz foo *\#* Makefile

dist: DISTFILES
	$(RM) -rf $(DISTNAME)
	$(MKDIR) $(DISTNAME)
	for d in `find $(ALL_SUBDIRS) -type d -print`; do \
	  if [ "$$d" != "." -a "$$d" != "./$(DISTNAME)" ]; then \
	    mkdir $(DISTNAME)/$$d; \
	  fi \
	done
	for f in `cat DISTFILES`; do \
	  $(LN) $(srcdir)/$$f $(DISTNAME)/$$f || \
		{ echo copying $$f; cp -p $(srcdir)/$$f $(DISTNAME)/$$f ; } \
	done
	(cd $(DISTNAME); $(MAKE) $(MFLAGS) distclean)
	$(TAR) chvf - $(DISTNAME) | gzip >$(DISTNAME).tar.gz
	$(RM) -rf $(DISTNAME)

# Gets rid of most of the unwanted files.  Verify manually (if necessary)
# that this produces a list of all the files desired in the distribution. 
DISTFILES: FORCE
	$(RM) -rf $(DISTNAME)
	(cd $(srcdir); find . ! -type d -print) \
	| sed  '/\/RCS\//d; \
	       /\/EMACS-BACKUPS\//d; \
	       /\.tar.*/d; \
	       /~$$/d; /\.o$$/d; \
	       /\/config\.status$$/d; \
	       /\/.*\.BAK$$/d; \
	       /\/TAGS$$/d; \
	       /\/core$$/d; \
	       /\/[a-z]*\.core$$/d; \
	       /\/core\.[a-z]*$$/d; \
	       /\/a.out$$/d; \
	       /\/=/d; \
	       /\/conftest\.c$$/d; \
	       /\/DISTFILES$$/d; \
	       /\/xact\/xact$$/d; \
	       /\.toc$$/d; \
	       /\.aux$$/d; /\.log$$/d; \
	       /\.cps$$/d; /\.cp$$/d; \
	       /\.fns$$/d; /\.fn$$/d; \
	       /\.tps$$/d; /\.tp$$/d; \
	       /\.vrs$$/d; /\.vr$$/d; \
	       /\.pgs$$/d; /\.pg$$/d; \
	       /\.kys$$/d; /\.ky$$/d; \
	       s/^.\///; /^\.$$/d;' \
	| sort | uniq > DISTFILES


FORCE:
