1 ###########################################################
2 ### Makefile.subdir for the GNU PIC Library
4 ### Copyright (C) 2005 by Raphael Neider <rneider AT 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 AT 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 $(top_builddir)/Makefile.common
24 # fallback: if builddir is not specified via the command line...
25 builddir ?= build/$(patsubst $(shell cd $(top_builddir); pwd)/%,%,$(CURDIR))
27 C_SRC ?= $(notdir $(wildcard $(srcdir)/*.c))
28 S_SRC ?= $(notdir $(wildcard $(srcdir)/*.S))
29 OBJS ?= $(addprefix $(top_builddir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
32 ifneq (,$(strip $(MKLIB)))
33 LIB_LIB = $(top_builddir)/$(builddir)/$(MKLIB)
40 .PHONY : all install clean clean-intermediate $(addprefix install,$(TARGETS))
50 ifneq (,$(strip $(TARGETS)))
52 $(addprefix install,$(TARGETS)): install% : %
53 @-if [ -e "$<" ]; then \
54 [ -d "$(top_builddir)/$(installdir)" ] || $(MKDIR) "$(top_builddir)/$(installdir)"; \
55 $(ECHO) "[INSTALL] $(patsubst $(top_builddir)/$(builddir)/%,%,$<)"; \
56 [ ! -e "$<" ] || $(CP) "$<" "$(top_builddir)/$(installdir)"; \
59 # usually install $(LIB_LIB) or $(OBJS), race condition in "[ -d x ] || mkdir x"
60 install : recurse $(OBJS) $(LIB_LIB) $(addprefix install,$(TARGETS))
62 # used in subdirs like libc/ctype whose files
63 # are contained in a parent's library
64 install : recurse $(OBJS) $(LIB_LIB)
68 @-echo "dummy" > .dummy
69 $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf)))
70 @-echo "dummy" > .dummy
71 $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
72 @-echo "dummy" > .dummy
73 $(Q)-$(RM) .dummy $(TARGETS)
74 @-echo "dummy" > .dummy
75 $(Q)-$(RM) .dummy $(addprefix $(top_builddir)/$(installdir)/,$(notdir $(TARGETS)))
76 $(Q)-[ ! -d "$(top_builddir)/$(builddir)" ] || $(RMDIR) "$(top_builddir)/$(builddir)"
80 clean-intermediate : recurse
81 @-echo "dummy" > .dummy
82 $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf)))
84 include $(top_srcdir)/Makefile.rules