* */Makefile.in: removed annoying warning:
[fw/sdcc] / device / lib / Makefile.in
index 36d7578bf3893f2f417ff0046f6a1c2064a4ae9d..d0c5d41bf8e18c1e5c77b531e61fb6993e901f94 100644 (file)
@@ -12,98 +12,126 @@ CPP                = @CPP@
 INSTALL                = @INSTALL@
 CP              = @CP@
 
-PRJDIR         = ../..
-INCDIR         = $(PRJDIR)/device/include
+ifeq ($(shell uname -s),Linux)
+CP_U   = $(CP) -u
+else
+CP_U   = $(CP)
+endif
+
+top_builddir   = @top_builddir@
+top_srcdir     = @top_srcdir@
+VPATH           = @srcdir@
+srcdir          = @srcdir@
+INCDIR         = $(top_srcdir)/device/include
 ifndef PORTINCDIR
 PORTINCDIR     = $(INCDIR)/mcs51
 endif
 
-CC             = $(PRJDIR)/bin/sdcc
-CPP            = $(PRJDIR)/bin/sdcpp
+CC             = $(top_builddir)/bin/sdcc
+CPP            = $(top_builddir)/bin/sdcpp
 
 prefix          = @prefix@
 exec_prefix     = @exec_prefix@
 bindir          = @bindir@
 libdir          = @libdir@
 datadir         = @datadir@
+datarootdir     = @datarootdir@
 includedir      = @includedir@
 mandir          = @mandir@
 man1dir         = $(mandir)/man1
 man2dir         = $(mandir)/man2
 infodir         = @infodir@
-srcdir          = @srcdir@
 
 lib_dir_suffix  = @lib_dir_suffix@
 
 sdcc_libdir     = $(DESTDIR)$(datadir)/$(lib_dir_suffix)
 
 CPPFLAGS        = -I$(INCDIR) -I$(PORTINCDIR)
-CFLAGS         = $(MODELFLAGS) --nostdinc
+CFLAGS         = $(MODELFLAGS) --nostdinc --std-c99
 
 BUILDDIR        = build
 # Default
 PORT            = z80
+ifndef PORTDIR
 PORTDIR         = $(BUILDDIR)/$(PORT)
+endif
 
-SOURCES                = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
-                 _decdptr.c _divsint.c _divslong.c _divuint.c \
-                 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
-                 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
-                 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fscmp.c _fsmul.c \
-                 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
-                 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
-                 _islower.c _isprint.c _ispunct.c _isspace.c \
-                 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
-                 _slong2fs.c \
-                 _memcmp.c _memcpy.c _memmove.c _memset.c \
-                 _modsint.c _modslong.c _moduint.c _modulong.c \
-                 _mulint.c _mullong.c \
-                 abs.c labs.c \
-                 _ser.c _setjmp.c \
-                 _spx.c _startup.c \
-                 _strcat.c _strchr.c _strcmp.c _strcpy.c \
-                 _strcspn.c _strlen.c _strncat.c _strncmp.c \
-                 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
-                 _strstr.c _strtok.c \
-                 _uchar2fs.c _uint2fs.c _ulong2fs.c \
-                 calloc.c malloc.c realloc.c free.c \
-                 serial.c ser_ir.c printfl.c \
-                 printf_large.c sprintf.c vprintf.c puts.c gets.c \
-                 printf_fast.c printf_fast_f.c printf_tiny.c \
-                 assert.c time.c bpx.c \
-                 _fsget1arg.c _fsget2args.c _fsnormalize.c \
-                 _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
-                 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
-                 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
-                 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
-                 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
+OPT_DISABLE_AVR   = @OPT_DISABLE_AVR@
+OPT_DISABLE_DS390 = @OPT_DISABLE_DS390@
+OPT_DISABLE_DS400 = @OPT_DISABLE_DS400@
+OPT_DISABLE_GBZ80 = @OPT_DISABLE_GBZ80@
+OPT_DISABLE_HC08  = @OPT_DISABLE_HC08@
+OPT_DISABLE_MCS51 = @OPT_DISABLE_MCS51@
+OPT_DISABLE_PIC   = @OPT_DISABLE_PIC@
+OPT_DISABLE_PIC16 = @OPT_DISABLE_PIC16@
+OPT_DISABLE_XA51  = @OPT_DISABLE_XA51@
+OPT_DISABLE_Z80   = @OPT_DISABLE_Z80@
+
+SOURCES =      _autobaud.c _bp.c _decdptr.c \
+               _gptrget.c _gptrgetc.c _gptrput.c \
+               _ser.c _setjmp.c \
+               serial.c ser_ir.c \
+               _atof.c _atoi.c _atol.c _itoa.c _ltoa.c \
+               _schar2fs.c _sint2fs.c _slong2fs.c \
+               _uchar2fs.c _uint2fs.c _ulong2fs.c \
+               _fs2schar.c _fs2sint.c _fs2slong.c \
+               _fs2uchar.c _fs2uint.c _fs2ulong.c \
+               _fsadd.c _fsdiv.c _fsmul.c _fssub.c \
+               _fseq.c _fsgt.c _fslt.c _fsneq.c \
+               _divsint.c _divslong.c _divuint.c _divulong.c \
+               _modsint.c _modslong.c _moduint.c _modulong.c \
+               _mulint.c _mullong.c \
+               abs.c labs.c rand.c \
+               _iscntrl.c _isdigit.c _isgraph.c \
+               _isprint.c _ispunct.c _isspace.c \
+               _islower.c _isupper.c _isxdigit.c \
+               _spx.c _startup.c \
+               _strcat.c _strchr.c _strcmp.c _strcpy.c \
+               _strcspn.c _strlen.c _strncat.c _strncmp.c \
+               _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
+               _strstr.c _strtok.c \
+               _memcmp.c _memcpy.c _memmove.c _memset.c \
+               _heap.c calloc.c malloc.c realloc.c free.c \
+               printf_large.c sprintf.c vprintf.c puts.c gets.c \
+               printf_fast.c printf_fast_f.c printf_tiny.c printfl.c \
+               assert.c time.c bpx.c \
+               _fscmp.c _fsget1arg.c _fsget2args.c _fsnormalize.c \
+               _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
+               fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
+               cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
+               asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
+               sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
 
 OBJECTS                = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
 
-Z80SOURCES      = _atof.c _atoi.c \
-                 _iscntrl.c _isdigit.c _isgraph.c \
-                 _islower.c _isprint.c _ispunct.c _isspace.c \
-                 _isupper.c _isxdigit.c \
-                 _memcmp.c _memcpy.c _memmove.c _memset.c \
-                 _startup.c \
-                 _strcat.c _strchr.c _strcmp.c _strcpy.c \
-                 _strcspn.c _strlen.c _strncat.c _strncmp.c \
-                 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
-                 _strstr.c _strtok.c \
-                 assert.c \
-                 _modslong.c _modulong.c \
-                 _mullong.c \
-                 abs.c labs.c \
-                 _divslong.c _divulong.c \
-                 calloc.c malloc.c realloc.c free.c \
-                 printf_large.c sprintf.c vprintf.c puts.c gets.c \
-                 _fs2schar.c _fs2sint.c _fs2slong.c \
-                 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
-                 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
-                 _fsneq.c _fssub.c \
-                 _uchar2fs.c _uint2fs.c \
-                 _ulong2fs.c \
-                 _slong2fs.c _sint2fs.c _schar2fs.c
+Z80SOURCES =   \
+               _atof.c _atoi.c _atol.c _itoa.c _ltoa.c \
+               _schar2fs.c _sint2fs.c _slong2fs.c \
+               _uchar2fs.c _uint2fs.c _ulong2fs.c \
+               _fs2schar.c _fs2sint.c _fs2slong.c \
+               _fs2uchar.c _fs2uint.c _fs2ulong.c \
+               _fsadd.c _fsdiv.c _fsmul.c _fssub.c \
+               _fseq.c _fsgt.c _fslt.c _fsneq.c \
+               _divslong.c _divulong.c \
+               _modslong.c _modulong.c \
+               _mullong.c \
+               abs.c labs.c rand.c \
+               _iscntrl.c _isdigit.c _isgraph.c \
+               _isprint.c _ispunct.c _isspace.c \
+               _islower.c _isupper.c _isxdigit.c \
+               _startup.c \
+               _strcat.c _strchr.c _strcmp.c _strcpy.c \
+               _strcspn.c _strlen.c _strncat.c _strncmp.c \
+               _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
+               _strstr.c _strtok.c \
+               _memcmp.c _memcpy.c _memmove.c _memset.c \
+               calloc.c malloc.c realloc.c free.c \
+               printf_large.c sprintf.c vprintf.c puts.c gets.c \
+               assert.c time.c \
+               fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
+               cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
+               asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
+               sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
 
 Z80OBJECTS      = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
 
