On Wed, Apr 28, 2010 at 8:29 PM, <[email protected]> wrote:

>
> severip := $(shell /sbin/ifconfig)
>
> all:
>    @echo $(serverip)
>

First, check the spelling of "seRverip" very closely.

Secondly, the problem is happening because the ifconfig output contains
special shell characters, which are being expanded inside the "all" recipe
before the shell gets to execute the code. The shell then sees those chars
and chokes.

step...@jareth:~/tmp$ cat Makefile
serverip := $(shell /sbin/ifconfig)
all:
echo $(serverip)
step...@jareth:~/tmp$ make
echo eth0      Link encap:Ethernet  HWaddr 00:1d:92:60:ea:e9             UP
BROADCAST MULTICAST  MTU:1500  Metric:1           RX packets:0 errors:0
dropped:0 overruns:0 frame:0           TX packets:0 errors:0 dropped:0
overruns:0 carrier:0           collisions:0 txqueuelen:1000            RX
bytes:0 (0.0 B)  TX bytes:0 (0.0 B)           Interrupt:28 Base
address:0x6000   lo        Link encap:Local Loopback             inet
addr:127.0.0.1  Mask:255.0.0.0           inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:16436  Metric:1           RX packets:16769
errors:0 dropped:0 overruns:0 frame:0           TX packets:16769 errors:0
dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0
 RX bytes:8936678 (8.9 MB)  TX bytes:8936678 (8.9 MB)  wlan3     Link
encap:Ethernet  HWaddr 00:18:e7:34:6c:5a             inet addr:192.168.0.136
 Bcast:192.168.0.255  Mask:255.255.255.0           inet6 addr:
fe80::218:e7ff:fe34:6c5a/64 Scope:Link           UP BROADCAST RUNNING
MULTICAST  MTU:1500  Metric:1           RX packets:160193 errors:0 dropped:0
overruns:0 frame:0           TX packets:95979 errors:0 dropped:0 overruns:0
carrier:0           collisions:0 txqueuelen:1000            RX
bytes:220564696 (220.5 MB)  TX bytes:9354390 (9.3 MB)           Interrupt:17
Memory:f9fffc00-f9fffc25
/bin/sh: Syntax error: "(" unexpected

Be aware that the output of ifconfig is very platform-dependent, and parsing
of it tends to break when the script/makefile is tried on another platform.

You might be better of using "ping -c1 $(hostname)" or "nslookup
$(hostname)" and parsing their output (which is formatted more simply).

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to