LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 12-03-2010, 01:30 AM   #1
daat99
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Rep: Reputation: 0
How can I convert makefile argument "toupper" (and "tolower")?


I have the following stripped down makefie:
Code:
.PHONY c
c:
	echo argument: $n()
I call it using:
Code:
make c n=something
I want to be able to convert the argument to upper case and to lower case.

I tried:
Code:
c:
	echo upper: $(n, UC), lower: $(n, LC)
But it didn't work.

Anyone have any idea how I can convert the argument into upper case string (and lower case too, I need them both)?

ps
The real makefile is much bigger, this is just the stripped down version for clarity.

Thanks in advance
 
Old 12-04-2010, 02:57 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,724

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
DO you have such programs on your system ('upper' and 'lower')?

This works here:

c:
@echo $(n)
@echo $(n) | tr 'a-z' 'A-Z'
@echo $(n) | tr 'A-Z' 'a-z'
 
Old 12-04-2010, 04:38 AM   #3
daat99
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by gnashley View Post
DO you have such programs on your system ('upper' and 'lower')?

This works here:

c:
@echo $(n)
@echo $(n) | tr 'a-z' 'A-Z'
@echo $(n) | tr 'A-Z' 'a-z'
No, I don't have such programs, that was meant to be text string.

As for the solution you suggested there are 2 things with it:

1. I need a single string in the same line that contains text string before and after the variable that I turn into capital letters (or small letters).
For example I want the output (hopefully it'll be more clear now) in a single line:
"This text is in upper case: $(variableInUpperCase), but this is in lower case: $(variableInLowerCase) everything in this quote is in a single line that ends here."

2. It should work from inside makefile in ubuntu-linux environment (I figured this is linux questions forums so I didn't mention it earlier, my bad).

Thank you for trying to help anyway
 
Old 12-04-2010, 10:25 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,724

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Is this homework? Do you know how to use 'echo' so it prints no end of line character?

A little fooling around gives this:
Code:
c:
	@echo input':'$(n)
	@echo -n upper':'
	@echo -n "$(n) " | tr 'a-z' 'A-Z'
	@echo -n lower':'
	@echo "$(n)" | tr 'A-Z' 'a-z'
bash-3.1$ make c n=somethiNG
input:somethiNG
upper:SOMETHING lower:something
 
1 members found this post helpful.
Old 12-04-2010, 10:49 AM   #5
daat99
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by gnashley View Post
Is this homework? Do you know how to use 'echo' so it prints no end of line character?

A little fooling around gives this:
Code:
c:
	@echo input':'$(n)
	@echo -n upper':'
	@echo -n "$(n) " | tr 'a-z' 'A-Z'
	@echo -n lower':'
	@echo "$(n)" | tr 'A-Z' 'a-z'
bash-3.1$ make c n=somethiNG
input:somethiNG
upper:SOMETHING lower:something
This isn't homework but I'm not very experienced with linux (I'm used to @echo in windows/dos environment and wasn't aware it is the same in linux as well).

As for making echo not print EOL, no, I wasn't familiar with this option so thank you for demonstrating it.

That is surely helped a lot and I really appreciate it
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
spamassassin: sa-learn --sync -> "Argument "M-HM-JM-J" isn't numeric" XXLRay Linux - Server 8 06-22-2010 10:10 AM
error: Error for wireless request "Set Mode" (8B06) : invalid argument "roaming" penguin chick Linux - Wireless Networking 5 08-22-2008 01:16 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
"cp -p" fails with "cp: setting permissions for `/home/svbld/t': Invalid argument" mkhesin Red Hat 1 02-28-2007 12:57 AM


All times are GMT -5. The time now is 01:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration