2013年2月2日土曜日

[Makefile]automakeを使用してMakefileを作成する手順

以下のディレクトリ構成でautomakeを実施する手順を記述する。
hello

└─src
        hello.c
        hello.h
        main.c
  1. hello/Makefile.am を作成
  2. SUBDIRS = src
  3. hello/src/Makefile.am を作成
    bin_PROGRAMS = hello
    hello_SOURCES = hello.c hello.h main.c
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      Makefile.am (*)
    
    └─src
            hello.c
            hello.h
            main.c
            Makefile.am (*)
  4. hello直下でautoscanを実行しconfigure.scanを作成する
  5. configure.scanをconfigure.acに改名して以下の箇所を修正
    1. AC_INITの中身を修正
      AC_INIT([hello, 1.0], [hoge@hogehoge])
    2. AC_INITの次の行に以下を追加
      AM_INIT_AUTOMAKE([foreign])
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      autoscan-2.63.log (*)
      configure.ac (*)
      Makefile.am
    
    └─src
            hello.c
            hello.h
            main.c
            Makefile.am
  6. autoheader 実行
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      autoscan-2.63.log
      config.h.in (*)
      configure.ac
      Makefile.am
    
    ├─autom4te.cache (*)
          output.0 (*)
          requests (*)
          traces.0 (*)
    
    └─src
            hello.c
            hello.h
            main.c
            Makefile.am
  7. aclocalを実行
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      aclocal.m4 (*)
      autoscan-2.63.log
      config.h.in
      configure.ac
      Makefile.am
    
    ├─autom4te.cache
          output.0
          output.1 (*)
          requests
          traces.0
          traces.1 (*)
    
    └─src
            hello.c
            hello.h
            main.c
            Makefile.am
  8. automake ‑‑add-missing ‑‑copyを実行
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      aclocal.m4
      autoscan-2.63.log
      config.h.in
      configure.ac
      depcomp (*)
      install-sh (*)
      Makefile.am
      Makefile.in (*)
      missing (*)
    
    ├─autom4te.cache
          output.0
          output.1
          output.2 (*)
          requests
          traces.0
          traces.1
          traces.2 (*)
    
    └─src
            hello.c
            hello.h
            main.c
            Makefile.am
            Makefile.in (*)
  9. autoconfを実行
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      aclocal.m4
      autoscan-2.63.log
      config.h.in
      configure (*)
      configure.ac
      depcomp
      install-sh
      Makefile.am
      Makefile.in
      missing
    
    ├─autom4te.cache
          output.0
          output.1
          output.2
          requests
          traces.0
          traces.1
          traces.2
    
    └─src
            hello.c
            hello.h
            main.c
            Makefile.am
            Makefile.in
  10. configureを実行
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      aclocal.m4
      autoscan-2.63.log
      config.h (*)
      config.h.in
      config.log (*)
      config.status (*)
      configure
      configure.ac
      depcomp
      install-sh
      Makefile (*)
      Makefile.am
      Makefile.in
      missing
      stamp-h1 (*)
    
    ├─autom4te.cache
          output.0
          output.1
          output.2
          requests
          traces.0
          traces.1
          traces.2
    
    └─src
          hello.c
          hello.h
          main.c
          Makefile (*)
          Makefile.am
          Makefile.in
        
        └─.deps (*)
                hello.Po (*)
                main.Po (*)
  11. makeを実行
    この時点でのディレクトリ構成は以下の通り(*は新規追加されたファイル)
    hello
      aclocal.m4
      autoscan-2.63.log
      config.h
      config.h.in
      config.h.in~ (*)
      config.log
      config.status
      configure
      configure.ac
      depcomp
      install-sh
      Makefile
      Makefile.am
      Makefile.in
      missing
      stamp-h1
    
    ├─autom4te.cache
          output.0
          output.1
          output.2
          requests
          traces.0
          traces.1
          traces.2
    
    └─src
          hello.c
          hello.exe (*)
          hello.h
          hello.o (*)
          main.c
          main.o (*)
          Makefile
          Makefile.am
          Makefile.in
        
        └─.deps
                hello.Po
                main.Po

0 件のコメント:

コメントを投稿