makefile작성하다가..

anycastle의 이미지

File: a.c
#include “a.h”
#include “b.h”
File: b.c
#include “b.h”
File: b.h
#include “common.h”

저소스대로 makefile작성좀알려주세요

jj의 이미지

anycastle님, 작성하다 막혔으면, 일단 작성한 코드를 보여주세요. 틀린점을 지적해주실겁니다.

요즘 올라오는 이런 질문들, 아쉽습니다. 지식in의 영향일까요?

--
콘쏠의힘

--
Life is short. damn short...

eminency의 이미지

예의가 부실한 질문이네요

노루가 사냥꾼의 손에서 벗어나는 것 같이, 새가 그물치는 자의 손에서 벗어나는 것 같이 스스로 구원하라 -잠언 6:5

akbar의 이미지

AAAA

ㅡ,.ㅡ;;의 이미지

저정도는 라면 그냥

makefile 만들지말고..

cc a.c

로.ㅎㅎ


----------------------------------------------------------------------------

mrjh76의 이미지

이래저래... 구찮으면...

qmake 를 사용해보세요~~~ (원래 QT를 위한것이나... QT가 링크되서 그렇지 다른데서도 잘 됩니다!)

# qmake -project
# qmake

위와 같이 명령어 두번치면,,, 서브디렉토리까지 검사해서 자동으로 Makefile 만들어 줍니다!

ssehoony의 이미지

아마 소스파일이 헤더파일의 변경이 있을 때도 재 컴파일 하도록하시는게 목적인가요?
그렇다면

a.o : a.h b.h common.h a.c
b.o : b.h common.h b.c

이런식으로 하시면 되는데요.
매번 헤더 include 까지 신경 쓸려면 귀찮습니다.
만약 common.h 가 stdio.h 를 include 했다면요?
근데 알고 보니 stdio.h 는 sys/type.h 와 sys/time.h 를 include 했다면요?
언제 하나씩 다 추적해 볼 수도 없는 노릇이죠.

이런 의존성 문제를 편리하게 해결하기 위해 gcc에는 다음과 같은 옵션이 있습니다.

       -M  Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the
           main source file.  The preprocessor outputs one make rule containing the object file name for that source file, a
           colon, and the names of all the included files, including those coming from -include or -imacros command line
           options.
 
           Unless specified explicitly (with -MT or -MQ), the object file name consists of the basename of the source file with
           any suffix replaced with object file suffix.  If there are many included files then the rule is split into several
           lines using \-newline.  The rule has no commands.
 
           This option does not suppress the preprocessor's debug output, such as -dM.  To avoid mixing such debug output with
           the dependency rules you should explicitly specify the dependency output file with -MF, or use an environment vari-
           able like DEPENDENCIES_OUTPUT.  Debug output will still be sent to the regular output stream as normal.
 
           Passing -M to the driver implies -E, and suppresses warnings with an implicit -w.

이걸 활용하는 간다한 예제가 gcc문서에서 본적이 있는 듯 합니다.
자세한건 gcc문서를 참고해 보세요.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.