# Makefile for SIL library top directory
#
#   very top SIL directory

##################### LIBRARIES ########################
#
# DIRS:
# This is an ordered list
# Put only the directories that build object files in the list

# make all targets
DIRS = src

ifdef MAC
 INSTALL_PREFIX ?= /usr/local
else
 INSTALL_PREFIX ?= /usr
endif

SRC_INST=$(DESTDIR)$(INSTALL_PREFIX)/share/yumapro/src/libsystem-linux

#################### PLATFORM DEFINITIONS ############

ifdef MAC
all:
else
all: silall
endif

################################ MAKE RULES #################################
#

clean: silclean

superclean: silsuperclean

distclean: silsuperclean

uninstall: libuninstall
	rm -rf $(SRC_INST)

TARGETS=

ifdef DEBIAN
 ifeq "$(PACKAGE)" "DEVELOPER"
TARGETS= libinstall srcinstall
 endif # DEVELOPER

 ifeq "$(PACKAGE)" "SERVER"
TARGETS= libinstall
 endif # SERVER

 ifeq "$(PACKAGE)" "TOOLS"
TARGETS= srcinstall
 endif # TOOLS

else # not DEBIAN
 ifndef MAC
TARGETS= libinstall srcinstall
 endif # MAC
endif  # DEBIAN

install: $(TARGETS)

bindir:
	mkdir -p bin lib

silall: bindir
	for dir in $(DIRS); do\
	  cd $$dir && $(MAKE) && cd ..;\
	done

silclean: bindir
	for dir in $(DIRS); do\
	  cd $$dir && $(MAKE) clean && cd ..;\
	done

silsuperclean: bindir
	for dir in $(DIRS); do\
	  cd $$dir && $(MAKE) superclean && cd ..;\
	done

libinstall: bindir
	for dir in $(DIRS); do\
	  if [ -f $$dir/dependencies ]; then \
	    cd $$dir && $(MAKE) install && cd ..;\
	  fi \
	done

libuninstall:
	for dir in $(DIRS); do\
	  if [ -f $$dir/dependencies ]; then\
	    cd $$dir && $(MAKE) uninstall && cd ..;\
	  fi \
	done

srcinstall:
	mkdir -p $(SRC_INST)
	mkdir -p $(SRC_INST)/src
	mkdir -p $(SRC_INST)/lib
	mkdir -p $(SRC_INST)/bin
	cp Makefile $(SRC_INST)
	cp src/*c $(SRC_INST)/src/
	cp src/*h $(SRC_INST)/src/
	cp src/Makefile $(SRC_INST)/src/

.PHONY: all clean superclean distclean install bindir \
    silall silclean silsuperclean srcinstall libinstall \
    libuninstall

# prevent the make program from choking on all the symbols
# that get generated from autogenerated make rules
.NOEXPORT:
