#
# Makefile for the linux ncp-filesystem routines.
#

TOPDIR = $(shell pwd)
include ./Makeinit

EXECSUBDIRS = lib-static-su sutil util ipx-1.0 man
SUBDIRS := $(EXECSUBDIRS) lib-shared lib-static
INSTALL_SUBDIRS := util sutil man ipx-1.0
ifeq ($(HAVE_ELF),yes)
EXECSUBDIRS := lib-shared $(EXECSUBDIRS)
INSTALL_SUBDIRS := lib-shared $(INSTALL_SUBDIRS)
else
EXECSUBDIRS := lib-static $(EXECSUBDIRS)
INSTALL_SUBDIRS := lib-static $(INSTALL_SUBDIRS)
endif

export INCLUDES VERSION HAVE_ELF CFLAGS 

all:
	set -e; for i in $(EXECSUBDIRS); do make -C $$i all; done
	@if [ "$(HAVE_ELF)" = yes ] ;\
	then \
	echo ; echo ; echo ;\
	echo Please add \'`pwd`/lib\' to the environment ; \
	echo variable LD_LIBRARY_PATH by executing ; \
	echo ;\
	echo export LD_LIBRARY_PATH=\"\$$LD_LIBRARY_PATH:`pwd`/lib\" ; \
	echo ;\
	echo or do a \'make install\'. ;\
	echo ;\
	fi	

dep:
	for i in $(SUBDIRS); do	make -C $$i dep; done

install:
	for i in $(INSTALL_SUBDIRS); do	make -C $$i install; done

clean_me:
	rm -f `find -name '*.out'`
	rm -f `find -name '*~'`
	rm -f *.tgz

clean: clean_me
	for i in $(SUBDIRS); do	make -C $$i clean; done

mrproper: clean_me
	for i in $(SUBDIRS) ipxdump; do make -C $$i mrproper; done

modules: ncpfs.o

SRCPATH=$(shell pwd)
SRCDIR=$(shell basename $(SRCPATH))
DISTFILE=$(SRCDIR).tgz

dist: tgz
	make dep
	make all

tgz: 
	indent -kr -i8 `find . -name '*.[ch]'`
	make mrproper
	(cd ..; \
         tar cvf - $(SRCDIR) | \
            gzip -9 > $(DISTFILE); \
         mv $(DISTFILE) $(SRCDIR))

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
