# @configure_input@
#
# Common rules for octave's libcruft directories.
#
# XXX FIXME XXX -- assumes that the libcruft directory tree is only
# one level deep.
#
# John W. Eaton
# jwe@bevo.che.wisc.edu
# University of Wisconsin-Madison
# Department of Chemical Engineering

SOURCES = *.f

DISTFILES = Makefile.in $(SOURCES) $(SPECIAL)

CRUFT_SRC = $(wildcard $(srcdir)/*.f) \
             $(wildcard $(srcdir)/*.c) \
             $(wildcard $(srcdir)/*.cc)
CRUFT_BASE = $(basename $(notdir $(CRUFT_SRC)) )
CRUFT_OBJ = $(addsuffix .o, $(CRUFT_BASE) )

ifeq ($(SHARED_LIBS), true)
  ifdef FPICFLAG
    CRUFT_PICOBJ := $(addprefix pic/, $(CRUFT_OBJ))
  else
    CRUFT_PICOBJ := $(CRUFT_OBJ)
  endif
endif

CWD = $(shell pwd)
THISDIR = $(notdir $(CWD))

LIBCRUFT = ../libcruft.a

LIBCRUFT_OBJS = $(CRUFT_OBJ) $(SPECIAL_DEPEND)

LIBCRUFT_DEPS = $(LIBCRUFT)($(LIBCRUFT_OBJS))

all: pic $(LIBCRUFT_DEPS) $(CRUFT_PICOBJ) $(SPECIAL_PICDEPEND)
.PHONY: all

.PRECIOUS: $(LIBCRUFT_OBJS)

pic:
	@if [ -d pic ]; then \
	  true; \
	else \
	  echo "mkdir pic"; \
	  mkdir pic; \
	fi

install:: all
.PHONY: install

uninstall::
.PHONY: uninstall

tags: $(SOURCES)
	ctags $(SOURCES)

TAGS: $(SOURCES)
	etags $(SOURCES)

clean::
	rm -f *.a *.o pic/*.o
.PHONY: clean

mostlyclean::
	rm -f *.o pic/*.o
.PHONY: mostlyclean

distclean:: clean
	rm -f Makefile stamp-picdir
	-rmdir pic
.PHONY: distclean
	
maintainer-clean:: distclean
	rm -f tags TAGS
.PHONY: maintainer-clean

dist:
	ln $(EXTERNAL_DISTFILES) ../../`cat ../../.fname`/libcruft/$(THISDIR)
.PHONY: dist
