본문 바로가기

리눅스

configure, make, make install 명령어

728x90

configure, make, make install 명령어

리눅스에서 소스 코드로부터 프로그램을 설치하는 과정은 일반적으로 configure, make, make install 명령어를 사용합니다.

 

이미지 출처-https://www.amazon.com

 

명령 설명
configure configure 명령을 이용하여 Makfile 생성
make distclean make clean과 유사하지만 Makefile을 포함하여 configure에 의해 생성된 모든 파일도 삭제합니다.
(파일을 받고 압축을 푼 처음 상태로 만드는 것)
make Makefile에 따라 소스 코드를 컴파일하고 링크하고 목적 파일, 실행 파일을 생성합니다.
(Makfile를 이용해서 소스 코드를 컴파일하여 실행가능한 설치파일을 만듬)
make clean 마지막 make 명령으로 생성된 개체 파일(접미사가 ".o"인 파일)과 실행 파일을 지웁니다
make install 컴파일된 실행 파일을 시스템 디렉토리(일반적으로 /usr/local/bin 디렉토리)에 설치합니다.
(설치파일을 설치하는 과정)

 

각 명령어의 역할과 사용 방법에 대한 간략한 설명

1. configure

configure 명령어는 소스 코드를 빌드하기 전에 시스템에 대한 구성 옵션을 설정합니다. 일반적으로 configure 스크립트가 프로젝트 디렉토리에 포함되어 있습니다. configure 스크립트를 실행하면 시스템에 대한 구성 옵션을 확인하고 필요한 의존성을 검사하여 빌드 환경을 설정합니다.

./configure [옵션]

일반적으로 ./configure 명령어는 다양한 옵션을 지정하여 빌드를 커스터마이즈할 수 있습니다. 자세한 옵션은 프로젝트의 문서나 README 파일에서 확인할 수 있습니다.

2. make

make 명령어는 configure 단계에서 생성된 Makefile을 사용하여 소스 코드를 컴파일합니다. Makefile은 빌드 프로세스를 자동화하기 위한 빌드 스크립트입니다. make 명령어를 실행하면 Makefile에 지정된 규칙에 따라 소스 코드가 컴파일되고 실행 파일이 생성됩니다.

make 컴파일 빠르게 하기

-j [N], --jobs[=N]
동시에 실행할 작업(명령)의 수를 지정합니다.
-j 옵션이 둘 이상 있으면 마지막 옵션이 유효합니다.
-j 옵션이 인수 없이 주어지면 make는 동시에 실행할 수 있는 작업의 수를 제한하지 않습니다.
make
make -j $(($(nproc) + 1))

make 명령어는 일반적으로 여러 개의 CPU 코어를 동시에 사용하여 빌드 프로세스를 가속화합니다. -j 옵션을 사용하여 동시에 실행되는 작업의 수를 지정할 수 있습니다. 예를 들어 -j4는 4개의 작업을 병렬로 실행합니다.

728x90

3. make install

make install 명령어는 빌드된 실행 파일과 관련 파일을 시스템에 설치합니다. 일반적으로 /usr/local 디렉토리 아래에 파일이 설치됩니다. make install 명령어를 실행하면 컴파일된 실행 파일이 지정된 위치로 복사되고, 라이브러리 파일이 적절한 디렉토리에 설치됩니다.

make install
make install -j $(($(nproc) + 1))

make install 명령어는 루트 권한을 필요로 할 수 있으므로 sudo 명령어와 함께 사용해야 할 수도 있습니다.

 

  • make 버전 정보
$ make -v
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

 

  • make 옵션 사용법
$ make -h
사용법: make [옵션] [타겟] ...
옵션:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.
  --warn-undefined-functions  Warn when an undefined user function is called.

This program built for x86_64-redhat-linux-gnu
Report bugs to <[email protected]

 

위의 단계를 따라 소스 코드를 컴파일하고 설치하면 프로그램이 시스템에 설치되어 사용할 수 있게 됩니다. 그러나 각 프로젝트마다 구체적인 빌드 및 설치 절차가 다를 수 있으므로 해당 프로젝트의 문서를 참조하여 정확한 명령어와 옵션을 확인하는 것이 좋습니다.

 

728x90