2.9. Placing arbitrary artifacts in the system using the make install command
make install command is an automated way to install built software to the system. In this case, you need to specify how to install the arbitrary artifacts to the system in the
Makefile that is usually written by the developer.
This procedure shows how to install a build artifact into a chosen location on the system.
installsection to the
cello: gcc -g -o cello cello.c clean: rm cello install: mkdir -p $(DESTDIR)/usr/bin install -m 0755 cello $(DESTDIR)/usr/bin/cello
Note that the lines under
install:must begin with a tab space.Note
Now you can use
Makefilenot only to build software, but also to install it to the target system.
Build and install the
$ make gcc -g -o cello cello.c $ sudo make install install -m 0755 cello /usr/bin/cello
As a result,
cellois now located in the directory that is listed in the
cellofrom any directory without specifying its full path:
$ cd ~ $ cello Hello World