## -*- mode: Makefile -*-
##
## Copyright (c) 2000 University of Utah and the Flux Group.
## All rights reserved.
## 
## This file is part of the Knit component composition software.
## 
## Permission to use, copy, modify, distribute, and sell this software and
## its documentation is hereby granted without fee, provided that the above
## copyright notice and this permission/disclaimer notice is retained in all
## copies or modified versions, and that both notices appear in supporting
## documentation.  THE COPYRIGHT HOLDERS PROVIDE THIS SOFTWARE "AS IS" AND
## WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION,
## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE.  THE COPYRIGHT HOLDERS DISCLAIM ANY LIABILITY OF ANY KIND FOR
## ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
## 
## Users are requested, but not required, to send to csl-dist@cs.utah.edu any
## improvements that they make and grant Univ. of Utah redistribution rights.
##

# In binary distributions, the binaries are in the ``source'' tree.
vpath % $(SRCDIR)

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

# This goes first to make it the default.
.PHONY: all
all		::

.PHONY: install
install		::

.PHONY: clean
clean		::

.PHONY: veryclean
veryclean	:: clean

###############################################################################
# Installation rules for binaries
###############################################################################

BIN_FILES =
##
## Programs that Knit users may usefully invoke.
##
BIN_FILES += knit
BIN_FILES += knitdoc
BIN_FILES += mk_unit
BIN_FILES += rename_dot_o_files
##
## Programs that the above programs use internally.  These are not intended for
## users to invoke directly, and so they should really go into `.../libexec',
## not $(INSTALL_BINDIR).  But for now, we're a little lazy.
##
BIN_FILES += knit_c_parser
BIN_FILES += knitGenBundles
BIN_FILES += knit_smartmv

install:: $(BIN_FILES)
	$(INSTALL) -d $(INSTALL_BINDIR)
	for f in $^; do $(INSTALL_PROGRAM) $$f $(INSTALL_BINDIR); done

###############################################################################
# Installation rules for libraries and other support files
###############################################################################

LIB_FILES =
##
## Any Haskell source or shared object files are put into $(INSTALL_LIBDIR).
##
LIB_FILES += $(wildcard *.hs) $(wildcard *.lhs) $(wildcard *.so)

ifneq "$(strip $(LIB_FILES))" ""

install:: $(LIB_FILES)
	$(INSTALL) -d $(INSTALL_LIBDIR)
	for f in $^; do $(INSTALL_DATA) $$f $(INSTALL_LIBDIR); done

endif

###############################################################################
# Special targets, used by the scripts that prepare binary distributions
###############################################################################

## `DIST_BINDIR' must be set by the distribution-making script.
##
DIST_BINDIR :=

ifneq "$(strip $(DIST_BINDIR))" ""

.PHONY: make-binary-dist
make-binary-dist:
	$(CP) $(BIN_FILES) $(LIB_FILES) $(DIST_BINDIR)

.PHONY: clean-binary-dist
clean-binary-dist:
	$(RM) $(addprefix $(DIST_BINDIR)/,$(BIN_FILES) $(LIB_FILES))

endif

###############################################################################
# End of Makefile
###############################################################################

