Setting the CPUTYPE compiler variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Setting the CPUTYPE compiler variable
# 1  
Old 04-05-2009
Setting the CPUTYPE compiler variable

I have a piece of code in BSD that sets a compiler variable, but I am unable to make it work:
Code:
# set compiler options and make options
cputype=`uname -p`
if [ $cputype == "amd64" ]; then
	$cputype="athlon64"
fi

cd /etc
echo " " >> make.conf
echo "CPUTYPE?=$cputype" >> make.conf

The error appears at the comparison operator "==". What do I change to make this work? Thanks in advance.
# 2  
Old 04-05-2009
Code:
cputype=`uname -p`
if [ $cputype == "amd64" ]; then
	$cputype="athlon64"
fi

For starters, Best Practices(Tm) suggest you "should" use ALL_CAPS for customized variables. This keeps convention between customized variables and standard variables (i.e., $PATH, $SHELL, etc).

The 'if' command (to the best of my knowledge) does not recognize "==" as "equal to" -- you want to use "-eq" (or -ne for "not equal to").

Regards.

Last edited by glen.barber; 04-05-2009 at 08:48 AM.. Reason: Fixed formatting
# 3  
Old 04-05-2009
Thank you for your response. The comparison operator for strings is one or more "=" signs, see here: Comparison operators (binary), and it is "-eq" for numbers only.
I currently have the, which seems to work:
Code:
# set compiler options and make options
cputype=`uname -p`
if [ $cputype=="amd64" ]; then
	cputype=athlon64
fi
cd /etc
echo " " >> make.conf
echo "CPUTYPE?=$cputype" >> make.conf

Changes made include the removal of spaces and the removal of the dollar sign in front of the variable.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setting a TZ variable in a script

Hello all, I know this must be simple .... but i can't grasp what could be the issue. I'm trying to setup the timezone variable (to the unix command date) according to what i find in a value that i got from parsing the config file. The end result would be setting the log file with this new... (4 Replies)
Discussion started by: maverick72
4 Replies

2. Shell Programming and Scripting

Setting a variable within if block

Hi, i have a variable which i would like to set inside an if block for example IS_VAR=0 if then IS_VAR=1 fi echo IS_VAR the last echo statement gives 0.So setting variables in the if block doesnt have effect outside the block?Is there any workaround for this? Thanks , Padmini (11 Replies)
Discussion started by: padmisri
11 Replies

3. Shell Programming and Scripting

Help with setting a variable!

I am working within a while loop and i am trying to set a variable that will read out each count of the files. the problem is the count variable i have set up gives me a total and not the individual count of each file. in the data area there is 4 abc.dat and 1 def.dat. how can i do this??? ... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

4. UNIX for Dummies Questions & Answers

setting a variable

In my script, I have the following command.... du -sk `ls -ltd sales12|awk '{print $11}'`|awk '{print $1}' it returns the value 383283 I want to modify my script to capture that value into a variable. So, I try doing the following... var1=`du -sk `ls -ltd sales12|awk '{print... (5 Replies)
Discussion started by: tumblez
5 Replies

5. Shell Programming and Scripting

Setting variable

How do you set a varible with information that contains a string and also another variable? For example: subject="Attention: $name / This $type needs your attention" The $xxxx are of course other variables that I instantiated earlier. Is it like Java where you have to use double quotes and... (1 Reply)
Discussion started by: briskbaby
1 Replies

6. Shell Programming and Scripting

Variable setting help please

L=0 cat test.sh | while read line do L='expr $1 + 1' echo $L done echo $l >>> the echo $L at the end produces 0 but i actually want it to produce the number of lines - any idea why this is happening? (16 Replies)
Discussion started by: penfold
16 Replies

7. UNIX for Dummies Questions & Answers

Setting a variable

I want to set a variable to be any number of dashes. Rather than doing the following: MYVAR="------------------" I'd like to be able to set the variable to, say, 80 dashes but don't want to have to count 80 dashes. Is there a way to do this? (2 Replies)
Discussion started by: photh
2 Replies

8. Programming

setting CC variable

I am trying to install GCC-3.1.1 on an SGI Indigo2. I already have MIPSpro 7.2.1 installed. However, when I try to configure GCC-3.1.1, I get the message "cc ERROR: cc -o conftest -g failed, You must set the environment variable CC to a working compiler." What is the name of the MIPSpro c++... (1 Reply)
Discussion started by: mdbanas
1 Replies

9. UNIX for Dummies Questions & Answers

setting CC variable

I am trying to install GCC-3.1.1 on an SGI Indigo2. I already have MIPSpro 7.2.1 installed. However, when I try to configure GCC-3.1.1, I get the message "cc ERROR: cc -o conftest -g failed, You must set the environment variable CC to a working compiler." What is the name of the MIPSpro c++... (1 Reply)
Discussion started by: mdbanas
1 Replies

10. UNIX for Dummies Questions & Answers

Setting TERM variable

Does anybody know how to give a default TERM variable while telnetting to Solaris (1 Reply)
Discussion started by: DPAI
1 Replies
Login or Register to Ask a Question