@@ -118,13 +146,13 @@ XA51SOURCES      = _atof.c _atoi.c _atol.c _schar2fs.c \
                  _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
                  _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
                  _moduint.c _modulong.c _mulint.c _mullong.c \
-                 abs.c labs.c \
+                 abs.c labs.c rand.c \
                  _strcat.c _strchr.c _strcmp.c _strcpy.c \
                  _strcspn.c _strlen.c _strncat.c _strncmp.c \
                  _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
                  _strstr.c _strtok.c \
                  _uchar2fs.c _uint2fs.c _ulong2fs.c \
-                 calloc.c malloc.c realloc.c free.c \
+                 _heap.c calloc.c malloc.c realloc.c free.c \
                  puts.c gets.c \
                  printf_large.c puts.c gets.c \
                  assert.c time.c \
@@ -135,78 +163,116 @@ XA51SOURCES      = _atof.c _atoi.c _atol.c _schar2fs.c \
 
 XA51OBJECTS      = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
 
-HC08SOURCES    = _atof.c _atoi.c _atol.c _schar2fs.c \
-                 _divsint.c _divslong.c \
-                 _fs2schar.c _fs2sint.c _fs2slong.c \
-                 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
-                 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
-                 _fsneq.c _fssub.c \
-                 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
-                 _islower.c _isprint.c _ispunct.c _isspace.c \
-                 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
-                 _slong2fs.c \
-                 _memcmp.c _memcpy.c _memmove.c _memset.c \
-                 _modsint.c _modslong.c _moduint.c _modulong.c \
-                 abs.c labs.c \
-                 _spx.c _startup.c \
-                 _strcat.c _strchr.c _strcmp.c _strcpy.c \
-                 _strcspn.c _strlen.c _strncat.c _strncmp.c \
-                 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
-                 _strstr.c _strtok.c \
-                 _uchar2fs.c _uint2fs.c _ulong2fs.c \
-                 calloc.c malloc.c realloc.c free.c \
-                 printf_large.c sprintf.c vprintf.c \
-                 assert.c time.c \
-                 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
-                 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
-                 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
-                 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
+HC08SOURCES =  \
+               _atof.c _atoi.c _atol.c _itoa.c _ltoa.c \
+               _schar2fs.c _sint2fs.c _slong2fs.c \
+               _uchar2fs.c _uint2fs.c _ulong2fs.c \
+               _fs2schar.c _fs2sint.c _fs2slong.c \
+               _fs2uchar.c _fs2uint.c _fs2ulong.c \
+               _fsadd.c _fsdiv.c _fsmul.c _fssub.c \
+               _fseq.c _fsgt.c _fslt.c _fsneq.c \
+               _divsint.c _divslong.c \
+               _modsint.c _modslong.c _moduint.c _modulong.c \
+               abs.c labs.c rand.c \
+               _iscntrl.c _isdigit.c _isgraph.c \
+               _isprint.c _ispunct.c _isspace.c \
+               _islower.c _isupper.c _isxdigit.c \
+               _spx.c _startup.c \
+               _strcat.c _strchr.c _strcmp.c _strcpy.c \
+               _strcspn.c _strlen.c _strncat.c _strncmp.c \
+               _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
+               _strstr.c _strtok.c \
+               _memcmp.c _memcpy.c _memmove.c _memset.c \
+               _heap.c calloc.c malloc.c realloc.c free.c \
+               printf_large.c sprintf.c vprintf.c puts.c gets.c \
+               assert.c time.c \
+               fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
+               cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
+               asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
+               sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
 
 HC08OBJECTS    = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
 
 OEXT            = .rel
 
-include incl.mk
+include $(srcdir)/incl.mk
+
+ifeq ($(OPT_DISABLE_DS390), 0)
+TARGETS        += model-ds390
+endif
+
+ifeq ($(OPT_DISABLE_DS400), 0)
+TARGETS        += model-ds400
+endif
+
+ifeq ($(OPT_DISABLE_HC08), 0)
+TARGETS        += model-hc08
+endif
+
+ifeq ($(OPT_DISABLE_MCS51), 0)
+TARGETS        += models small-mcs51-stack-auto
+endif
+
+ifeq ($(OPT_DISABLE_PIC), 0)
+TARGETS        += model-pic14
+endif
+
+ifeq ($(OPT_DISABLE_PIC16), 0)
+TARGETS        += model-pic16
+endif
+
+ifeq ($(OPT_DISABLE_Z80), 0)
+TARGETS        += model-z80
+endif
+
+ifeq ($(OPT_DISABLE_GBZ80), 0)
+TARGETS        += model-gbz80
+endif
 
 # Compiling entire program or any subproject
 # ------------------------------------------
