⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 一套完整的makefile样板 - c-c++讨论区-原创精华帖.htm

📁 Makefile编程及相关资料的介绍与入门。很适合初学者的学习与借鉴
💻 HTM
📖 第 1 页 / 共 4 页
字号:
          <TD vAlign=bottom noWrap align=left width="10%"><SPAN class=nav><A 
            href="http://bbs.chinaunix.net/forum/posting.php?show_type=&amp;mode=newtopic&amp;f=23"><IMG 
            alt=发表新帖 src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/post.gif" 
            align=middle border=0></A>&nbsp;&nbsp;&nbsp;<A 
            href="http://bbs.chinaunix.net/forum/posting.php?show_type=&amp;mode=reply&amp;t=534829"><IMG 
            alt=回复帖子 src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/reply.gif" 
            align=middle border=0></A></SPAN></TD>
          <TD vAlign=center align=left width=*><SPAN 
            class=nav>&nbsp;&nbsp;&nbsp;<A class=nav 
            href="http://www.chinaunix.net/">首页</A> -&gt; <A class=nav 
            href="http://bbs.chinaunix.net/forum">论坛首页</A> -&gt; <A class=nav 
            href="http://bbs.chinaunix.net/forum/viewforum.php?f=23">C/C++</A></SPAN></TD>
          <TD align=right><A class=nav 
            href="http://bbs.chinaunix.net/forum/favorites.php?t=534829&amp;mode=add" 
            target=_blank><IMG alt=将本帖添加到我的收藏夹 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/fav_add.gif" 
            border=0>添加到我的收藏夹</A> <A class=nav 
            href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=19&amp;title='+escape(d.title)+'&amp;url='+escape(d.location.href)+'&amp;desc='+escape(t),'vivi','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes'));vivi.focus();">[<FONT 
            color=blue>收藏此页到新浪ViVi</FONT>]</A> 
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!--<iframe src=http://www.chinaunix.net/other/frame_announce.html width="95%" height=15 frameborder=0 border=0 marginwidth=0 marginheight=0 scrolling=no> </iframe>-->
<TABLE class=forumline style="WORD-BREAK: break-all; BORDER-COLLAPSE: collapse" 
cellSpacing=1 cellPadding=3 width="95%" align=center border=0>
  <TBODY>
  <TR align=right>
    <TD class=catHead colSpan=2 height=28><SPAN class=nav><A class=nav 
      href="http://bbs.chinaunix.net/forum/viewtopic.php?t=534829&amp;show_type=&amp;view=previous">阅读上一个主题</A> 
      :: <A class=nav 
      href="http://bbs.chinaunix.net/forum/viewtopic.php?t=534829&amp;show_type=&amp;view=next">阅读下一个主题</A> 
      &nbsp;</SPAN></TD></TR>
  <TR>
    <TH class=thLeft noWrap width=150 height=26>作者</TH>
    <TH class=thRight noWrap>留言</TH></TR>
  <TR>
    <TD class=row1 vAlign=top align=left width=150><SPAN class=name><A 
      name=3533040></A><B>FH&nbsp;&nbsp; </B>&nbsp;&nbsp; </SPAN><BR><SPAN 
      class=postdetails>★荣誉会员★<BR><BR><IMG alt="" 
      src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/Alfred.gif" 
      onload="javascript:if(this.width>150)this.width=140" border=0><BR>注册时间: 
      2004-01-25<BR>最后登录: 2005-04-22<BR>帖子总数: <A 
      href="http://www.chinaunix.net/cgi-bin/forum/search.cgi?mode=all_author&amp;key=FH&amp;u=128617" 
      target=_blank>2212</A><BR>精华帖子: 0<BR>原创精华: <A 
      href="http://www.chinaunix.net/cgi-bin/forum/search.cgi?forum_num=-1&amp;mode=author_name&amp;key=FH&amp;u=128617" 
      target=_blank>1</A><BR><BR>BLOG主页:<A 
      href="http://blog.chinaunix.net/index.php?blogId=509" 
      target=_blank>进入</A><BR>在线状态: ...保密...<BR></SPAN></TD>
    <TD class=row1 vAlign=top width="100%" height=28>
      <TABLE cellSpacing=0 cellPadding=0 width="95%" border=0>
        <TBODY>
        <TR>
          <TD width="100%"><A 
            href="http://bbs.chinaunix.net/forum//forum/viewtopic.php?show_type=&amp;p=3533040#3533040"><IMG 
            title=帖子总数 height=9 alt=帖子总数 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_minipost.gif" 
            width=12 border=0></A><SPAN class=postdetails>发表于: 2005-04-22 
            22:45<SPAN class=gen>&nbsp;</SPAN>&nbsp; &nbsp;发表主题: 一套完整的makefile样板 
            </SPAN></TD>
          <TD vAlign=top noWrap align=right><A class=nav 
            href="http://bbs.chinaunix.net/forum/tuijian.php?pid=3533040&amp;fid=23" 
            target=_blank><IMG alt=推荐此帖为精华,以便版主设置 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/tuijian.gif" 
            border=0></A> <A class=nav 
            href="http://bbs.chinaunix.net/forum/jubao.php?pid=3533040&amp;fid=23" 
            target=_blank><IMG alt=举报此帖,以便版主处理 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/jubao.gif" border=0></A> 
            <A 
            href="http://bbs.chinaunix.net/forum/posting.php?show_type=&amp;mode=quote&amp;p=3533040"><IMG 
            title=引用并回复 alt=引用并回复 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_quote.gif" 
            border=0></A> </TD></TR>
        <TR>
          <TD colSpan=2>
            <HR>
          </TD></TR>
        <TR>
          <TD colSpan=2><SPAN 
            class=postbody>近来,经常看到有人询问makefile的写法,这里根据本人经验给出一个应用系统的完整例子,便于各位参考。 
            <BR><SPAN style="FONT-WEIGHT: bold">应用系统的目录结构如下:</SPAN> <BR></SPAN>
            <TABLE cellSpacing=1 cellPadding=3 width="90%" align=center 
