====== Установка ПО из исходных текстов ====== ===== Учебный пример ===== ==== Простейшая программа ==== $ cat hello.c #include int main () { printf("Hello World\n"); } $ cc hello.c -o hello.exe $ ./hello.exe Hello World ==== Программа из нескольких исходных файлов ==== $ cat hello.c #include extern char* str; int main () { printf("%s",str); } $ cat string.c char* str="Hello World 3\n"; $ cc -c hello.c $ cc -c string.c $ cc hello.o string.o -o hello.exe $ ./hello.exe Hello World 3 ==== Использование утилиты make ==== # apt install make $ cat Makefile hello.exe: hello.o string.o cc hello.o string.o -o hello.exe hello.o: hello.c cc -c hello.c string.o: string.c cc -c string.c $ cat string.c char* str="Hello World 4\n"; $ make cc -c string.c cc hello.o string.o -o hello.exe $ ./hello.exe Hello World 4 ==== Использование меток в файле конфигурации make ==== $ cat Makefile ... install: cp hello.exe /usr/local/bin clean: rm *.o rm *.exe $ sudo make install cp hello.exe /usr/local/bin $ hello.exe Hello World 4 $ make clean rm *.o rm *.exe ==== Использование make для сопровождения файлов конфигурации сервиса ==== * Модуль AppArmor [[Модуль AppArmor#Определение наличия и правка профилей для служб]] student@gate:~$ mkdir dhcp student@gate:~$ cd dhcp/ student@gate:~/dhcp$ cp /etc/dhcp/dhcpd.conf . student@gate:~/dhcp$ cat Makefile test: /usr/sbin/dhcpd -t -cf dhcpd.conf install: cp dhcpd.conf /etc/dhcp/dhcpd.conf systemctl restart isc-dhcp-server student@gate:~/dhcp$ make test student@gate:~/dhcp$ sudo make install ===== Пример установки текстового браузера ===== freebsd# fetch http://invisible-mirror.net/archives/lynx/tarballs/lynx2.8.5rel.1.tar.gz или gentoo# wget http://invisible-mirror.net/archives/lynx/tarballs/lynx2.8.9rel.1.tar.gz # tar -xvf lynx2.8.*.tar.gz # cd lynx # more README # ./configure --help gentoo# ./configure --prefix=/usr/local freebsd# ./configure --prefix=/usr/local/lynx # make # make install # lynx https://ya.ru !!! не работает, нужно было собирать с поддержкой ssl !!! # lynx http://val.bmstu.ru # lynx http://www.bmstu.ru # make uninstall # make clean