-all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08 model-pic16
+all: checkconf $(TARGETS)
 
 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
 
 models:
-       if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
+       if [ "`grep mcs51 $(top_builddir)/ports.build`" = mcs51 ]; then \
          for model in $(MODELS); do \
            $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model PORTINCDIR=$(INCDIR)/mcs51 objects; \
          done \
        fi
 
+small-mcs51-stack-auto:
+       if [ "`grep mcs51 $(top_builddir)/ports.build`" = mcs51 ]; then \
+         $(MAKE) MODELFLAGS="--model-small --stack-auto" PORT=small PORTDIR=$(BUILDDIR)/small-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
+       fi
+
 model-mcs51-stack-auto:
-       if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
+       if [ "`grep mcs51 $(top_builddir)/ports.build`" = mcs51 ]; then \
          for model in $(MODELS); do \
-           $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
+           $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model PORTDIR=$(BUILDDIR)/$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
          done \
        fi
 
 model-mcs51-xstack-auto:
-       if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
+       if [ "`grep mcs51 $(top_builddir)/ports.build`" = mcs51 ]; then \
          for model in $(MODELS); do \
-           $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model-xstack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
+           $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model PORTDIR=$(BUILDDIR)/$$model-xstack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
          done \
        fi
 
 model-ds390:
-       if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
+       if [ "`grep ds390 $(top_builddir)/ports.build`" = ds390 ]; then \
          $(MAKE) MODELFLAGS="-mds390" PORT=ds390 PORTINCDIR=$(INCDIR)/mcs51 objects; \
        fi
 
 model-ds400:
-       if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
+       if [ "`grep ds400 $(top_builddir)/ports.build`" = ds400 ]; then \
          $(MAKE) MODELFLAGS="-mds400" PORT=ds400 PORTINCDIR=$(INCDIR)/mcs51 objects; \
        fi
 
 model-xa51:
-       if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
+       if [ "`grep xa51 $(top_builddir)/ports.build`" = xa51 ]; then \
          $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
        fi
 
@@ -214,12 +280,12 @@ objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
        cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
 
 model-z80:
-       if [ "`grep z80 ../../ports.build`" = z80 ]; then \
+       if [ "`grep z80 $(top_builddir)/ports.build`" = z80 ]; then \
          $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
        fi
 
 model-gbz80:
-       if [ "`grep z80 ../../ports.build`" = z80 ]; then \
+       if [ "`grep z80 $(top_builddir)/ports.build`" = z80 ]; then \
          $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
        fi
 
@@ -227,7 +293,7 @@ objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
        cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
 
 model-hc08:
-       if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
+       if [ "`grep hc08 $(top_builddir)/ports.build`" = hc08 ]; then \
          $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
        fi
 
@@ -235,13 +301,18 @@ objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
        cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
 
 model-pic16:
-       if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
+       if [ "`grep pic16 $(top_builddir)/ports.build`" = pic16 ]; then \
          $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
-         fi
+       fi
 
 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
-       cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
+       -cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
 
+# yes, we do reuse the *-pic16 rules for pic14
+model-pic14:
+       if [ "`grep pic $(top_builddir)/ports.build | grep -v pic16`" = pic ]; then \
+         $(MAKE) MODELFLAGS="-mpic14" PORT=pic OEXT=.lib objects-pic16; \
+       fi
 
 build-dir: $(PORTDIR)
 
@@ -249,20 +320,20 @@ $(PORTDIR):
        mkdir -p $(PORTDIR)
 
 port-specific-objects:
-       if [ -d $(PORT) ]; then \
+       -if [ -f $(PORT)/Makefile ]; then \
          $(MAKE) -C $(PORT); \
          cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
        fi
 
 port-specific-objects-pic16:
