Add logic for environments that can't use soft links
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@530 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
c691f1db9d
commit
3f1c7dc771
@ -303,4 +303,5 @@
|
||||
* 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
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: January 7, 2008</p>
|
||||
<p>Last Updated: January 8, 2008</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -27,39 +27,76 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#overview">Overview</a></td>
|
||||
<td>
|
||||
<a href="#overview">Overview</a>.<br>
|
||||
What is NuttX?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#downloads">Downloads</a></td>
|
||||
<td>
|
||||
<a href="#downloads">Downloads</a>.<br>
|
||||
Where can I get NuttX? What is the current development status?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#platforms">Supported Platforms</a></td>
|
||||
<td>
|
||||
<a href="#platforms">Supported Platforms</a>.<br>
|
||||
What target platforms has NuttX been ported to?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#footprint">Memory Footprint</a></td>
|
||||
<td>
|
||||
<a href="#environments">Development Environments</a>.<br>
|
||||
What kinds of host cross-development platforms can be used with NuttX?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#licensing">Licensing</a></td>
|
||||
<td>
|
||||
<a href="#footprint">Memory Footprint</a>.<br>
|
||||
Just how big is it? Do I have enough memory to use NuttX?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#history">Release History</a></td>
|
||||
<td>
|
||||
<a href="#licensing">Licensing</a>.<br>
|
||||
Are there any licensing restrictions for the use of NuttX? (Almost none)
|
||||
Will there be problems if I link my proprietary code with NuttX? (No)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#TODO">Bugs, Issues, <i>Things-To-Do</i></a></td>
|
||||
<td>
|
||||
<a href="#history">Release History</a><br>
|
||||
What has changed in the last release of NuttX?
|
||||
What unreleased changes are pending in CVS?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#documentation">Other Documentation</a></td>
|
||||
<td>
|
||||
<a href="#TODO">Bugs, Issues, <i>Things-To-Do</i></a>.<br>
|
||||
Software is never finished nor ever tested well enough.
|
||||
(Do you want to help devlop NuttX? If so, send me an email).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td><a href="#trademarks">Trademarks</a></td>
|
||||
<td>
|
||||
<a href="#documentation">Other Documentation</a>.<br>
|
||||
What other NuttX documentation is available?
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#trademarks">Trademarks</a>.<br>
|
||||
Some of the words used in this document belong to other people.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@ -643,6 +680,159 @@
|
||||
is available that may be used to build a NuttX-compatible arm-elf toolchain under
|
||||
Linux or Cygwin.</blockquote>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="environments"><h1>Development Environments</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<center><table width="90%">
|
||||
<tr>
|
||||
<td valign="top"><img src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>Linux + GNU make + GCC/binutils</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
The is the most natural development environment for NuttX.
|
||||
Any version of the GCC/binutils toolchain may be used.
|
||||
There is a highly modified <a href="http://buildroot.uclibc.org/">buildroot</a>
|
||||
available for download from the
|
||||
<a href="http://sourceforge.net/project/showfiles.php?group_id=189573">NuttX SourceForge</a>
|
||||
page.
|
||||
This download may be used to build a NuttX-compatible arm-elf toolchain under Linux or Cygwin.
|
||||
Additional support for m68k, m68hc11, and m68hc12 is available in the
|
||||
<a href="http://nuttx.cvs.sourceforge.net/nuttx/misc/buildroot/">NuttX CVS</a>.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><img src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>Linux + GNU make + SDCC</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
Also very usable is the Linux environment using the
|
||||
<a href="http://sdcc.sourceforge.net/">SDCC</a> compiler.
|
||||
The SDCC compiler provides support for the 8051/2, z80, hc08, and other microcontrollers.
|
||||
The SDCC-based logic is less well exercised and you will likely find some compilation
|
||||
issues if you use parts of NuttX with SDCC that have not been well-tested.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><img src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>Cygwin + GNU make + GCC/binutils</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
This combination works well too.
|
||||
It works just as well as the native Linux environment except
|
||||
that compilation and build times are a little longer.
|
||||
The custom NuttX buildroot referenced above may be build in
|
||||
the Cygwin environment as well.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><img src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>Cygwin + GNU make + SDCC</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
I have never tried this combination, but it would probably work just fine.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><img src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>Cygwin + GNU make + Windows Native Toolchain</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
This is a tougher environment.
|
||||
In this case, the Windows native toolchain is unaware of the the
|
||||
Cygwin <i>sandbox</i> and, instead, operates in the native Windows environment.
|
||||
The primary difficulties with this are:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Pathes</b>.
|
||||
Full pathes for the native toolchain must follow Windows standards.
|
||||
For example, the path <code>/home/my\ name/nuttx/include</code> my have to be
|
||||
converted to something like <code>'C:\cygwin\home\my name\nuttx\include'</code>
|
||||
to be usable by the toolchain.
|
||||
</li>
|
||||
<p>
|
||||
Fortunately, this conversion is done simply using the <code>cygpath</code> utility.
|
||||
</p>
|
||||
<li>
|
||||
<b>Symbolic Links</b>
|
||||
NuttX depends on symbolic links to install platform-specific directories in the build system.
|
||||
On Linux, true symbolic links are used.
|
||||
On Cygwin, emulated symbolic links are used.
|
||||
Unfortunately, for native Windows applications that operate outside of the
|
||||
Cygwin <i>sandbox</i>, these symbolic links cannot be used.
|
||||
</li>
|
||||
<p>
|
||||
The NuttX make system works around this limitation by copying the platform
|
||||
specific directories in place.
|
||||
These copied directories make work a little more complex, but otherwise work well.
|
||||
</p>
|
||||
</ul>
|
||||
<p>
|
||||
At present, on the Zilog Z16F port uses a native Windows toolchain
|
||||
(the Zilog ZDS-II toolchain).
|
||||
</p.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><img src="favicon.ico"></td>
|
||||
<td bgcolor="#5eaee1">
|
||||
<b>Others?</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
The primary environmental dependency of NuttX is GNU make.
|
||||
If you have other platforms that support GNU make or make
|
||||
utilities that are compatible with GNU make, then it is very
|
||||
likely that NuttX would work in that environment as well.
|
||||
If GNU make is not supported, then some significant modification
|
||||
of the Make system would be required.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table></center>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
@ -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
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
|
75
Makefile
75
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/<arch-name>/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/<board-name>/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/<board-name>/src dir to arch/<arch-name>/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/<arch-name>/include/<chip-name> to arch/<arch-name>/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/<arch-name>/src/<chip-name> to arch/<arch-name>/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 \
|
||||
|
@ -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
|
||||
|
84
tools/link.sh
Executable file
84
tools/link.sh
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
############################################################################
|
||||
# tools/link.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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 ; }
|
70
tools/unlink.sh
Executable file
70
tools/unlink.sh
Executable file
@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
############################################################################
|
||||
# tools/unlink.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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
|
97
tools/winlink.sh
Executable file
97
tools/winlink.sh
Executable file
@ -0,0 +1,97 @@
|
||||
#!/bin/sh
|
||||
############################################################################
|
||||
# tools/winlink.sh
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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 ; }
|
Loading…
Reference in New Issue
Block a user