border=0>
              <TBODY>
              <TR>
                <TD><SPAN class=genmed><B>代码:</B></SPAN></TD></TR>
              <TR>
                <TD class=code><BR>~/bin&nbsp; &nbsp;可执行程序目录 <BR>~/etc&nbsp; 
                  &nbsp;配置文件目录 <BR>~/inc&nbsp; &nbsp;头文件目录 <BR>~/lib&nbsp; 
                  &nbsp;函数库文件目录 <BR>~/log&nbsp; &nbsp;日志文件目录 <BR>~/src&nbsp; 
                  &nbsp;源程序文件目录 <BR>~/src/lib&nbsp; &nbsp;函数库源程序目录 
                  <BR>~/src/lib/LIB_1&nbsp; &nbsp;函数库libLIB_1源程序目录 
                  <BR>~/src/APP_A&nbsp; &nbsp;子系统APP_A源程序目录 
                  <BR>~/src/APP_A/mod_a&nbsp; &nbsp;子系统APP_A模块mod_a源程序目录 
                  <BR>~/.profile <BR>~/makefile <BR></TD></TR></TBODY></TABLE><SPAN 
            class=postbody><BR><SPAN 
            style="FONT-WEIGHT: bold">~/makefile文件内容如下:</SPAN> <BR></SPAN>
            <TABLE cellSpacing=1 cellPadding=3 width="90%" align=center 
border=0>
              <TBODY>
              <TR>
                <TD><SPAN class=genmed><B>代码:</B></SPAN></TD></TR>
              <TR>
                <TD class=code><BR>all: <BR>&nbsp; &nbsp;@MakeSubDir() \ 
                  <BR>&nbsp; &nbsp;{ \ <BR>&nbsp; &nbsp;&nbsp; &nbsp;for DIR in 
                  `ls|grep 'lib';ls|grep -v 'lib'`; do \ <BR>&nbsp; &nbsp;&nbsp; 
                  &nbsp;&nbsp; &nbsp;if [ -d ${DIR} ]; then \ <BR>&nbsp; 
                  &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;cd ${DIR}; \ 
                  <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
                  &nbsp;MakeSubDir; \ <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
                  &nbsp;&nbsp; &nbsp;if [ -f makefile -o -f Makefile ]; then \ 
                  <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
                  &nbsp;echo ""; \ <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
                  &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;pwd; \ <BR>&nbsp; &nbsp;&nbsp; 
                  &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;make all; \ 
                  <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fi; \ 
                  <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;cd ..; 
                  \ <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fi; \ <BR>&nbsp; 
                  &nbsp;&nbsp; &nbsp;done; \ <BR>&nbsp; &nbsp;}; \ <BR>&nbsp; 
                  &nbsp;MakeSubDir <BR><BR>tar: <BR>&nbsp; &nbsp;@tar -cf `date 
                  +%Y%m%d-%H%M%S`.tar .profile `ls|grep -v '.tar'` 
              <BR></TD></TR></TBODY></TABLE><SPAN class=postbody><BR><SPAN 
            style="FONT-WEIGHT: bold">~/src/lib/LIB_1/makefile文件内容如下:</SPAN> 
            <BR></SPAN>
            <TABLE cellSpacing=1 cellPadding=3 width="90%" align=center 
