User Tools

Site Tools


установка_по_из_исходных_текстов

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
установка_по_из_исходных_текстов [2011/02/25 22:29]
val
установка_по_из_исходных_текстов [2022/06/17 15:12]
val [Использование make для сопровождения файлов конфигурации сервисов]
Line 2: Line 2:
  
 ===== Учебный пример ===== ===== Учебный пример =====
 +
 +
 +
 ==== Простейшая программа ==== ==== Простейшая программа ====
 <​code>​ <​code>​
-$ cat hello.c+$ cat hello.c 
 +</​code><​code>​
 #include <​stdio.h>​ #include <​stdio.h>​
-main () {+int main () {
         printf("​Hello World\n"​);​         printf("​Hello World\n"​);​
 } }
-<Ctrl>-D +</​code><​code>
 $ cc hello.c -o hello.exe $ cc hello.c -o hello.exe
  
Line 16: Line 19:
 Hello World Hello World
 </​code>​ </​code>​
 +
 ==== Программа из нескольких исходных файлов ==== ==== Программа из нескольких исходных файлов ====
 <​code>​ <​code>​
 $ cat hello.c $ cat hello.c
 +</​code><​code>​
 #include <​stdio.h>​ #include <​stdio.h>​
 extern char* str; extern char* str;
-main () { +int main () { 
-        printf(str);​+        printf("​%s",​str);
 } }
 +</​code><​code>​
 $ cat string.c $ cat string.c
 +</​code><​code>​
 char* str="​Hello World 3\n"; char* str="​Hello World 3\n";
- +</​code><​code>​
-$ ls -lT +
 $ cc -c hello.c $ cc -c hello.c
 $ cc -c string.c $ cc -c string.c
 $ cc hello.o string.o -o hello.exe $ cc hello.o string.o -o hello.exe
 +
 $ ./hello.exe $ ./hello.exe
 Hello World 3 Hello World 3
Line 39: Line 44:
 ==== Использование утилиты make ==== ==== Использование утилиты make ====
 <​code>​ <​code>​
-$ cat Makefile+# apt install make 
 + 
 +$ cat Makefile 
 +</​code><​code>​
 hello.exe: hello.o string.o hello.exe: hello.o string.o
-        ​cc hello.o string.o -o hello.exe+ cc hello.o string.o -o hello.exe
 hello.o: hello.c hello.o: hello.c
-        ​cc -c hello.c+ cc -c hello.c
 string.o: string.c string.o: string.c
-        ​cc -c string.c + cc -c string.c 
-<Ctrl>-D +</​code><​code>
 $ cat string.c $ cat string.c
 +</​code><​code>​
 char* str="​Hello World 4\n"; char* str="​Hello World 4\n";
 +</​code><​code>​
 $ make $ make
 cc -c string.c cc -c string.c
Line 58: Line 66:
 Hello World 4 Hello World 4
 </​code>​ </​code>​
- 
 ==== Использование меток в файле конфигурации make ==== ==== Использование меток в файле конфигурации make ====
 <​code>​ <​code>​
-$ cat >> ​Makefile+$ cat Makefile 
 +</code><code> 
 +...
 install: install:
-        ​cp hello.exe /​usr/​local/​bin+ cp hello.exe /​usr/​local/​bin
 clean: clean:
-        ​rm *.o + rm *.o 
-        rm *.exe + rm *.exe 
-<Ctrl>-D +</​code><​code>
 $ sudo make install $ sudo make install
 cp hello.exe /​usr/​local/​bin cp hello.exe /​usr/​local/​bin
Line 79: Line 87:
 rm *.exe rm *.exe
 </​code>​ </​code>​
-===== Пример установки текстового браузера ​(libncurses5-dev) ​=====+ 
 +==== Использование make для сопровождения файлов конфигурации сервиса ==== 
 + 
 +  * Модуль AppArmor [[Модуль AppArmor#​Определение наличия и правка профилей для служб]] 
 + 
 +<​code>​ 
 +student@gate:​~$ mkdir dhcp 
 + 
 +student@gate:​~$ cd dhcp/ 
 + 
 +student@gate:​~/​dhcp$ cp /​etc/​dhcp/​dhcpd.conf . 
 + 
 +student@gate:​~/​dhcp$ cat Makefile 
 +</​code><​code>​ 
 +test: 
 +        dhcpd -t -cf dhcpd.conf 
 +install: 
 +        cp dhcpd.conf /​etc/​dhcp/​dhcpd.conf 
 +        systemctl restart isc-dhcp-server 
 +</​code><​code>​ 
 +student@gate:​~/​dhcp$ make test 
 + 
 +student@gate:​~/​dhcp$ sudo make install 
 +</​code>​ 
 + 
 +===== Пример установки текстового браузера ===== 
 <​code>​ <​code>​
-fetch http://lynx.isc.org/lynx2.8.5/lynx2.8.5.tar.bz2+freebsd# ​fetch http://invisible-mirror.net/​archives/​lynx/​tarballs/lynx2.8.5rel.1.tar.gz
 или или
-wget http://lynx.isc.org/lynx2.8.5/lynx2.8.5.tar.bz2+gentoo# ​wget http://invisible-mirror.net/​archives/​lynx/​tarballs/lynx2.8.9rel.1.tar.gz
  
-tar -xvf lynx2.8.5.tar.bz2+tar -xvf lynx2.8.*.tar.gz
  
-cd lynx2-8-5+cd lynx<​TAB>​
  
-more README+more README
  
-./configure --prefix=/​home/​userX/​+./configure --help
  
-$ make+gentoo# ./configure --prefix=/​usr/​local 
 +freebsd# ./configure --prefix=/​usr/​local/​lynx
  
-make install+make
  
-make clean+make install 
 + 
 +# lynx https://​ya.ru ​ !!! не работает,​ нужно было собирать с поддержкой ssl !!! 
 +# lynx http://​val.bmstu.ru 
 +# lynx http://​www.bmstu.ru 
 + 
 +# make uninstall
  
-$ lynx http://​www.ru+# make clean
 </​code>​ </​code>​
установка_по_из_исходных_текстов.txt · Last modified: 2022/09/08 15:50 by val