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 );
44 @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))";
45 $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)"
47 # used in subdirs like libc/ctype whose files
48 # are contained in a parent's library
49 install : recurse $(OBJS) $(LIB_LIB)
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)"
59 clean-intermediate : recurse
60 @-echo "dummy" > .dummy
61 $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf)))
63 include $(topsrcdir)/Makefile.rules