* src/*.c, src/pic16/{gen.c,glue.c,main.c}: applied Vangelis
[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@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@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 $(topsrcdir)/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 $(topsrcdir); pwd)/%,%,$(CURDIR))
26
27 C_SRC   ?= $(wildcard *.c)
28 S_SRC   ?= $(wildcard *.S)
29 OBJS    ?= $(addprefix $(topsrcdir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
30 LIB_O   ?= $(OBJS)
31
32 ifneq (,$(strip $(MKLIB)))
33 LIB_LIB = $(topsrcdir)/$(builddir)/$(MKLIB)
34 TARGETS ?= $(LIB_LIB)
35 else
36 LIB_LIB = 
37 #TARGETS ?= $(OBJS)
38 endif
39
40 all : install
41
42 ifneq (,$(strip $(TARGETS)))
43 # usually install $(LIB_LIB) or $(OBJS)
44 install : builddir recurse $(OBJS) $(LIB_LIB)
45         @[ -d "$(topsrcdir)/$(installdir)" ] || $(MKDIR) "$(topsrcdir)/$(installdir)";
46         @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))";
47         $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)"
48 else
49 # used in subdirs like libc/ctype whose files
50 # are contained in a parent's library
51 install : builddir recurse $(OBJS) $(LIB_LIB)
52 endif
53
54 clean : recurse
55         @-echo "dummy" > .dummy
56         $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym hex,$(OBJS:.o=.$(suf)))
57         @-echo "dummy" > .dummy
58         $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
59         $(Q)-[ ! -d "$(topsrcdir)/$(builddir)" ] || $(RMDIR) "$(topsrcdir)/$(builddir)"
60
61 clean-intermediate : recurse
62         @-echo "dummy" > .dummy
63         $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym hex,$(OBJS:.o=.$(suf)))
64         
65 include $(topsrcdir)/Makefile.rules