懒人学习automake, Makefile.am,configure.ac

时间:2023-03-09 08:09:44
懒人学习automake, Makefile.am,configure.ac

已经存在Makefile.am,如何生成Makefile?

步骤:

  1. [root@localhost hello]# autoscan .///在当前文件夹中搜索
  2. [root@localhost hello]# cp configure.scan configure.ac //复制文件
  3. [root@localhost hello]# vi configure.ac //编辑文件
  4. 编辑configure.ac,加入下面一行:
  5. AM_INIT_AUTOMAKE(hello,1.0)      //automake所必备的宏,必须添加
  6. [root@localhost hello]# aclocal     //执行aclocal生成aclocal.m4文件
  7. [root@localhost hello]# autoconf   //执行autoconf生成configure文件
  8. [root@localhost hello]# autoheader
  9. [root@localhost hello]# automake --add-missing
  10. [root@localhost hello]# touch NEWS; touch README; touch AUTHORS; touch ChangeLog    //创建NEWS等文件,如果没有自动生成,手工创建
  11. [root@localhost hello]# automake --add-missing //再运行一次
  12. [root@localhost hello]# ./configure    //配置,生成Makefile文件
  13. [root@localhost hello]# make     //执行make命令

以上过程可能出现一些警告,请忽略。最后,给出一个Makefile.am的内容作为例子:

  1. AM_LDFLAGS = -lpthread -lc -lm -lrt -ldl
  2. CXXFLAGS = -D__STDC_LIMIT_MACROS -g -Wall -DORDER_SERIALIZE #-O2 -fno-strict-aliasing
  3. bin_PROGRAMS = parser_main
  4. parser_main_SOURCES = parser_main.cpp \
  5. Parser.cpp \
  6. Lexer.cpp \
  7. SelectStmt.cpp \
  8. InsertStmt.cpp \
  9. UpdateStmt.cpp \
  10. DeleteStmt.cpp \
  11. Stmt.cpp \
  12. Expr.cpp \
  13. Identifier.cpp
  14. ~

参考文献:

http://os.51cto.com/art/201006/207098.htm

http://os.51cto.com/art/201006/207099.htm

http://os.51cto.com/art/201006/207101.htm

如何写Makefile.am