Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile 만들어서 컴파일하기 #4

Open
yejineee opened this issue Apr 17, 2021 · 1 comment
Open

Makefile 만들어서 컴파일하기 #4

yejineee opened this issue Apr 17, 2021 · 1 comment
Labels
Linux Linux ⚙️ Settings 세팅, 배포

Comments

@yejineee
Copy link
Owner

Makefile 작성 규칙

image

목표파일 : 목표파일을 만드는데 필요한 구성요소들
    목표를 달성하기 위한 명령 1
    목표를 달성하기 위한 명령 2

매크로 사용

  • 매크로 참조는 ${macro_name}, $(macro_name), $macro_name으로 사용하면 된다.
    -> 대부분의 책은 $(..)을 권한다.
  • 매크로는 치환될 위치보다 상위에서 정의되어야 한다.
  • 탭으로 시작해서는 안되고, :,=,#,”” 등은 매크로 이름으로 사용될 수 없다.

내부 매크로 사용

$@ : 현재 타겟 파일 이름
$^ : 현재 타겟 파일의 종속 리스트

예시

CC = gcc
TARGET = main
DEPENDENCY = collatz.c main.c error.c

$(TARGET):  $(DEPENDENCY)
    $(CC) -o $@ $^

clean :
    rm -rf *.o $(TARGET)
@yejineee yejineee added the ⚙️ Settings 세팅, 배포 label Apr 17, 2021
@yejineee
Copy link
Owner Author

@yejineee yejineee added the Linux Linux label Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux Linux ⚙️ Settings 세팅, 배포
Projects
None yet
Development

No branches or pull requests

1 participant