Merge remote-tracking branch 'origin/master' into windeps
This commit is contained in:
commit
f6718fb050
@ -11297,4 +11297,6 @@
|
||||
used with the Cygwin make (2016-01-09).
|
||||
* tools/mkwindeps.sh: A script that coordinates us ov cnvwindeps.exe
|
||||
(2016-01-09).
|
||||
|
||||
* tools/mkdeps.c: Deleted mkdeps.sh and mkdeps.bat. The mkdeps
|
||||
executable generated from mkdeps.c is now that the only supported
|
||||
way to make dependencies (2016-01-09).
|
||||
|
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit 95a83af6d1ee3d2ecd2cd6a3c3bb4a99c4c06d7a
|
||||
Subproject commit 1a314699cf004cd85dae0038b566bab3343d294f
|
@ -381,7 +381,7 @@ static inline void enc_configspi(FAR struct spi_dev_s *spi)
|
||||
|
||||
SPI_SETMODE(spi, CONFIG_ENC28J60_SPIMODE);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ENC28J60_FREQUENCY)
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ENC28J60_FREQUENCY);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -198,6 +198,25 @@ int dns_setserver(FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
|
||||
int dns_getserver(FAR struct sockaddr *addr, FAR socklen_t *addrlen);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dns_getaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the DNS server IPv4 address
|
||||
*
|
||||
* Parameters:
|
||||
* ipaddr The location to return the IPv4 address
|
||||
*
|
||||
* Return:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
int dns_getaddr(FAR struct in_addr *inaddr);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ endif
|
||||
# Add DNS lookup support
|
||||
|
||||
ifeq ($(CONFIG_NETDB_DNSCLIENT),y)
|
||||
CSRCS += lib_dnsclient.c
|
||||
CSRCS += lib_dnsclient.c lib_getdnsaddr.c
|
||||
endif
|
||||
|
||||
# Add the net directory to the build
|
||||
|
@ -57,11 +57,11 @@
|
||||
/* DNS client configuration **************************************************/
|
||||
|
||||
#ifndef CONFIG_NETDB_DNSCLIENT_ENTRIES
|
||||
# define RESOLV_ENTRIES 4
|
||||
#else
|
||||
# define RESOLV_ENTRIES CONFIG_NETDB_DNSCLIENT_ENTRIES
|
||||
# define CONFIG_NETDB_DNSCLIENT_ENTRIES 4
|
||||
#endif
|
||||
|
||||
#define RESOLV_ENTRIES CONFIG_NETDB_DNSCLIENT_ENTRIES
|
||||
|
||||
#ifndef CONFIG_NETDB_DNSCLIENT_MAXRESPONSE
|
||||
# define CONFIG_NETDB_DNSCLIENT_MAXRESPONSE 96
|
||||
#endif
|
||||
|
98
libc/netdb/lib_getdnsaddr.c
Normal file
98
libc/netdb/lib_getdnsaddr.c
Normal file
@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
* libc/netdb/lib_dnsgetaddr.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <nuttx/net/dns.h>
|
||||
|
||||
#include <apps/netutils/netlib.h>
|
||||
|
||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NETDB_DNSCLIENT)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dns_getaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the DNS server IPv4 address
|
||||
*
|
||||
* Parameters:
|
||||
* ipaddr The location to return the IPv4 address
|
||||
*
|
||||
* Return:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int dns_getaddr(FAR struct in_addr *inaddr)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
socklen_t addrlen;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (inaddr)
|
||||
{
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
ret = dns_getserver((FAR struct sockaddr *)&addr, &addrlen);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Sanity check */
|
||||
|
||||
DEBUGASSERT(addr.sin_family == AF_INET &&
|
||||
addrlen == sizeof(struct sockaddr_in));
|
||||
memcpy(inaddr, &addr.sin_addr, sizeof(struct in_addr));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IPv4 && CONFIG_NETDB_DNSCLIENT */
|
@ -47,8 +47,10 @@
|
||||
#include <netinet/ether.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/dns.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "utils/utils.h"
|
||||
#include "procfs/procfs.h"
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
|
||||
@ -246,7 +248,7 @@ static int netprocfs_ipaddresses(FAR struct netprocfs_file_s *netfile)
|
||||
"Mask:%s\n", inet_ntoa(addr));
|
||||
|
||||
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
|
||||
netlib_get_ipv4dnsaddr(&addr);
|
||||
dns_getaddr(&addr);
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"\tDNSaddr:%s\n", inet_ntoa(addr));
|
||||
#endif
|
||||
@ -255,7 +257,7 @@ static int netprocfs_ipaddresses(FAR struct netprocfs_file_s *netfile)
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
/* Convert the 128 network mask to a human friendly prefix length */
|
||||
|
||||
preflen = netlib_ipv6netmask2prefix(dev->d_ipv6netmask);
|
||||
preflen = net_ipv6_mask2pref(dev->d_ipv6netmask);
|
||||
|
||||
/* Show the assigned IPv6 address */
|
||||
|
||||
|
@ -41,7 +41,7 @@ NET_CSRCS += net_chksum.c
|
||||
# IPv6 utilities
|
||||
|
||||
ifeq ($(CONFIG_NET_IPv6),y)
|
||||
NET_CSRCS += net_ipv6_maskcmp.c net_ipv6_pref2mask.c
|
||||
NET_CSRCS += net_ipv6_maskcmp.c net_ipv6_mask2pref.c net_ipv6_pref2mask.c
|
||||
endif
|
||||
|
||||
# Non-interrupt level support required?
|
||||
|
188
net/utils/net_ipv6_mask2pref.c
Normal file
188
net/utils/net_ipv6_mask2pref.c
Normal file
@ -0,0 +1,188 @@
|
||||
/****************************************************************************
|
||||
* net/utils/net_ipv6_mask2pref.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const uint8_t g_nibblemap[16] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0: No bits, 1-7: Should not happen */
|
||||
1, 1, 1, 1, /* 8: 1 bit, 9-b: Should not happen */
|
||||
2, 2, 3, 4 /* c: 2 bits, d: Should not happen, e: 3 bits, f: 4 bits */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_msbits4
|
||||
*
|
||||
* Description:
|
||||
* Count the number of leading '1' bits in an 4-bit nibble
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint8_t net_msbits4(uint8_t nibble)
|
||||
{
|
||||
/* Return the number of leading zeroes: 0-4) */
|
||||
|
||||
return g_nibblemap[nibble];
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_msbits8
|
||||
*
|
||||
* Description:
|
||||
* Count the number of leading '1' bits in an 8-bit byte
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t net_msbits8(uint8_t byval)
|
||||
{
|
||||
uint8_t ones;
|
||||
|
||||
/* Check the MS nibble */
|
||||
|
||||
ones = net_msbits4(byval >> 4);
|
||||
if (ones == 4)
|
||||
{
|
||||
/* All ones, try the LS nibble */
|
||||
|
||||
ones += net_msbits4(byval & 0x0f);
|
||||
}
|
||||
|
||||
/* Return the number of leading ones (0-8) */
|
||||
|
||||
return ones;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_msbits16
|
||||
*
|
||||
* Description:
|
||||
* Count the number of leading '1' bits in a 16-bit half-workd
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline uint8_t net_msbits16(uint16_t hword)
|
||||
{
|
||||
uint8_t ones;
|
||||
|
||||
/* Look at the MS byte of the 16-bit value */
|
||||
|
||||
ones = net_msbits8((uint8_t)(hword >> 8));
|
||||
if (ones == 8)
|
||||
{
|
||||
/* All '1's, try the LS byte */
|
||||
|
||||
ones += net_msbits8((uint8_t)(hword & 0xff));
|
||||
}
|
||||
|
||||
/* Return the number of leading ones (0-15) */
|
||||
|
||||
return ones;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_ipv6_mask2pref
|
||||
*
|
||||
* Description:
|
||||
* Convert a 128-bit netmask to a prefix length. The Nuttx IPv6
|
||||
* networking uses 128-bit network masks internally. This function
|
||||
* converts the IPv6 netmask to a prefix length.
|
||||
*
|
||||
* The prefix length is the number of MS '1' bits on in the netmask.
|
||||
* This, of course, assumes that all MS bits are '1' and all LS bits are
|
||||
* '0' with no intermixed 1's and 0's. This function searches from the MS
|
||||
* bit until the first '0' is found (this does not necessary mean that
|
||||
* there might not be additional '1' bits following the firs '0', but that
|
||||
* will be a malformed netmask.
|
||||
*
|
||||
* Parameters:
|
||||
* mask Points to an IPv6 netmask in the form of uint16_t[8]
|
||||
*
|
||||
* Return:
|
||||
* The prefix length, range 0-128 on success; This function will not
|
||||
* fail.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t net_ipv6_mask2pref(FAR const uint16_t *mask)
|
||||
{
|
||||
uint8_t preflen;
|
||||
int i;
|
||||
|
||||
/* Count the leading all '1' 16-bit groups */
|
||||
|
||||
for (i = 0, preflen = 0; i < 8 && mask[i] == 0xffff; i++, preflen += 16);
|
||||
|
||||
/* Now i either, (1) indexes past the end of the mask, or (2) is the index
|
||||
* to the first half-word that is not equal to 0xffff.
|
||||
*/
|
||||
|
||||
if (i < 8)
|
||||
{
|
||||
preflen += net_msbits16(ntohs(mask[i]));
|
||||
}
|
||||
|
||||
/* Return the prefix length */
|
||||
|
||||
return preflen;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IPv6 */
|
@ -151,6 +151,34 @@ unsigned int net_dsec2tick(int dsec);
|
||||
unsigned int net_timeval2dsec(FAR struct timeval *tv,
|
||||
enum tv2ds_remainder_e remainder);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_ipv6_mask2pref
|
||||
*
|
||||
* Description:
|
||||
* Convert a 128-bit netmask to a prefix length. The Nuttx IPv6
|
||||
* networking uses 128-bit network masks internally. This function
|
||||
* converts the IPv6 netmask to a prefix length.
|
||||
*
|
||||
* The prefix length is the number of MS '1' bits on in the netmask.
|
||||
* This, of course, assumes that all MS bits are '1' and all LS bits are
|
||||
* '0' with no intermixed 1's and 0's. This function searches from the MS
|
||||
* bit until the first '0' is found (this does not necessary mean that
|
||||
* there might not be additional '1' bits following the firs '0', but that
|
||||
* will be a malformed netmask.
|
||||
*
|
||||
* Parameters:
|
||||
* mask Points to an IPv6 netmask in the form of uint16_t[8]
|
||||
*
|
||||
* Return:
|
||||
* The prefix length, range 0-128 on success; This function will not
|
||||
* fail.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
uint8_t net_ipv6_mask2pref(FAR const uint16_t *mask);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: net_ipv6_pref2mask
|
||||
*
|
||||
|
@ -393,8 +393,6 @@ mkromfsimg.sh
|
||||
image. It accepts an rcS script "template" and generates and image that
|
||||
may be mounted under /etc in the NuttX pseudo file system.
|
||||
|
||||
mkdeps.sh
|
||||
mkdeps.bat
|
||||
mkdeps.c
|
||||
cnvwindeps.c
|
||||
mkwindeps.sh
|
||||
@ -402,11 +400,10 @@ mknulldeps.sh
|
||||
-------------
|
||||
|
||||
NuttX uses the GCC compilers capabilities to create Makefile dependencies.
|
||||
The bash script mkdeps.sh is used to run GCC in order to create the
|
||||
dependencies. If a NuttX configuration uses the GCC toolchain, its Make.defs
|
||||
file (see configs/README.txt) will include a line like:
|
||||
The program mkdeps is used to run GCC in order to create the dependencies.
|
||||
If a NuttX configuration uses the GCC toolchain, its Make.defs file (see
|
||||
configs/README.txt) will include a line like:
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh, or
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps[.exe] (See NOTE below)
|
||||
|
||||
If the NuttX configuration does not use a GCC compatible toolchain, then
|
||||
@ -416,13 +413,6 @@ mknulldeps.sh
|
||||
|
||||
The mknulldeps.sh is a stub script that does essentially nothing.
|
||||
|
||||
NOTE: The mk*deps.* files are undergoing change. mkdeps.sh is a bash
|
||||
script that produces dependencies well for POSIX style hosts (e..g.,
|
||||
Linux and Cygwin). It does not work well for mixed environments with
|
||||
a Windows toolchain running in a POSIX style environment (hence, the
|
||||
mkwindeps.sh script). And, of course, cannot be used in a Windows
|
||||
native environment.
|
||||
|
||||
mkwindeps.sh is a version that creates dependencies using the Windows
|
||||
native toolchain. That generates Windows native paths in the dependency
|
||||
file. But the mkwindeps.sh uses cnvwindeps.c to convert the Windows
|
||||
@ -430,16 +420,6 @@ mknulldeps.sh
|
||||
generation but is generally th best option available for that mixed
|
||||
environment of Cygwin with a native Windows GCC toolchain.
|
||||
|
||||
[mkdeps.sh does have an option, --winpath, that purports to convert
|
||||
the dependencies generated by a Windows toolchain to POSIX format.
|
||||
However, that is not being used and mostly likely does not cover
|
||||
all of the conversion cases.]
|
||||
|
||||
mkdeps.bat is a simple port of the bash script to run in a Windows
|
||||
command shell. However, it does not work well either because some
|
||||
of the common CFLAGS use characters like '=' which are transformed
|
||||
by the CMD.exe shell.
|
||||
|
||||
mkdeps.c generates mkdeps (on Linux) or mkdeps.exe (on Windows).
|
||||
However, this verison is still under-development. It works well in
|
||||
the all POSIX environment or in the all Windows environment but also
|
||||
|
200
tools/mkdeps.bat
200
tools/mkdeps.bat
@ -1,200 +0,0 @@
|
||||
@echo off
|
||||
|
||||
rem tools/mkdeps.sh
|
||||
rem
|
||||
rem Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
rem Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
rem
|
||||
rem Redistribution and use in source and binary forms, with or without
|
||||
rem modification, are permitted provided that the following conditions
|
||||
rem are met:
|
||||
rem
|
||||
rem 1. Redistributions of source code must retain the above copyright
|
||||
rem notice, this list of conditions and the following disclaimer.
|
||||
rem 2. Redistributions in binary form must reproduce the above copyright
|
||||
rem notice, this list of conditions and the following disclaimer in
|
||||
rem the documentation and/or other materials provided with the
|
||||
rem distribution.
|
||||
rem 3. Neither the name NuttX nor the names of its contributors may be
|
||||
rem used to endorse or promote products derived from this software
|
||||
rem without specific prior written permission.
|
||||
rem
|
||||
rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
rem FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
rem COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
rem INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
rem BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
rem OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
rem AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
rem LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
rem ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
rem POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
rem Accumulate CFLAGS up to "--"
|
||||
|
||||
set cc=
|
||||
set cflags=
|
||||
set altpath=
|
||||
set files=
|
||||
set args=
|
||||
set objpath=
|
||||
set suffix=.o
|
||||
set debug=n
|
||||
|
||||
:Loop
|
||||
if "%1"=="" goto Continue
|
||||
|
||||
if "%1"=="--" (
|
||||
set cc=%cflags%
|
||||
set cflags=%args%
|
||||
set args=
|
||||
goto NextParm
|
||||
)
|
||||
|
||||
if "%1"=="--dep-path" (
|
||||
if "%args%"=="" (
|
||||
set altpath=%altpath% %2
|
||||
) else (
|
||||
set args=%args% %2
|
||||
)
|
||||
shift
|
||||
goto NextParm
|
||||
)
|
||||
|
||||
if "%1"=="--obj-path" (
|
||||
set objpath=%2
|
||||
shift
|
||||
goto NextParm
|
||||
)
|
||||
|
||||
if "%1"=="--obj-suffix" (
|
||||
set suffix=%2
|
||||
shift
|
||||
goto NextParm
|
||||
)
|
||||
|
||||
if "%1"=="--dep-debug" (
|
||||
rem @echo on
|
||||
set debug=y
|
||||
goto NextParm
|
||||
)
|
||||
|
||||
if "%1"=="--help" goto Usage
|
||||
|
||||
if "%args%"=="" (
|
||||
set args=%1
|
||||
) else (
|
||||
set args=%args% %1
|
||||
)
|
||||
|
||||
:NextParm
|
||||
shift
|
||||
goto Loop
|
||||
:Continue
|
||||
|
||||
set files=%args%
|
||||
|
||||
if "%debug%"=="y" (
|
||||
echo cc=%cc%
|
||||
echo cflags=%cflags%
|
||||
echo files=%files%
|
||||
echo altpath=%altpath%
|
||||
)
|
||||
|
||||
rem Now check if we have everything
|
||||
|
||||
if "%cc%"=="" (
|
||||
echo ERROR: No compiler specified
|
||||
goto Usage
|
||||
)
|
||||
|
||||
if "%files%"=="" (
|
||||
rem Don't report an error -- this happens normally in some configurations
|
||||
echo # No files specified for dependency generataion
|
||||
goto End
|
||||
)
|
||||
|
||||
rem Then get the dependencies for each file
|
||||
|
||||
if "%altpath%"=="" goto NoPaths
|
||||
for %%G in (%files%) do (
|
||||
set fullpath=
|
||||
set file=%%G
|
||||
call :Checkpaths
|
||||
if "%debug%"=="y" echo %file%: fullpath=%fullpath%
|
||||
if "%fullpath%"=="" goto :NoFile
|
||||
|
||||
mtarg=""
|
||||
if "%objpath%"=="" (
|
||||
set objname=%~n1
|
||||
set mtarg="-MT %objpath%\%objname%%suffix%
|
||||
)
|
||||
|
||||
if "%debug%"=="y" echo CMD: %cc% -M %cflags% %fullpath%
|
||||
%cc% -M %mtarg% %cflags% %fullpath% || goto DepFail
|
||||
)
|
||||
goto :End
|
||||
|
||||
:NoPaths
|
||||
for %%G in (%files%) do (
|
||||
set fullpath=
|
||||
set file=%%G
|
||||
call :CheckFile %%G
|
||||
)
|
||||
goto :End
|
||||
|
||||
:CheckFile
|
||||
if "%debug%"=="y" echo Checkfile: Checking %file%
|
||||
if not exist %file% goto :NoFile
|
||||
set fullpath=%file%
|
||||
if "%debug%"=="y" echo CMD: %cc% -M %cflags% %fullpath%
|
||||
%cc% -M %cflags% %fullpath% || goto DepFail
|
||||
goto :EOF
|
||||
|
||||
:CheckPaths
|
||||
for %%H in (%altpath%) do (
|
||||
set tmppath=%%H\%file%
|
||||
if "%debug%"=="y" echo Checkfile: Checking %tmppath%
|
||||
if exist %tmppath% (
|
||||
set fullpath=%tmppath%
|
||||
goto :EOF
|
||||
)
|
||||
)
|
||||
goto :EOF
|
||||
|
||||
:NoFile
|
||||
echo ERROR: No readable file at %file%
|
||||
goto Usage
|
||||
|
||||
:DepFail
|
||||
echo ERROR: Failed to created dependencies for %file%
|
||||
|
||||
:Usage
|
||||
echo Usage: mkdeps [OPTIONS] CC -- CFLAGS -- file [file [file...]]
|
||||
echo Where:
|
||||
echo CC
|
||||
echo A variable number of arguments that define how to execute the compiler
|
||||
echo CFLAGS
|
||||
echo The compiler compilation flags
|
||||
echo file
|
||||
echo One or more C files whose dependencies will be checked. Each file is expected
|
||||
echo to reside in the current directory unless --dep-path is provided on the command line
|
||||
echo And [OPTIONS] include:
|
||||
echo --dep-debug
|
||||
echo Enable script debug
|
||||
echo --dep-path ^<path^>
|
||||
echo Do not look in the current directory for the file. Instead, look in <path> to see
|
||||
echo if the file resides there. --dep-path may be used multiple times to specify
|
||||
echo multiple alternative location
|
||||
echo --obj-path ^<path^>
|
||||
echo The final objects will not reside in this path but, rather, at the path provided by
|
||||
echo ^<path^>. if provided multiple time, only the last --obj-path will be used.
|
||||
echo --obj-suffix ^<suffix^>
|
||||
echo If and object path is provided, then the extension will be assumed to be .o. This
|
||||
echo default suffix can be overrided with this command line option.
|
||||
echo --help
|
||||
echo Shows this message and exits
|
||||
|
||||
:End
|
218
tools/mkdeps.sh
218
tools/mkdeps.sh
@ -1,218 +0,0 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# tools/mkdeps.sh
|
||||
#
|
||||
# Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
#
|
||||
# Usage:
|
||||
|
||||
show_usage ()
|
||||
{
|
||||
echo ""
|
||||
echo "$progname [OPTIONS] CC -- CFLAGS -- file [file [file...]]"
|
||||
echo ""
|
||||
echo "Where:"
|
||||
echo " CC"
|
||||
echo " A variable number of arguments that define how to execute the compiler"
|
||||
echo " CFLAGS"
|
||||
echo " The compiler compilation flags"
|
||||
echo " file"
|
||||
echo " One or more C files whose dependencies will be checked. Each file is expected"
|
||||
echo " to reside in the current directory unless --dep-path is provided on the command line"
|
||||
echo ""
|
||||
echo "And [OPTIONS] include:"
|
||||
echo " --dep-debug"
|
||||
echo " Enable script debug"
|
||||
echo " --dep-path <path>"
|
||||
echo " Do not look in the current directory for the file. Instead, look in <path> to see"
|
||||
echo " if the file resides there. --dep-path may be used multiple times to specify"
|
||||
echo " multiple alternative location"
|
||||
echo " --obj-path <path>"
|
||||
echo " The final objects will not reside in this path but, rather, at the path provided by"
|
||||
echo " <path>. if provided multiple time, only the last --obj-path will be used."
|
||||
echo " --obj-suffix <suffix>"
|
||||
echo " If and object path is provided, then the extension will be assumed to be .o. This"
|
||||
echo " default suffix can be overrided with this command line option."
|
||||
echo " --winpaths <TOPDIR>"
|
||||
echo " CC generates dependency lists using Windows paths (e.g., C:\blablah\blabla). This"
|
||||
echo " switch instructs the script to use 'cygpath' to convert the Windows paths to Cygwin"
|
||||
echo " paths"
|
||||
echo " --help"
|
||||
echo " Shows this message and exits"
|
||||
exit 1
|
||||
}
|
||||
|
||||
dodep ()
|
||||
{
|
||||
unset fullpath
|
||||
if [ -z "$altpath" ]; then
|
||||
if [ -r $1 ]; then
|
||||
fullpath=$1
|
||||
else
|
||||
echo "# ERROR: No readable file at $1"
|
||||
show_usage
|
||||
fi
|
||||
else
|
||||
for path in $altpath; do
|
||||
tmppath=$path/$1
|
||||
if [ -r $tmppath ]; then
|
||||
fullpath=$tmppath
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ -z "$fullpath" ]; then
|
||||
echo "# ERROR: No readable file for $1 found at any location"
|
||||
show_usage
|
||||
fi
|
||||
fi
|
||||
|
||||
unset mtarg
|
||||
if [ ! -z "$objpath" ]; then
|
||||
srcname=`basename $1`
|
||||
objname="${srcname%.*}"
|
||||
mtarg="-MT ${objpath}/${objname}${suffix}"
|
||||
fi
|
||||
|
||||
$cc -M $mtarg $cflags $fullpath || \
|
||||
( echo "# ERROR: $cc -M $cflags $fullpath FAILED"; exit 4; )
|
||||
}
|
||||
|
||||
unset cc
|
||||
unset cflags
|
||||
unset files
|
||||
unset args
|
||||
unset altpath
|
||||
unset objpath
|
||||
suffix=.o
|
||||
winpaths=n
|
||||
unset topdir
|
||||
|
||||
# Accumulate CFLAGS up to "--"
|
||||
progname=$0
|
||||
while [ ! -z "$1" ]; do
|
||||
case $1 in
|
||||
-- )
|
||||
cc=$cflags
|
||||
cflags=$args
|
||||
args=
|
||||
;;
|
||||
--dep-debug )
|
||||
if [ -z "$args" ]; then
|
||||
set -x
|
||||
else
|
||||
args="$args $1"
|
||||
fi
|
||||
;;
|
||||
--dep-path )
|
||||
if [ -z "$args" ]; then
|
||||
shift
|
||||
altpath="$altpath $1"
|
||||
else
|
||||
args="$args $1"
|
||||
fi
|
||||
;;
|
||||
--obj-path )
|
||||
shift
|
||||
objpath="$1"
|
||||
;;
|
||||
--obj-suffix )
|
||||
shift
|
||||
suffix="$1"
|
||||
;;
|
||||
--winpaths )
|
||||
if [ -z "$args" ]; then
|
||||
shift
|
||||
winpaths=y
|
||||
topdir=$1
|
||||
else
|
||||
args="$args $1"
|
||||
fi
|
||||
;;
|
||||
--help )
|
||||
show_usage
|
||||
;;
|
||||
*)
|
||||
args="$args $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
files=$args
|
||||
|
||||
if [ -z "$cc" ]; then
|
||||
echo "ERROR: No compiler specified"
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$files" ]; then
|
||||
# Don't report an error -- this happens normally in some configurations
|
||||
echo "# No files specified for dependency generataion"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if this compiler generates Cygwin/Linux paths or Windows paths
|
||||
|
||||
if [ "X${winpaths}" = "Xy" ]; then
|
||||
# We will have to parse and modify each dependency (yech)
|
||||
# Make sure a valid TOPDIR argument was provided
|
||||
|
||||
if [ -z "$topdir" -o ! -d $topdir ]; then
|
||||
echo "<TOPDIR> not specified or does not exist: $topdir"
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the top dir expressed like the Windows GCC would use it, except
|
||||
# with forward slashs
|
||||
|
||||
wtopdir=`cygpath -w ${topdir} | sed -e "s,\\\\\\,/,g"`
|
||||
|
||||
# Then get the dependency and perform conversions on it to make it
|
||||
# palatable to the Cygwin make. This is probably not sufficiently
|
||||
# general to work on all platforms (like if your disk is not C:).
|
||||
|
||||
for file in $files ; do
|
||||
dodep $file | sed -e "s,\\\,/,g" -e "s,${wtopdir},${topdir},g" \
|
||||
-e "s,/ ,\\\ ,g" -e "s,c:/,/cygdrive/c/,g" \
|
||||
-e "s,/$,\\\,g"
|
||||
done
|
||||
else
|
||||
# For normal Cygwin/Linux GCC, the dependency paths are in the
|
||||
# correct form and can simply be echoed on stdout
|
||||
|
||||
for file in $files ; do
|
||||
dodep $file
|
||||
done
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user