* configure.in, configure: have device/lib/pic configured
[fw/sdcc] / device / lib / pic / Makefile.subdir
1 ###########################################################
2 ### Makefile.subdir for the SDCC/PIC14 Library
3 ###
4 ### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
5 ###
6 ### The library is currently maintained by
7 ###     Raphael Neider <rneider@web.de>
8 ###
9 ### This file may be distributed under the terms of the the
10 ### GNU General Public License (GPL). See GPL for details.
11 ###
12 ### $Id$
13 ###
14
15 include $(topsrcdir)/Makefile.common
16
17 SUBDIRS ?= 
18 MKLIB   ?= 
19
20 # fallback: if builddir is not specified via the command line...
21 builddir ?= build/$(patsubst $(shell cd $(topsrcdir); pwd)/%,%,$(CURDIR))
22
23 C_SRC   ?= $(wildcard *.c)
24 S_SRC   ?= $(wildcard *.S)
25 OBJS    ?= $(addprefix $(topsrcdir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
26 LIB_O   ?= $(OBJS)
27
28 ifneq (,$(strip $(MKLIB)))
29 LIB_LIB = $(topsrcdir)/$(builddir)/$(MKLIB)
30 TARGETS ?= $(LIB_LIB)
31 else
32 LIB_LIB = 
33 #TARGETS ?= $(OBJS)
34 endif
35
36 .PHONY : all install clean clean-intermediate
37
38 all : install
39
40 ifneq (,$(strip $(TARGETS)))
41 # usually install $(LIB_LIB) or $(OBJS), race condition in "[ -d x ] || mkdir x"
42 install : recurse $(OBJS) $(LIB_LIB)
43         @[ -d "$(topsrcdir)/$(installdir)" ] || ( $(MKDIR) "$(topsrcdir)/$(installdir)" || true );
44         @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))";
45         $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)"
46 else
47 # used in subdirs like libc/ctype whose files
48 # are contained in a parent's library
49 install : recurse $(OBJS) $(LIB_LIB)
50 endif
51
52 clean : recurse
53         @-echo "dummy" > .dummy
54         $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
55         @-echo "dummy" > .dummy
56         $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
57         $(Q)-[ ! -d "$(topsrcdir)/$(builddir)" ] || $(RMDIR) "$(topsrcdir)/$(builddir)"
58
59 clean-intermediate : recurse
60         @-echo "dummy" > .dummy
61         $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf)))
62         
63 include $(topsrcdir)/Makefile.rules