a98191b06925ec9a042e75bd2111ffe996c8220e
[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 AT web.de>
5 ###
6 ### The library is currently maintained by
7 ###     Raphael Neider <rneider AT 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 $(top_builddir)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 $(top_srcdir); pwd)/%,%,$(CURDIR))
22
23 C_SRC   ?= $(notdir $(wildcard $(srcdir)/*.c))
24 S_SRC   ?= $(notdir $(wildcard $(srcdir)/*.S))
25 OBJS    ?= $(addprefix $(top_builddir)$(builddir)/,$(C_SRC:%.c=%.o) $(S_SRC:%.S=%.o))
26
27 LIB_O   ?= $(OBJS)
28
29 ifneq (,$(strip $(MKLIB)))
30 LIB_LIB = $(top_builddir)$(builddir)/$(MKLIB)
31 TARGETS ?= $(LIB_LIB)
32 else
33 LIB_LIB = 
34 #TARGETS ?= $(OBJS)
35 endif
36
37 .PHONY : all install clean clean-intermediate
38
39 all : install
40
41 ifneq (,$(strip $(TARGETS)))
42 # usually install $(LIB_LIB) or $(OBJS), race condition in "[ -d x ] || mkdir x"
43 install : recurse $(OBJS) $(LIB_LIB)
44         -@$(MKDIR) "$(top_builddir)$(installdir)"
45 ifndef SILENT
46         @echo "[INSTALL] $(patsubst $(top_builddir)$(builddir)/%,%,$(TARGETS))"
47 endif
48         $(Q)$(CP) $(TARGETS) "$(top_builddir)$(installdir)"
49 else
50 # used in subdirs like libc/ctype whose files
51 # are contained in a parent's library
52 install : recurse $(OBJS) $(LIB_LIB)
53 endif
54
55 clean : recurse
56         @-echo "dummy" > .dummy
57         $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
58         @-echo "dummy" > .dummy
59         $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
60         $(Q)-$(RM) $(TARGETS)
61         $(Q)-$(RM) $(addprefix $(top_builddir)$(installdir)/,$(notdir $(TARGETS)))
62         $(Q)-[ ! -d "$(top_builddir)$(builddir)" ] || $(RMDIR) "$(top_builddir)$(builddir)"
63
64 distclean : clean
65         $(Q)-$(RM) Makefile
66
67 clean-intermediate : recurse
68         @-echo "dummy" > .dummy
69         $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf)))
70         
71 include $(top_srcdir)/Makefile.rules