From c3ef95592254689e5f87e940970f0f41993777cc Mon Sep 17 00:00:00 2001 From: tecodev Date: Sat, 13 Aug 2005 13:06:16 +0000 Subject: [PATCH] * device/lib/Makefile.in (port-specific-objects-pic16): revert to cp $(PORT)/bin/*.* $(PORTDIR) * device/lib/pic16/Makefile: added .PHONY targets, removed builddir dependency * device/lib/pic16/Makefile.rules: build subdirs before creating the library, removed builddir rule, create $(builddir) early in recurse rule, use empty recurse rule for leaf directories * device/lib/pic16/Makefile.subdir: added phony targets, ignore mkdir errors (race condition), removed duplicate suffix "hex" from clean rules * device/lib/pic16/libdev/Makefile: recursive make via + and $(MAKE) * device/lib/pic16/libio/Makefile: create sub-make's builddir early, prevents mkdir -p from aborting on Alpha git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3841 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 16 ++++++++++++++++ device/lib/Makefile.in | 2 +- device/lib/pic16/Makefile | 6 ++++-- device/lib/pic16/Makefile.rules | 20 ++++++++++++-------- device/lib/pic16/Makefile.subdir | 14 ++++++++------ device/lib/pic16/libdev/Makefile | 4 ++-- device/lib/pic16/libio/Makefile | 12 +++++++++--- 7 files changed, 52 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bcd73e2..daa90501 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-08-13 Raphael Neider + + * device/lib/Makefile.in (port-specific-objects-pic16): + revert to cp $(PORT)/bin/*.* $(PORTDIR) + * device/lib/pic16/Makefile: added .PHONY targets, removed builddir + dependency + * device/lib/pic16/Makefile.rules: build subdirs before creating + the library, removed builddir rule, create $(builddir) early in + recurse rule, use empty recurse rule for leaf directories + * device/lib/pic16/Makefile.subdir: added phony targets, ignore + mkdir errors (race condition), removed duplicate suffix "hex" + from clean rules + * device/lib/pic16/libdev/Makefile: recursive make via + and $(MAKE) + * device/lib/pic16/libio/Makefile: create sub-make's builddir early, + prevents mkdir -p from aborting on Alpha + 2005-08-12 Raphael Neider * src/pic16/glue.c (pic16_print(G)PointerType): do not flush diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index f88dbf83..7465987a 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -258,7 +258,7 @@ port-specific-objects-pic16: -if [ -d $(PORT) ]; then \ mkdir -p $(PORT)/bin; \ $(MAKE) -C $(PORT); \ - cp -f $(PORT)/bin/*.o $(PORT)/bin/*.lib $(PORTDIR); \ + cp -f $(PORT)/bin/*.* $(PORTDIR); \ fi lib-files: diff --git a/device/lib/pic16/Makefile b/device/lib/pic16/Makefile index a28c9f7c..002ef2a6 100644 --- a/device/lib/pic16/Makefile +++ b/device/lib/pic16/Makefile @@ -22,6 +22,8 @@ include $(topsrcdir)/Makefile.common ifeq (:,$(findstring :,$(LD) $(AS) $(LIB))) +.PHONY : all + all % : @echo "gputils not found -- PIC16 library not built!" @@ -36,11 +38,11 @@ C_SRC = $(wildcard *.c) S_SRC = $(wildcard *.S) OBJS = $(C_SRC:.c=.o) $(S_SRC:.S=.o) -.PHONY : all clean clean-intermediate recurse +.PHONY : all clean clean-intermediate install all : install -install : builddir recurse +install : recurse clean : recurse $(Q)-$(RMDIR) "$(topsrcdir)/$(builddir)"; diff --git a/device/lib/pic16/Makefile.rules b/device/lib/pic16/Makefile.rules index e36ebe6b..42aaef90 100644 --- a/device/lib/pic16/Makefile.rules +++ b/device/lib/pic16/Makefile.rules @@ -37,22 +37,26 @@ ifneq (,$(strip $(LIB_O))) @echo "[ LIB ] $(patsubst $(topsrcdir)/%,%,$@) <== $(patsubst $(topsrcdir)/$(builddir)/%,%,$^)"; $(Q)$(RM) "$@"; $(LIB) $(LIBFLAGS) "$@" $^; else -%.lib : force +%.lib : recurse @echo "[ LIB ] $(patsubst $(topsrcdir)/%,%,$@) <== **/*.o"; $(Q)$(RM) "$@"; LIB_O=`find "$(topsrcdir)/$(builddir)" -name "*.o"`; [ "x$${LIB_O}" = "x" ] || $(LIB) $(LIBFLAGS) "$@" $${LIB_O}; endif -.PHONY : builddir recurse force - -# create builddir -builddir : force - $(Q)[ -d "$(topsrcdir)/$(builddir)" ] || $(MKDIR) "$(topsrcdir)/$(builddir)"; +.PHONY : recurse force # build sub-directories +ifneq (,$(strip $(SUBDIRS))) recurse : force - $(Q)for DIR in $(SUBDIRS) . ; do \ - [ "$${DIR}" = "." ] || $(GREP) "^$${ARCH}$$" "$${DIR}.ignore" &> /dev/null || $(MAKE) -C "$${DIR}" builddir="$(builddir)/$${DIR}" $(MAKECMDGOALS) || exit 1; \ + $(Q)+for DIR in $(SUBDIRS) ; do \ + $(GREP) "^$${ARCH}$$" "$${DIR}.ignore" &> /dev/null || ( \ + [ -d "$(topsrcdir)/$(builddir)/$${DIR}" ] || $(MKDIR) "$(topsrcdir)/$(builddir)/$${DIR}"; \ + $(MAKE) -C "$${DIR}" builddir="$(builddir)/$${DIR}" $(MAKECMDGOALS); \ + ) || exit 1; \ done +else +recurse : + @# nothing to do +endif # target to force remaking of (seemingly) independent targets force : diff --git a/device/lib/pic16/Makefile.subdir b/device/lib/pic16/Makefile.subdir index 1e97bab1..3ee509cd 100644 --- a/device/lib/pic16/Makefile.subdir +++ b/device/lib/pic16/Makefile.subdir @@ -37,29 +37,31 @@ LIB_LIB = #TARGETS ?= $(OBJS) endif +.PHONY : all install clean clean-intermediate + all : install ifneq (,$(strip $(TARGETS))) -# usually install $(LIB_LIB) or $(OBJS) -install : builddir recurse $(OBJS) $(LIB_LIB) - @[ -d "$(topsrcdir)/$(installdir)" ] || $(MKDIR) "$(topsrcdir)/$(installdir)"; +# 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)" else # used in subdirs like libc/ctype whose files # are contained in a parent's library -install : builddir recurse $(OBJS) $(LIB_LIB) +install : recurse $(OBJS) $(LIB_LIB) endif clean : recurse @-echo "dummy" > .dummy - $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym hex,$(OBJS:.o=.$(suf))) + $(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)" clean-intermediate : recurse @-echo "dummy" > .dummy - $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym hex,$(OBJS:.o=.$(suf))) + $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym,$(OBJS:.o=.$(suf))) include $(topsrcdir)/Makefile.rules diff --git a/device/lib/pic16/libdev/Makefile b/device/lib/pic16/libdev/Makefile index 804ed151..c56128b5 100644 --- a/device/lib/pic16/libdev/Makefile +++ b/device/lib/pic16/libdev/Makefile @@ -27,9 +27,9 @@ TARGETS = $(OBJS:.o=.lib) # [...]/devicelibs would be the default target) suball : all -.PHONY : $(topsrcdir)/$(builddir)/device_libs +.PHONY : $(topsrcdir)/$(builddir)/device_libs suball $(topsrcdir)/$(builddir)/device_libs : - $(Q)$(foreach dev,$(C_FILES:.c=),make $(topsrcdir)/$(builddir)/$(dev).lib LIB_O=$(topsrcdir)/$(builddir)/$(dev).o;) + $(Q)+$(foreach dev,$(C_FILES:.c=),$(MAKE) $(topsrcdir)/$(builddir)/$(dev).lib LIB_O=$(topsrcdir)/$(builddir)/$(dev).o;) include $(topsrcdir)/Makefile.subdir diff --git a/device/lib/pic16/libio/Makefile b/device/lib/pic16/libio/Makefile index 3c999bc4..ba199bae 100644 --- a/device/lib/pic16/libio/Makefile +++ b/device/lib/pic16/libio/Makefile @@ -23,13 +23,19 @@ SUBDIRS = adc i2c usart ifeq ($(origin IO_ARCH),undefined) include $(topsrcdir)/Makefile.common -all clean clean-intermediate install : builddir - $(Q)cat $(topsrcdir)/pics.build \ +.PHONY : all clean clean-intermediate install + +# I create $(builddir)/$${arch} right here in order to prevent +# the sub-make's `builddir´ rules from aborting if another sub-make +# already created the above directory (happened on Alpha). +all clean clean-intermediate install : + $(Q)+cat $(topsrcdir)/pics.build \ | $(SED) -e "s,[ \t]*#.*$$,," \ | $(GREP) -v "^[ \t]*$$" \ | while read arch; do \ [ "x$${arch}" = "x" ] \ - || MKLIB=libio18f$${arch}.lib $(MAKE) builddir=$(builddir)/$${arch} ARCH=$${arch} IO_ARCH=$${arch} $(MAKECMDGOALS) \ + || ( [ -d "$(builddir)/$${arch}" ] || $(MKDIR) "$(builddir)/$${arch}"; \ + $(MAKE) MKLIB=libio18f$${arch}.lib builddir=$(builddir)/$${arch} ARCH=$${arch} IO_ARCH=$${arch} $(MAKECMDGOALS); ) \ || exit 1; \ done -- 2.47.2