* src/pic16/gen.c (genCast): fixed typo
[fw/sdcc] / device / lib / pic16 / Makefile.subdir
1 ###########################################################
2 ### Makefile.subdir for the GNU PIC Library
3 ###
4 ### Copyright (C) 2005 by Raphael Neider <rneider AT web.de>
5 ###
6 ### The GNU PIC Library was originally designed and
7 ### implemented by
8 ###     Vangelis Rokas <vrokas@otenet.gr>
9 ###
10 ### It is currently maintained by
11 ###     Raphael Neider <rneider AT web.de>
12 ###
13 ### This file may be distributed under the terms of the the
14 ### GNU General Public License (GPL). See COPYING for details.
15 ###
16 ### $Id$
17 ###
18
19 include $(top_builddir)/Makefile.common
20
21 SUBDIRS ?= 
22 MKLIB   ?= 
23
24 # fallback: if builddir is not specified via the command line...
25 builddir ?= build/$(patsubst $(shell cd $(top_builddir); pwd)/%,%,$(CURDIR))
26
27 C_SRC   ?= $(notdir $(wildcard $(srcdir)/*.c))
28 S_SRC   ?= $(notdir $(wildcard $(srcdir)/*.S))
29 OBJS    ?= $(addprefix $(top_builddir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
30 LIB_O   ?= $(OBJS)
31
32 ifneq (,$(strip $(MKLIB)))
33 LIB_LIB = $(top_builddir)/$(builddir)/$(MKLIB)
34 TARGETS ?= $(LIB_LIB)
35 else
36 LIB_LIB = 
37 #TARGETS ?= $(OBJS)
38 endif
39
40 .PHONY : all install clean clean-intermediate $(addprefix install,$(TARGETS))
41
42 ifndef SILENT
43 ECHO=echo
44 else
45 ECHO=true
46 endif
47
48 all : install
49
50 ifneq (,$(strip $(TARGETS)))
51
52 $(addprefix install,$(TARGETS)): install% : %
53         @-if [ -e "$<" ]; then \
54         [ -d "$(top_builddir)/$(installdir)" ] || $(MKDIR) "$(top_builddir)/$(installdir)"; \
55         $(ECHO) "[INSTALL] $(patsubst $(top_builddir)/$(builddir)/%,%,$<)"; \
56         [ ! -e "$<" ] || $(CP) "$<" "$(top_builddir)/$(installdir)"; \
57         fi
58
59 # usually install $(LIB_LIB) or $(OBJS), race condition in "[ -d x ] || mkdir x"
60 install : recurse $(OBJS) $(LIB_LIB) $(addprefix install,$(TARGETS))
61 else
62 # used in subdirs like libc/ctype whose files
63 # are contained in a parent's library
64 install : recurse $(OBJS) $(LIB_LIB)
65 endif
66
67 clean : recurse
68         @-echo "dummy" > .dummy
69         $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
70         @-echo "dummy" > .dummy
71         $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
72         @-echo "dummy" > .dummy
73         $(Q)-$(RM) .dummy $(TARGETS)
74         @-echo "dummy" > .dummy
75         $(Q)-$(RM) .dummy $(addprefix $(top_builddir)/$(installdir)/,$(notdir $(TARGETS)))
76         $(Q)-[ ! -d "$(top_builddir)/$(builddir)" ] || $(RMDIR) "$(top_builddir)/$(builddir)"
77
78 distclean : clean
79
80 clean-intermediate : recurse
81         @-echo "dummy" > .dummy
82         $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf)))
83         
84 include $(top_srcdir)/Makefile.rules