So I have this basic terminal app, which the contents of which I don’t think matter. I would like to be able to run the application with a custom command, simply something like: foo
.
I have had times where when I download a ZIP file and open it, all of a sudden there is a new terminal command at my disposal that runs the application without using ./
at all.
TL;DR: What code should I put in a Makefile to create a terminal command?
I am using Debian Linux, but a cross-platform solution or a few different solutions would all be appreciated.
I have tried simply writing code into the file: .bachrc
, but that would not be an easy thing for an average user to do. I have also tried concatenating some text to it, but that never seemed to work for me.
2
Answers
Create a bin directory in your home directory
Move your terminal app to the newly created bin directory
Then add your local bin to your PATH environment variable by adding this to the end of your .bashrc:
In a new terminal window try to find your command.
You should get output that looks something like this:
NOTE: if you prefer you can create a symbolic link to your terminal app instead of moving it, like this:
The usual mechanism is to have an
install:
target in yourMakefile
which installs the script or binary into/usr/local/bin
; but you also want to be able to allow the user to override this (so that, for example, a Debian package can use yourMakefile
but install toDEBIAN/usr/bin
instead).Here,
scriptfile
is a script or binary executable which you want to install in/usr/local/bin/scriptfile
which should then make it available to any user with a sanePATH
.For good measure, probably also include
uninstall
;If someone wants to install to their home directory, they can
make prefix=$HOME
or some such.DESTDIR
is a common convention for setting the installation root; so, for example, a Debian packager would setDESTDIR=DEBIAN/
andprefix=/usr
. (A more complex project might also install libraries in$(DESTDIR)$(prefix)/lib
, man pages in$(DESTDIR)$(prefix)/share/man
, etc.)