Makefile에서 조건문을 만들기에 대한 질문입니다.

hyper9의 이미지


지금하고 싶은것은요,,,

/etc/fedora-release 의 값을 읽어서
Fedora Core 5와 Fedora Core 7을 구별한 후에
그걸 바탕으로 Makefile에 약간 다른 부분을 추가해 넣으려고 합니다.

일단 /etc/fedora-release의 내용을 보면요,,
Fedora release 7 (Moonshine)
이라고 되어 있습니다.

VERSION=$(cat /etc/fedora-release | cut -d' ' -f4)로 읽으면
예를 들어 Fedora Core 7인 경우에는 Version이 "(Moonshine)"의 값을
가질 것으로 생각했습니다. (이게 틀리면 지적해 주세요~)

그리고는 Makefile내에

ifneq(,$(VERSION))
$(warning *** Warning-111)
else
$(warning *** Warning-222)
endif
와 같은 일종의 조건문을 삽입하는 게 목표입니다.
위와 같은 조건문을 삽입하고 Compile을 해봤습니다.

이렇게 하면 결과가 아래와 같습니다.

Makefile:3: *** missing separator. Stop.
그리고 3번째 줄은 위에서 보인 ifneq(,$(VERSION))이 있는 줄입니다.
어떤게 잘못된건지 잘 몰라서요..지적해 주시면 감사하겠고요
혹시 전체적으로 뭔가 잘 이해를 못하고 있는 것 같다면,,
전반적인 설명을 해주시는 것도 정말 환영합니다..

아 그리고 한가지 추가 질문이 있는데요 ,,
위에서 $(warning *** Warning-111)과 같은 line은 Makefile에 따라
make를 진행하면서 뭔가 Message를 출력하고 싶어서 첨가한 줄인데요..
이건 기존의 어떤분이 해놓은걸 Copy해서 쓰고 있는 것이고요..

혹시 echo나 @echo를 써서도 뭔가 string을 출력할 수 있도록 할 수 있지
않나요?

예전에는 했던것 같은데,,이번엔 뭔가를 잘못하는지 echo를 써서 string 출력
하는걸 잘 못하고 있습니다.
이 문제에 대해서도 질문을 드리고 싶네요.

그럼 많은 의견 부탁드립니다. ^^

hyper9의 이미지

VER=(Moonshine)
VERSION=$(cat /etc/fedora-release | cut -d' ' -f3)

$(warning *** Warning: kernel source version ($(VERSION)))
$(warning *** Warning: kernel source version ($(VER)))

ifeq ($(VERSION),VER)
SUBDIRS=abcd
else
SUBDIRS=efgh
endif

그랬더니,,VERSION의 값은 공백으로 찍히고, VER의 값은 제대로 (Moonshine)이 찍히네요
이 이유는 어째서일까요 ~ 다시 질문 드립니다..

primewizard의 이미지

이것을
VERSION=$(cat /etc/fedora-release | cut -d' ' -f4)

이렇게
VERSION=$(shell cat /etc/fedora-release | cut -d' ' -f4)

--
Makefile 탭 간격 주의하세요.

hyper9의 이미지

위에 분이 말씀해 주신대로 하니까..
일단 아래에서 $(VERSION) 과 $(VER) 값이 제대로 찍히는 건 확인이
잘 되었습니다.

그 다음 질문이었던 echo나 warning의 사용법이나,
Make진행중에 message를 출력하는 방법등도 알려주시면
감사하겠습니다 .~

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.