[原创]一个简单的makefile编写及shell环境下直接make生成可供gdb调试的二进制文件。

jackxiang 2007-10-11 17:06 | |
#file a b c makefile
CGI_DIR =bin


all:myfile

myfile:filea.o fileb.o filec.o
        gcc filea.o fileb.o filec.o -o myfile
filea.o:filea.c head.h
        gcc -c filea.c
fileb.o:fileb.c head.h
        gcc -c fileb.c
filec.o:filec.c head.h
        gcc -c filec.c

install:
        @if [ ! -d $(CGI_DIR) ]; then \
        mkdir -p $(CGI_DIR); \
        fi
        cp myfile /usr/home/xiangdong2/c++/make/$(CGI_DIR)




clean:
        rm -f *.o;
        rm -rf myfile
        rm -rf bin

(注意:这儿的要执行的命令要用tab键隔开,否则出现:operation erro)



———————————shell环境下直接make生成可供gdb调试的二进制文件。—————————————
root@192.168.137.128:~/dev_codes_all/arts_debug_book/arts_debug/chapt1# make ins CFLAGS="-Wall -o2 -g"
cc -Wall -o2 -g    ins.c   -o ins
root@192.168.137.128:~/dev_codes_all/arts_debug_book/arts_debug/chapt1# gdb ins
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/dev_codes_all/arts_debug_book/arts_debug/chapt1/ins...done.
(gdb) l
53      void print_results()
54      {
55        int i;
56        for (i = 0; i < num_inputs; i++)
57          printf("%d\n", y[i]);
58      }
59          
60      int main(int argc,char **argv)
61      {
62        get_args(argc,argv);
(gdb)

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/694/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2013-10-8 23:29
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]