-       if [ -d $(PORT) ]; then \
-         mkdir -p $(PORT)/bin \
+       -if [ -f $(PORT)/Makefile ]; then \
+         mkdir -p $(PORT)/bin; \
          $(MAKE) -C $(PORT); \
          cp -f $(PORT)/bin/*.* $(PORTDIR); \
        fi
 
 lib-files:
-       cp *.lib $(PORTDIR)
+       cp $(srcdir)/*.lib $(PORTDIR)
 
 clean_intermediate:
        rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
@@ -273,9 +344,24 @@ clean_intermediate-pic16:
 # Compiling and installing everything and runing test
 # ---------------------------------------------------
 install: all installdirs
-       cp -r -u $(BUILDDIR)/* $(sdcc_libdir)
-       cp -r -u ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
-       rm -r `find $(sdcc_libdir)/src -name '*.rel' -or -name '*.dump*' -or -name '*.sym' -or -name '*.o' -or -name '*.lst' -or -name '*.asm' -or -name 'CVS'`
+       $(CP_U) -r $(BUILDDIR)/* $(sdcc_libdir)
+       $(CP_U) -r $(MODELS) $(srcdir)/mcs51 $(srcdir)/ds390 $(srcdir)/ds400 \
+                            $(srcdir)/gbz80 $(srcdir)/z80 $(srcdir)/hc08 \
+                            $(srcdir)/pic $(srcdir)/pic16 $(srcdir)/*.c $(sdcc_libdir)/src
+       $(CP_U) -r $(MODELS) mcs51 ds390 ds400 gbz80 z80 hc08 $(sdcc_libdir)/src
+
+       for src in $(MODELS) ds390 ds400 gbz80 z80 hc08 pic pic16; do \
+         find $(sdcc_libdir)/src/$$src -depth \
+           \( -name '*.rel' -o -name '*.dump*' -o -name '*.sym' -o -name '*.o' -o -name '*.lib' -o \
+           -name '*.lst' -o -name '*.asm' -o -name '.svn' -o -name 'build' -o -name 'bin' -o \
+           -name 'Makefile*' \) \
+           -exec rm -rf {}+ \; ; \
+       done
+       find $(sdcc_libdir)/src/mcs51 -depth \
+         \( -name '*.rel' -o -name '*.dump*' -o -name '*.sym' -o -name '*.o' -o -name '*.lib' -o \
+         -name '*.lst' -o -name '.svn' -o -name 'build' -o -name 'bin' -o \
+         -name 'Makefile*' \) \
+         -exec rm -rf {}+ \;
 
 # Deleting all the installed files
 # --------------------------------
@@ -297,13 +383,12 @@ installcheck:
 installdirs:
        [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
        for model in $(MODELS); do \
-        [ -d $(sdcc_libdir)/$$model ] || \
-        mkdir -p $(sdcc_libdir)/$$model; \
+         [ -d $(sdcc_libdir)/$$model ] || \
+         mkdir -p $(sdcc_libdir)/$$model; \
+       done
+       for libdir in small-stack-auto ds390 ds400 hc08 pic16 pic; do \
+         [ -d $(sdcc_libdir)/$$libdir ] || mkdir -p $(sdcc_libdir)/$$libdir; \
        done
-       [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
-       [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
-       [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
-       [ -d $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
        mkdir -p $(sdcc_libdir)/src
 
 # Creating dependencies
@@ -312,14 +397,17 @@ dep: Makefile.dep
 
 Makefile.dep: $(SOURCES) $(INCDIR)/*.h $(PORTINCDIR)/*.h
        rm -f Makefile.dep
-       for i in $(SOURCES); do \
+       for i in $(filter %.c,$^); do \
          $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
          cat $${i}.dep >>Makefile.dep; \
          rm $${i}.dep; \
        done
 
-include Makefile.dep
-include clean.mk
+ifeq "$(findstring $(MAKECMDGOALS),uninstall check installcheck installdirs checkconf \
+                                   clean distclean mostlyclean realclean)" ""
+  -include Makefile.dep
+endif
+include $(srcdir)/clean.mk
 
 # My rules
 # --------
@@ -332,8 +420,8 @@ $(PORTDIR)/%$(OEXT): %.c
 # Remaking configuration
 # ----------------------
 checkconf:
-       @if [ -f $(PRJDIR)/devel ]; then\
-         $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
+       @if [ -f $(top_builddir)/devel ]; then\
+         $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" top_builddir="$(top_builddir)" \
          freshconf;\
        fi