1 ###########################################################
2 ### Makefile.subdir for the GNU PIC Library
4 ### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
6 ### The GNU PIC Library was originally designed and
8 ### Vangelis Rokas <vrokas@otenet.gr>
10 ### It is currently maintained by
11 ### Raphael Neider <rneider@web.de>
13 ### This file may be distributed under the terms of the the
14 ### GNU General Public License (GPL). See COPYING for details.
19 include $(topsrcdir)/Makefile.common
24 # fallback: if builddir is not specified via the command line...
25 builddir ?= build/$(patsubst $(shell cd $(topsrcdir); pwd)/%,%,$(CURDIR))
27 C_SRC ?= $(wildcard *.c)
28 S_SRC ?= $(wildcard *.S)
29 OBJS ?= $(addprefix $(topsrcdir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
32 ifneq (,$(strip $(MKLIB)))
33 LIB_LIB = $(topsrcdir)/$(builddir)/$(MKLIB)
40 .PHONY : all install clean clean-intermediate
44 ifneq (,$(strip $(TARGETS)))
45 # usually install $(LIB_LIB) or $(OBJS), race condition in "[ -d x ] || mkdir x"
46 install : recurse $(OBJS) $(LIB_LIB)
47 @[ -d "$(topsrcdir)/$(installdir)" ] || ( $(MKDIR) "$(topsrcdir)/$(installdir)" || true );
48 @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))";
49 $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)"
51 # used in subdirs like libc/ctype whose files
52 # are contained in a parent's library
53 install : recurse $(OBJS) $(LIB_LIB)
57 @-echo "dummy" > .dummy
58 $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
59 @-echo "dummy" > .dummy
60 $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
61 $(Q)-[ ! -d "$(topsrcdir)/$(builddir)" ] || $(RMDIR) "$(topsrcdir)/$(builddir)"
63 clean-intermediate : recurse
64 @-echo "dummy" > .dummy
65 $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
67 include $(topsrcdir)/Makefile.rules