* src/pic/device.c (pic14_assignConfigWordValue): remember assignments to
[fw/sdcc] / device / lib / pic16 / libio / Makefile
index 8dc2251c0da66a4c03107d4bd60a603806ab4be0..ba199bae49b78a14624e988df5c5cc8b66b9db23 100644 (file)
@@ -1,68 +1,51 @@
-#
-# Makefile - Makefile to build pic16 support libraries
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-MCUS   = $(shell cat ../pics.build)
-
-PROCESSORS     = $(MCUS)
-
-
-DIRS   = adc i2c usart
-
-LOBJS  = $(patsubst %,%/*.o,$(DIRS))
-
-# library name example libio18f8720.lib
-LIB    = libio18f$(MMCU).lib
-
-all: build-libraries
-
-make-target: build-libraries
-
-build-libraries:
-       for proc in $(PROCESSORS) ; do \
-               echo "Building libraries for processor pic18f $$proc" ; \
-               $(MAKE) -C . build-processor-library MMCU=$$proc ;  \
-       done ;
+###########################################################
+### Makefile for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@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@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
+
+topsrcdir=..
+
+SUBDIRS = adc i2c usart
+
+ifeq ($(origin IO_ARCH),undefined)
+include $(topsrcdir)/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 clean-intermediate install :
+       $(Q)+cat $(topsrcdir)/pics.build \
+               | $(SED) -e "s,[ \t]*#.*$$,," \
+               | $(GREP) -v "^[ \t]*$$" \
+               | while read arch; do \
+                       [ "x$${arch}" = "x" ] \
+                       || ( [ -d "$(builddir)/$${arch}" ] || $(MKDIR) "$(builddir)/$${arch}"; \
+                               $(MAKE) MKLIB=libio18f$${arch}.lib builddir=$(builddir)/$${arch} ARCH=$${arch} IO_ARCH=$${arch} $(MAKECMDGOALS); ) \
+                       || exit 1; \
+       done
 
-# Should have externally specified PROC
-build-processor-library:
-       for dir in $(DIRS) ; do  \
-               $(MAKE) -C $$dir clean ; \
-               $(MAKE) -C $$dir build-io-lib MCU=18f$(MMCU); \
-       done;
-       gplib -c $(LIB) $(LOBJS)
-       mv -v $(LIB) ../bin
-       
+include $(topsrcdir)/Makefile.rules
 
-clean-intermediate:
-       @for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean-intermediate ; \
-       done ;
-       
-clean:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean; \
-       done ;
-       rm -fv $(LIB)
+else
 
+include $(topsrcdir)/Makefile.subdir
 
-real-clean: clean
-       find -name *.adb -print | xargs -- rm -fv ;
-       find -name *.p -print | xargs -- rm -fv ;
-       find -name *.d -print | xargs -- rm -fv ;
-       find -name *.dump* -print | xargs -- rm -fv ;
-       
+# prevent library to be build in $(SUBDIRS) as well
+unexport MKLIB
 
-dep:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir dep; \
-       done
+endif