border=0>
              <TBODY>
              <TR>
                <TD><SPAN class=genmed><B>代码:</B></SPAN></TD></TR>
              <TR>
                <TD class=code><BR>ALL:&nbsp; &nbsp;INFO all 
                  <BR><BR>BASEDIR&nbsp; &nbsp;= $(HOME) <BR>INC&nbsp; &nbsp;= 
                  $(BASEDIR)/inc <BR>LIB&nbsp; &nbsp;= $(BASEDIR)/lib 
                  <BR><BR>PRDNAME&nbsp; &nbsp;= $(LIB)/libLIB_1 
                  <BR><BR>PRODUCT&nbsp; &nbsp;= $(PRDNAME).a $(PRDNAME).so 
                  <BR><BR>OBJS&nbsp; &nbsp;= LIB_1_f1.o LIB_1_f2.o 
                  <BR><BR>AR&nbsp; &nbsp;= ar &lt;特定平台ar可选参数&gt; <BR>CC&nbsp; 
                  &nbsp;= cc &lt;特定平台cc可选参数&gt; <BR><BR>all:&nbsp; 
                  &nbsp;$(PRODUCT) <BR><BR>$(PRDNAME).a:&nbsp; &nbsp;$(OBJS) 
                  <BR>&nbsp; &nbsp;@echo " &nbsp;Making $@ ..." <BR>&nbsp; 
                  &nbsp;@$(AR) -r $@ $(OBJS) <BR><BR>$(PRDNAME).so:&nbsp; 
                  &nbsp;$(OBJS) <BR>&nbsp; &nbsp;@echo " &nbsp;Making $@ ..." 
                  <BR>&nbsp; &nbsp;@$(CC) -G -o $@ $(OBJS) <BR><BR>.c.o:&nbsp; 
                  &nbsp;*.h $(INC)/*.h <BR>&nbsp; &nbsp;@echo " &nbsp;Compiling 
                  $&lt; ..." <BR>&nbsp; &nbsp;@$(CC) -c -I$(INC) $&lt; 
                  <BR><BR>INFO: <BR>&nbsp; &nbsp;@echo " &nbsp;make all - same 
                  with 'make' except this message" <BR>&nbsp; &nbsp;@echo " 
                  &nbsp;make clear - remove object files" <BR>&nbsp; &nbsp;@echo 
                  " &nbsp;make clean - remove all object and target files" 
                  <BR>&nbsp; &nbsp;@echo "" <BR><BR>clear:&nbsp; &nbsp;FORCE 
                  <BR>&nbsp; &nbsp;@rm -f *.o <BR><BR>clean:&nbsp; &nbsp;FORCE 
                  clear <BR>&nbsp; &nbsp;@rm -f $(PRODUCT) <BR><BR>FORCE: 
              <BR></TD></TR></TBODY></TABLE><SPAN class=postbody><BR><SPAN 
            style="FONT-WEIGHT: bold">~/src/APP_A/mod_a/makefile文件内容如下:</SPAN> 
            <BR></SPAN>
            <TABLE cellSpacing=1 cellPadding=3 width="90%" align=center 
border=0>
              <TBODY>
              <TR>
                <TD><SPAN class=genmed><B>代码:</B></SPAN></TD></TR>
              <TR>
                <TD class=code><BR>ALL:&nbsp; &nbsp;INFO all 
                  <BR><BR>BASEDIR&nbsp; &nbsp;= $(HOME) <BR>INC&nbsp; &nbsp;= 
                  $(BASEDIR)/inc <BR>LIB&nbsp; &nbsp;= $(BASEDIR)/lib 
                  <BR>BIN&nbsp; &nbsp;= $(BASEDIR)/bin <BR><BR>MODULE&nbsp; 
                  &nbsp;= $(BIN)/APP_A_mod_a <BR>TESTER&nbsp; &nbsp;= 
                  APP_A_mod_a_t <BR>PRODUCT&nbsp; &nbsp;= $(SERVER) $(TESTER) 
                  <BR><BR>CC&nbsp; &nbsp;= cc &lt;特定平台cc可选参数&gt; 
                  <BR><BR>all:&nbsp; &nbsp;$(PRODUCT) <BR><BR>$(MODULE):&nbsp; 
                  &nbsp;APP_A_mod_a.o <BR>&nbsp; &nbsp;@echo " &nbsp;Making $@ 
                  ..." <BR>&nbsp; &nbsp;@$(CC) $? -o$@ -L$(LIB) -lLIB_1 
                  <BR><BR>APP_A_mod_a_t:&nbsp; &nbsp;APP_A_mod_a_t.o <BR>&nbsp; 
                  &nbsp;@echo " &nbsp;Making $@ ..." <BR>&nbsp; &nbsp;@$(CC) $? 
                  -o$@ -L$(LIB) -lLIB_1 <BR><BR>.c.o:&nbsp; &nbsp;*.h $(INC)/*.h 
                  <BR>&nbsp; &nbsp;@echo " &nbsp;Compiling $&lt; ..." <BR>&nbsp; 
                  &nbsp;@$(CC) -c -I$(INC) $&lt; <BR><BR>INFO: <BR>&nbsp; 
                  &nbsp;@echo " &nbsp;make all - same with 'make' except this 
                  message" <BR>&nbsp; &nbsp;@echo " &nbsp;make clear - remove 
                  object files" <BR>&nbsp; &nbsp;@echo " &nbsp;make clean - 
                  remove all object and target files" <BR>&nbsp; &nbsp;@echo "" 
                  <BR><BR>clear:&nbsp; &nbsp;FORCE <BR>&nbsp; &nbsp;@rm -f *.o 
                  <BR><BR>clean:&nbsp; &nbsp;FORCE clear <BR>&nbsp; &nbsp;@rm -f 
                  $(PRODUCT) <BR><BR>FORCE: <BR></TD></TR></TBODY></TABLE><SPAN 
            class=postbody><BR><SPAN style="FONT-WEIGHT: bold">使用方法:</SPAN> 
            <BR>1.在主目录下使用'make'命令能够首先建立函数库,然后建立所有目标。 <BR>2.在主目录下使用'make 
            tar'命令能够对整个系统进行打包,生成的文件以日期和时间命名。 
            <BR>3.在最下层子目录中直接使用'make'命令会首先给出用法提示,然后建立本目录所有目标。 
            <BR>4.在最下层子目录中使用'make all'命令不出现提示信息,直接建立本目录所有目标。 
            <BR>5.在最下层子目录中使用'make clear'命令可以清除本目录的所有.o文件。 <BR>6.在最下层子目录中使用'make 
            clean'命令可以清除本目录的所有.o文件和建立的所有目标。</SPAN><SPAN 
            class=postbody><BR><BR><BR>_________________<BR>精炼和高效是我追求的完美!</SPAN><SPAN 
            class=gensmall></SPAN> </TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD class=row1 vAlign=center align=left width=150><SPAN class=nav><A 
      class=nav 
      href="http://bbs.chinaunix.net/forum/viewtopic.php?t=534829#top">返回页首</A></SPAN></TD>
    <TD class=row1 vAlign=bottom noWrap width="100%" height=28>
      <TABLE height=18 cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD vAlign=center noWrap align=left><A 
            href="http://bbs.chinaunix.net/forum/profile.php?mode=viewprofile&amp;u=128617"><IMG 
            title=阅览会员资料 alt=阅览会员资料 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_profile.gif" 
            border=0></A> <A 
            href="http://bbs.chinaunix.net/forum/privmsg.php?mode=post&amp;u=128617"><IMG 
            title=发送站内信件 alt=发送站内信件 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_pm.gif" 
            border=0></A> <SPAN class=gensmall><A 
            href="http://casmb.surfgold.com.cn/Check_Select.asp?select_name=bright_linux" 
            target=_blank><FONT color=red>为您提供数据备份,注册有奖</FONT></A><BR><A 
            href="http://www.chinaunix.net/cgi-bin/counturl2.cgi?id=hp_topic&amp;url=http://h50055.www5.hp.com/hpsmb/cn/chi/club/cn/NetPrinter_forum/landingpage.asp?jumpid=ex_hphqapcn_CNNetWorkForum/CN505032290051/chinaunix" 
            target=_blank><FONT color=red>网络打印论坛新版开张,发帖有礼,版主热募中! 
            </FONT></A></SPAN></TD>
          <TD vAlign=center align=right><!---广告begin-------><SPAN 
            class=gensmall><A 
            href="http://www.pcworld.com.cn/bbs/reg/reg_edm.html" 
            target=_blank><FONT color=red><B>恭贺PC 
            WORLD中国网正式开通!有奖注册!</B></FONT></A> <A 
            href="http://www.chinaunix.net/coop/sina/hr7.html" 
            target=_blank><FONT color=blue>新浪网诚聘C++软件工程师</FONT></A><BR><A 
            href="http://www.now.net.cn/" target=_blank><FONT color=red><B>JSP 
            PHP ASP.NET高速主机,带CDN镜象加速</B></FONT></A> <!---<a href=http://ad.ccw.com.cn/adClick.asp?adID=47&url=http%3A%2F%2Fgceclub%2Esun%2Ecom%2Ecn%2Fevent%2Fsubscription%2Findex%2Ehtml target=_blank><font color=red>免费试用 Sun Java Studio Creator(中文版)</font></a> |  ---></SPAN><!---广告begin-------></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD class=spaceRow colSpan=2 height=1><IMG height=1 alt="" 
      src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/spacer.gif" width=1></TD></TR>
  <TR>
    <TD class=row2 vAlign=top align=left width=150><SPAN class=name><A 
      name=3533065></A><B>rootclown&nbsp;&nbsp; <IMG title=性别:帅哥 alt=性别:帅哥 
      src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_minigender_male.gif" 
      border=0></B>&nbsp;&nbsp; </SPAN><BR><SPAN 
      class=postdetails>骑士<BR><BR><BR><IMG title=骑士 alt=骑士 
      src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/pips2.gif" border=0><BR>注册时间: 
      2003-11-20<BR>最后登录: 2005-04-22<BR>帖子总数: <A 
      href="http://www.chinaunix.net/cgi-bin/forum/search.cgi?mode=all_author&amp;key=rootclown&amp;u=113552" 
      target=_blank>78</A><BR>精华帖子: 0<BR>原创精华: 0<BR>来自: bei jing<BR>BLOG主页:<A 
      href="http://blog.chinaunix.net/index.php?blogId=5219" 
      target=_blank>进入</A><BR>在线状态: ...<FONT 
      color=#999999>离线</FONT>...<BR></SPAN></TD>
    <TD class=row2 vAlign=top width="100%" height=28>
      <TABLE cellSpacing=0 cellPadding=0 width="95%" border=0>
        <TBODY>
        <TR>
          <TD width="100%"><A 
            href="http://bbs.chinaunix.net/forum//forum/viewtopic.php?show_type=&amp;p=3533065#3533065"><IMG 
            title=帖子总数 height=9 alt=帖子总数 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_minipost.gif" 
            width=12 border=0></A><SPAN class=postdetails>发表于: 2005-04-22 
            22:57<SPAN class=gen>&nbsp;</SPAN>&nbsp; &nbsp;发表主题: </SPAN></TD>
          <TD vAlign=top noWrap align=right><A class=nav 
            href="http://bbs.chinaunix.net/forum/tuijian.php?pid=3533065&amp;fid=23" 
            target=_blank><IMG alt=推荐此帖为精华,以便版主设置 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/tuijian.gif" 
            border=0></A> <A class=nav 
            href="http://bbs.chinaunix.net/forum/jubao.php?pid=3533065&amp;fid=23" 
            target=_blank><IMG alt=举报此帖,以便版主处理 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/jubao.gif" border=0></A> 
            <A 
            href="http://bbs.chinaunix.net/forum/posting.php?show_type=&amp;mode=quote&amp;p=3533065"><IMG 
            title=引用并回复 alt=引用并回复 
            src="一套完整的makefile样板 - C-C++讨论区-原创精华帖.files/icon_quote.gif" 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -