###########################################################
### Makefile for the GNU PIC Library
###
### Copyright (C) 2005 by Raphael Neider <rneider AT web.de>
###
### The GNU PIC Library was originally designed and
### implemented by
###	Vangelis Rokas <vrokas@otenet.gr>
###
### It is currently maintained by
###	Raphael Neider <rneider AT web.de>
###
### This file may be distributed under the terms of the the
### GNU General Public License (GPL). See COPYING for details.
###
### $Id: Makefile.in 4555 2007-01-03 21:19:58Z bernhardheld $
###

top_builddir = ..
top_srcdir   = ..
srcdir       = .


SUBDIRS = adc i2c usart

ifeq ($(origin IO_ARCH),undefined)
include $(top_builddir)/Makefile.common

.PHONY : all clean clean-intermediate install

# I create $(builddir)/$${arch} right here in order to prevent 
# the sub-make's `builddir´ rules from aborting if another sub-make
# already created the above directory (happened on Alpha).
all clean-intermediate install : libio-recurse

clean : libio-recurse
	$(Q)-[ ! -d "$(top_builddir)/$(builddir)" ] || $(RMDIR) "$(top_builddir)/$(builddir)"

distclean : clean
 
libio-recurse :
	$(Q)+cat $(top_builddir)/pics.build \
		| $(SED) -e "s,[ \t]*#.*$$,," \
		| $(GREP) -v "^[ \t]*$$" \
		| while read arch; do \
			[ "x$${arch}" = "x" ] \
			|| ( $(MKDIR) "$(top_builddir)/$(builddir)/$${arch}"; \
				$(MAKE) MKLIB=libio18f$${arch}.lib builddir=$(builddir)/$${arch} ARCH=$${arch} IO_ARCH=$${arch} $(MAKECMDGOALS); ) \
			|| exit 1; \
	done

include $(top_srcdir)/Makefile.rules

else

include $(top_srcdir)/Makefile.subdir

# prevent library to be build in $(SUBDIRS) as well
unexport MKLIB

endif
