X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2Fpic16%2FMakefile.subdir;h=eb4a8be9148383315c539d2d46db57aa5352c433;hb=f1007d04010ff2955d4d962c89616311ff4719d6;hp=c14aa67839f2630170866a1301e6e2fe6268c140;hpb=92777a99c7549821c8524386d6a8e5ad67db940b;p=fw%2Fsdcc diff --git a/device/lib/pic16/Makefile.subdir b/device/lib/pic16/Makefile.subdir index c14aa678..eb4a8be9 100644 --- a/device/lib/pic16/Makefile.subdir +++ b/device/lib/pic16/Makefile.subdir @@ -1,14 +1,14 @@ ########################################################### ### Makefile.subdir for the GNU PIC Library ### -### Copyright (C) 2005 by Raphael Neider +### Copyright (C) 2005 by Raphael Neider ### ### The GNU PIC Library was originally designed and ### implemented by ### Vangelis Rokas ### ### It is currently maintained by -### Raphael Neider +### Raphael Neider ### ### This file may be distributed under the terms of the the ### GNU General Public License (GPL). See COPYING for details. @@ -16,37 +16,48 @@ ### $Id$ ### -include $(topsrcdir)/Makefile.common +include $(top_builddir)/Makefile.common SUBDIRS ?= MKLIB ?= # fallback: if builddir is not specified via the command line... -builddir ?= build/$(patsubst $(shell cd $(topsrcdir); pwd)/%,%,$(CURDIR)) +builddir ?= build/$(patsubst $(shell cd $(top_builddir); pwd)/%,%,$(CURDIR)) -C_SRC ?= $(wildcard *.c) -S_SRC ?= $(wildcard *.S) -OBJS ?= $(addprefix $(topsrcdir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o)) +C_SRC ?= $(notdir $(wildcard $(srcdir)/*.c)) +S_SRC ?= $(notdir $(wildcard $(srcdir)/*.S)) +OBJS ?= $(addprefix $(top_builddir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o)) LIB_O ?= $(OBJS) ifneq (,$(strip $(MKLIB))) -LIB_LIB = $(topsrcdir)/$(builddir)/$(MKLIB) +LIB_LIB = $(top_builddir)/$(builddir)/$(MKLIB) TARGETS ?= $(LIB_LIB) else LIB_LIB = #TARGETS ?= $(OBJS) endif -.PHONY : all install clean clean-intermediate +.PHONY : all install clean clean-intermediate $(addprefix install,$(TARGETS)) + +ifndef SILENT +ECHO=echo +else +ECHO=true +endif all : install ifneq (,$(strip $(TARGETS))) + +$(addprefix install,$(TARGETS)): install% : % + @-if [ -e "$<" ]; then \ + [ -d "$(top_builddir)/$(installdir)" ] || $(MKDIR) "$(top_builddir)/$(installdir)"; \ + $(ECHO) "[INSTALL] $(patsubst $(top_builddir)/$(builddir)/%,%,$<)"; \ + [ ! -e "$<" ] || $(CP) "$<" "$(top_builddir)/$(installdir)"; \ + fi + # usually install $(LIB_LIB) or $(OBJS), race condition in "[ -d x ] || mkdir x" -install : recurse $(OBJS) $(LIB_LIB) - @[ -d "$(topsrcdir)/$(installdir)" ] || ( $(MKDIR) "$(topsrcdir)/$(installdir)" || true ); - @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))"; - $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)" +install : recurse $(OBJS) $(LIB_LIB) $(addprefix install,$(TARGETS)) else # used in subdirs like libc/ctype whose files # are contained in a parent's library @@ -58,10 +69,16 @@ clean : recurse $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf))) @-echo "dummy" > .dummy $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB) - $(Q)-[ ! -d "$(topsrcdir)/$(builddir)" ] || $(RMDIR) "$(topsrcdir)/$(builddir)" + @-echo "dummy" > .dummy + $(Q)-$(RM) .dummy $(TARGETS) + @-echo "dummy" > .dummy + $(Q)-$(RM) .dummy $(addprefix $(top_builddir)/$(installdir)/,$(notdir $(TARGETS))) + $(Q)-[ ! -d "$(top_builddir)/$(builddir)" ] || $(RMDIR) "$(top_builddir)/$(builddir)" + +distclean : clean clean-intermediate : recurse @-echo "dummy" > .dummy $(Q)-$(RM) .dummy $(foreach suf,p lst hex cod sym,$(OBJS:.o=.$(suf))) -include $(topsrcdir)/Makefile.rules +include $(top_srcdir)/Makefile.rules