Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to run gmake when I run make, so I am creating a symbolic link. My gmake is inside /usr/local/dist. My make is inisde /usr/ccs/bin.

Is this the correct command: ln -s /usr/local/dist/gmake /usr/ccs/bin/make

My confusion is, do I even care about /usr/ccs/bin/make? I am making a symbolic link so if I type "make" anywhere it should just run gmake at /usr/local/dist right?

So should the command be: ln -s /usr/local/dist/gmake make?

share|improve this question
    
Check which command make points to at the moment. Try which make and then ls -al <the folder given by previous command>. Some distros have make as a symlink to gmake as standard. –  Trengot May 29 '14 at 13:13
    
Make does not currently point to anything -- ie I don't see "make -> something_else" –  DemiSheep May 29 '14 at 13:15
    
The second way creates the link in the current directory. So the effect it has depends what your last cd command was. –  Mikel May 29 '14 at 13:37

3 Answers 3

up vote 1 down vote accepted

You have to link gmake into the PATH before make, e.g. in /usr/bin. Check where make is linked now (if it is): type make

If /usr/bin is earlier in the PATH than the directory in which make is found then you can link it there with this command:

ln -s /usr/local/dist/gmake /usr/bin/make

Maybe you have to overwrite an existing link to make. I am not sure though how safe that is against updates of the package.

share|improve this answer
    
Thank you! So yes I already had added gmake earlier in my PATH than make (thought this was needed for what I was doing). So here is my command then: "ln -s /usr/sfw/bin/gmake /usr/ccs/bin/make" -- when I try this command I get the message: "ln: cannot create /usr/ccs/bin/make: File exists" –  DemiSheep May 29 '14 at 13:48
    
@DemiSheep You shall not overwrite an existing file (if it is not a symlink). Is /usr/ccs/bin part of your PATH? What is the output of type make? –  Hauke Laging May 29 '14 at 13:56
    
"type make" results in: "make is hashed (/usr/ccs/bin/make)" –  DemiSheep May 29 '14 at 14:11
mkdir -p ~/bin &&
  ln -s /usr/local/dist/gmake ~/bin/make &&
  PATH=~/bin:$PATH

That way you have control over what process (those that have a PATH where you're ~/bin is before /usr/ccs/bin) would invoke gmake upon make.

share|improve this answer
    
Not a very permanent effect though... –  Hauke Laging May 29 '14 at 13:59
1  
@HaukeLaging, well the point is you should not make it permanent. You don't want gmake to take over make as it would probably break things. If you still want to make it permanent (for your user), add the PATH=~/bin:$PATH to your ~/.profile –  Stéphane Chazelas May 29 '14 at 14:03
    
OK, interesting point but that should be explained in the answer then. –  Hauke Laging May 29 '14 at 14:17

Symlinking system binaries is usually not the correct approach at all. This will cause untold complications later with other software that expects certain binary names to correspond to certain know behaviors. It sounds like what you want is an alias instead. In your shell run:

alias make=gmake

Now any time you type make, it will run gmake for you. To make this permanent, add that line to your shell's rc file (e.g. ~/.bashrc).

share|improve this answer
    
That's an interesting thought and makes a lot of sense. So any script I run that calls make will be fine with the alias as well, correct? The reason I started down this road of creating a symlink is because the other machine has a symbolic link setup the way I was working on duplicating. Would the symlink be seen by all users on the system, where the alias would only be used by me? –  DemiSheep May 29 '14 at 13:52
1  
@DemiSheep, no. aliases affect only interactive shells (and only those that read you ~/.bashrc). –  Stéphane Chazelas May 29 '14 at 13:55
    
@DemiSheep No, aliases affect your interactive shell, not scripts. You should really be writing your scripts to call the binary you actually want. If you script expects the behavior of gmake rather than make, it should be calling gmake explicitly. –  Caleb May 29 '14 at 14:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.