- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Makefile , Variable
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 04:30 AM
тАО12-01-2008 04:30 AM
i have a question about Makefile:
i have to change a Makefile, is it possible to store a value in a Makefile ? in my example it doesn't work.
first i want to store the value 2.
second, i want to get the return value of an command from the remote-host, in my example the file can't be created.
Makefile example:
RET = 0
all:
@RET=2
@echo "RET: $(RET)"
@RET=`remsh otherhost -n "touch /tmpxx/test 2>/dev/null >/dev/null;echo " '$$?'`
@echo "RET: $(RET)"
Solved! Go to Solution.
- Tags:
- make
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 05:14 AM
тАО12-01-2008 05:14 AM
SolutionFirst, the shell variable '$$' isn't the return code, it's the PID of the current process. For a return code, you want '$?'
Yes, you can store variables and their values in a makefile.
Shell commands are also allowed but have rules too.
The 'make' manpages should be helpful; consult them!
From the snippet you posted, the logic would appear to be more suitable for a *shell* script and not a makefile.
Regards!
...JRF...
Sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 10:54 AM
тАО12-01-2008 10:54 AM
Re: Makefile , Variable
there are multiple errors at a time, you managed to put in such a small Makefile.
Sorry, but you better read something about Makefiles first - even a 'man make' will lead you further.
I comment only some if them ...
1 RET = 0
2
3 all:
4 @RET=2
5 @echo "RET: $(RET)"
6 @RET=`remsh otherhost -n "touch /tmpxx/test 2>/dev/null >/dev/null;echo "'$$?'`
7 @echo "RET: $(RET)"
You define a makro RET in line1.
In line 4-7 you use four distinct lines as a makerule for target 'all'. Distinct means here, that these are independent shell processes and no following line will know anything about the previous one. Your assignment to the shell variable RET in line 4 is a no-op therefore and has - N.B. - nothing to do with your makro definition in line 1.
Your line5 will use the makro of line1 and lead to an output
RET: 0
It will NOT use the assignment to the shell variable in line4, even when changing this line to
5 @echo "RET: $$RET"
as already mentioned.
The same mistake is done in lines 6 and 7:
Assigning a shell variable in a different process and querying a make makro. Line7 will always produce
RET: 0
Your line6 itself will set/show the return value of the remote command - but only if you really can reach 'otherhost' and get a passwordless login.
Try something like this:
1 all:
2 @RET=`remsh otherhost -n "touch /tmpxx/test 2>/dev/null >/dev/null;echo "'$$?'`; \
3 echo RET=$$RET
OK - it's your turn!
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 02:50 PM
тАО12-01-2008 02:50 PM
Re: Makefile , Variable
If you want to change it you must use a shell variable and one big long command that Peter mentions.
>JRF: the shell variable '$$' isn't the return code,
In makefiles, you must use $$ for shell variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2008 11:57 PM
тАО12-01-2008 11:57 PM
Re: Makefile , Variable
Thank you for your useful information. i made in the meantime some tests and with your informations i unterstand Makefiles better and integrate in my work.
kind regards,tom