@@ -790,6 +980,7 @@ Other memory:
* Add support toolchains that do not support making of dependencies
* Fix Cygwin build with spaces in directory names
* Name make system changes to deal with non-GNU toolchains (i.e., Zilog)
+ * Add support for Windows native toolchains that cannot follow Cygwin soft links
diff --git a/Makefile b/Makefile
index 7ee658c642e..4a7e17aba9c 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,13 @@ TOPDIR := ${shell pwd | sed -e 's/ /\\ /g'}
-include ${TOPDIR}/.config
-include ${TOPDIR}/Make.defs
+# Default tools
+
+ifeq ($(DIRLINK),)
+DIRLINK = $(TOPDIR)/tools/link.sh
+DIRUNLINK = $(TOPDIR)/tools/unlink.sh
+endif
+
# Process architecture and board-specific directories
ARCH_DIR = arch/$(CONFIG_ARCH)
@@ -121,79 +128,39 @@ include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig
# link the arch//include dir to include/arch
include/arch: Make.defs
- @if [ -h include/arch ]; then \
- rm -f include/arch ; \
- else \
- if [ -e include/arch ]; then \
- echo "include/arch exists but is not a symbolic link" ; \
- exit 1 ; \
- fi ; \
- fi
- @ln -s $(TOPDIR)/$(ARCH_DIR)/include include/arch
+ @$(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
# Link the configs//include dir to include/arch/board
-include/arch/board: Make.defs include/arch
- @if [ -h include/arch/board ]; then \
- rm -f include/arch/board ; \
- else \
- if [ -e include/arch/board ]; then \
- echo "include/arch/board exists but is not a symbolic link" ; \
- exit 1 ; \
- fi ; \
- fi
- @ln -s $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
+include/arch/board: include/arch Make.defs include/arch
+ @$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
# Link the configs//src dir to arch//src/board
$(ARCH_SRC)/board: Make.defs
- @if [ -h $(ARCH_SRC)/board ]; then \
- rm -f $(ARCH_SRC)/board ; \
- else \
- if [ -e $(ARCH_SRC)/board ]; then \
- echo "$(ARCH_SRC)/board exists but is not a symbolic link" ; \
- exit 1 ; \
- fi ; \
- fi
- @ln -s $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
+ @$(DIRLINK) $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
# Link arch//include/ to arch//include/chip
$(ARCH_SRC)/chip: Make.defs
ifneq ($(CONFIG_ARCH_CHIP),)
- @if [ -h $(ARCH_SRC)/chip ]; then \
- rm -f $(ARCH_SRC)/chip ; \
- else \
- if [ -e $(ARCH_SRC)/chip ]; then \
- echo "$(ARCH_SRC)/chip exists but is not a symbolic link" ; \
- exit 1 ; \
- fi ; \
- fi
- @ln -s $(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
+ @$(DIRLINK) $(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
endif
# Link arch//src/ to arch//src/chip
-$(ARCH_INC)/chip: Make.defs
+include/arch/chip: include/arch Make.defs
ifneq ($(CONFIG_ARCH_CHIP),)
- @if [ -e $(ARCH_INC)/chip ]; then \
- if [ -h $(ARCH_INC)/chip ]; then \
- rm -f $(ARCH_INC)/chip ; \
- else \
- echo "$(ARCH_INC)/chip exists but is not a symbolic link" ; \
- exit 1 ; \
- fi ; \
- fi
- @ln -s $(CONFIG_ARCH_CHIP) $(ARCH_INC)/chip
+ @$(DIRLINK) $(CONFIG_ARCH_CHIP) include/arch/chip
endif
-dirlinks: include/arch include/arch/board $(ARCH_SRC)/board $(ARCH_SRC)/chip $(ARCH_INC)/chip
+dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip
context: check_context include/nuttx/config.h dirlinks
clean_context:
- @rm -f include/nuttx/config.h include/arch
- @if [ -h include/arch ]; then rm -f include/arch ; fi
- @if [ -h $(ARCH_INC)/board ]; then rm -f $(ARCH_INC)/board ; fi
- @if [ -h $(ARCH_SRC)/board ]; then rm -f $(ARCH_SRC)/board ; fi
- @if [ -h $(ARCH_INC)/chip ]; then rm -f $(ARCH_INC)/chip ; fi
- @if [ -h $(ARCH_SRC)/chip ]; then rm -f $(ARCH_SRC)/chip ; fi
+ @rm -f include/nuttx/config.h
+ @$(DIRUNLINK) include/arch/board
+ @$(DIRUNLINK) include/arch/chip
+ @$(DIRUNLINK) include/arch
+ @$(DIRUNLINK) $(ARCH_SRC)/board
+ @$(DIRUNLINK) $(ARCH_SRC)/chip
check_context:
@if [ ! -e ${TOPDIR}/.config -o ! -e ${TOPDIR}/Make.defs ]; then \
diff --git a/configs/z16f2800100zcog/Make.defs b/configs/z16f2800100zcog/Make.defs
index e9f7342b77e..ee7a692cefd 100644
--- a/configs/z16f2800100zcog/Make.defs
+++ b/configs/z16f2800100zcog/Make.defs
@@ -129,6 +129,11 @@ endef
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
+# ZNeo-II cannot follow Cygwin soft links, so we will have to use directory copies
+
+DIRLINK = $(TOPDIR)/tools/winlink.sh
+DIRUNLINK = $(TOPDIR)/tools/unlink.sh
+
# Linux/Cygwin host tool definitions
HOSTCC = gcc
diff --git a/tools/link.sh b/tools/link.sh
new file mode 100755
index 00000000000..5c957629417
--- /dev/null
+++ b/tools/link.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+############################################################################
+# tools/link.sh
+#
+# Copyright (C) 2008 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+src=$1
+dest=$2
+
+# Verify that arguments were provided
+
+if [ -z "${src}" -o -z "${dest}" ]; then
+ echo "Missing src and/or dest arguments"
+ exit 1
+fi
+
+# Check if something already exists at the destination path
+
+if [ -e "${dest}" ]; then
+
+ # Yes, is it a symbolic link? If so, then remove it so that we can
+ # replace it with the new link (which might be different)
+
+ if [ -h "${dest}" ]; then
+ rm -f "${dest}"
+ else
+
+ # If the path is a directory and contains the "fake link" mark, then
+ # treat it like a soft link (i.e., remove the directory)
+
+ if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
+ rm -rf "${dest}"
+ else
+
+ # It is something else (like a file) or directory that does
+ # not contain the "fake link" mark
+
+ echo "${dest} already exists but is not a symbolic link"
+ exit 1
+ fi
+ fi
+fi
+
+# Verify that a directory exists at the source path
+
+if [ ! -d ${src} ]; then
+ echo "No directory at ${src}"
+ exit 1
+fi
+
+# Create the soft link
+
+ln -s "${src}" "${dest}" || \
+ { echo "Failed to create link: $dest" ; exit 1 ; }
\ No newline at end of file
diff --git a/tools/unlink.sh b/tools/unlink.sh
new file mode 100755
index 00000000000..ebd21d5129c
--- /dev/null
+++ b/tools/unlink.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+############################################################################
+# tools/unlink.sh
+#
+# Copyright (C) 2008 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+link=$1
+
+# Verify that arguments were provided
+
+if [ -z "${link}" ]; then
+ echo "Missing link argument"
+ exit 1
+fi
+
+# Check if something already exists at the link path
+
+if [ -e "${link}" ]; then
+
+ # Yes, is it a symbolic link? If so, then remove it
+
+ if [ -h "${link}" ]; then
+ rm -f "${link}"
+ else
+
+ # If the path is a directory and contains the "fake link" mark, then
+ # treat it like a soft link (i.e., remove the directory)
+
+ if [ -d "${link}" -a -f "${link}/.fakelnk" ]; then
+ rm -rf "${link}"
+ else
+
+ # It is something else (like a file) or directory that does
+ # not contain the "fake link" mark
+
+ echo "${link} already exists but is not a symbolic link"
+ exit 1
+ fi
+ fi
+fi
\ No newline at end of file
diff --git a/tools/winlink.sh b/tools/winlink.sh
new file mode 100755
index 00000000000..c98efa47d3d
--- /dev/null
+++ b/tools/winlink.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+############################################################################
+# tools/winlink.sh
+#
+# Copyright (C) 2008 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+#
+# NuttX uses symbolic links to configure platform-specific directories into
+# the build system. This works great except for when a Windows native
+# toolchain is used in a Cygwin environment. In that case, symbolic
+# links do not work correctly when accessed from the Windows native toolchain;
+# rather, just look link files with the extension .lnk
+#
+# In this environment, the build system will work around this using this script
+# as a replacement for the 'ln' command. This scrpt will simply copy the
+# directory into the expected positiion.
+#
+
+src=$1
+dest=$2
+
+# Verify that arguments were provided
+
+if [ -z "${src}" -o -z "${dest}" ]; then
+ echo "Missing src and/or dest arguments"
+ exit 1
+fi
+
+# Check if something already exists at the destination path
+
+if [ -e "${dest}" ]; then
+
+ # Yes, is it a symbolic link? If so, then remove it so that we can
+ # replace it with the new directory copy
+
+ if [ -h "${dest}" ]; then
+ rm -f "${dest}"
+ else
+
+ # If the path is a directory and contains the "fake link" mark, then
+ # remove the directory so that we can replace it with a new copy
+
+ if [ -d "${dest}" -a -f "${dest}/.fakelnk" ]; then
+ rm -rf "${dest}"
+ else
+
+ # It is something else (like a file) or directory that does
+ # not contain the "fake link" mark
+
+ echo "${dest} already exists but is not a symbolic link"
+ exit 1
+ fi
+ fi
+fi
+
+# Verify that a directory exists at the source path
+
+if [ ! -d ${src} ]; then
+ echo "No directory at ${src}"
+ exit 1
+fi
+
+# Copy the directory
+
+cp -a "${src}" "${dest}" || \
+ { echo "Failed to create link: $dest" ; rm -rf ${dest} ; exit 1 ; }
+touch "${dest}/.fakelnk" || \
+ { echo "Failed to touch ${dest}/.fakelnk" ; rm -rf ${dest} ; exit 1 ; }
\ No newline at end of file
|