1 ###########################################################
2 ### Makefile.subdir for the SDCC/PIC14 Library
4 ### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
6 ### The library is currently maintained by
7 ### Raphael Neider <rneider@web.de>
9 ### This file may be distributed under the terms of the the
10 ### GNU General Public License (GPL). See GPL for details.
15 include $(topsrcdir)/Makefile.common
20 # fallback: if builddir is not specified via the command line...
21 builddir ?= build/$(patsubst $(shell cd $(topsrcdir); pwd)/%,%,$(CURDIR))
23 C_SRC ?= $(wildcard *.c)
24 S_SRC ?= $(wildcard *.S)
25 OBJS ?= $(addprefix $(topsrcdir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
28 ifneq (,$(strip $(MKLIB)))
29 LIB_LIB = $(topsrcdir)/$(builddir)/$(MKLIB)
36 .PHONY : all install clean clean-intermediate
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 );
45 @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))";
47 $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)"
49 # used in subdirs like libc/ctype whose files
50 # are contained in a parent's library
51 install : recurse $(OBJS) $(LIB_LIB)
55 @-echo "dummy" > .dummy
56 $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
57 @-echo "dummy" > .dummy
58 $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
59 $(Q)-[ ! -d "$(topsrcdir)/$(builddir)" ] || $(RMDIR) "$(topsrcdir)/$(builddir)"
61 clean-intermediate : recurse
62 @-echo "dummy" > .dummy
63 $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf)))
65 include $(topsrcdir)/Makefile.rules