{"id":186,"date":"2013-11-16T11:34:11","date_gmt":"2013-11-16T11:34:11","guid":{"rendered":"http:\/\/finaldie.com\/blog\/?p=186"},"modified":"2013-11-16T11:34:11","modified_gmt":"2013-11-16T11:34:11","slug":"a-tip-of-writing-makefile-using","status":"publish","type":"post","link":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/","title":{"rendered":"A Tip of Writing Makefile &#8212; Using @"},"content":{"rendered":"<p>Ok, let&#8217;s talk about one of the tips for writing Makefile, the magic character &#8216;@&#8217;<\/p>\n<p>Before continue, let&#8217;s think about one thing: when you want to build a project, write a shell script or use the Make for building your project, which one would you prefer?<\/p>\n<p>Ok, I&#8217;ll choose Make, the reasons are:<\/p>\n<ol>\n<li>The shell script may contain the code which is specific for the target shell, for example: bash. So, if some users DO NOT use bash, the build process may stop unexpected. And the Make is stand alone, which can run on all UNIX like system, not depend on a specific shell environment.<\/li>\n<li>You need to handle all the building actions, for example, entry the target folder, return back to last folder, do the dependence actions before actual do the building actions, etc, and the Make has already supported all of the above.<\/li>\n<\/ol>\n<p>If you agree with me, follow me to the next step &#8212; Using &#8216;@&#8217; in your Makefile.<\/p>\n<p>Let&#8217;s take a look at a example <a href=\"https:\/\/gist.github.com\/finaldie\/7496785\/71795395e2477faf254912c9e4f45dcfb3719651\" target=\"_blank\">Makefile<\/a>:<\/p>\n<pre>all:\r\n\techo \"hello Makefile\"<\/pre>\n<p>When we run it, the output is:<\/p>\n<pre>bash $ make\r\necho \"hello Makefile\"\r\nhello Makefile<\/pre>\n<p>From above, we can see the original instructions are shown as well, they are useless and not beautiful, so let&#8217;s using &#8216;@&#8217; to rewrite the <a href=\"https:\/\/gist.github.com\/finaldie\/7496785\/78506ecc3f3e8013924b1cf0d3bd19449678c614\" target=\"_blank\">Makefile<\/a>:<\/p>\n<pre>all:\r\n\t@echo \"hello Makefile\"<\/pre>\n<p>And run it again:<\/p>\n<pre>bash $ make\r\nhello Makefile<\/pre>\n<p>From above, we can see the original instructions(echo xxx) have gone, it only shows the output of this command. So if you build a very large project, it may contain a lot of instructions, in this way you can using &#8216;@&#8217; to avoid outputing the command, only show its result.<\/p>\n<p>Reference: <a href=\"https:\/\/github.com\/finaldie\/final_dev_env\/blob\/master\/Makefile\" target=\"_blank\">https:\/\/github.com\/finaldie\/final_dev_env\/blob\/master\/Makefile<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok, let&#8217;s talk about one of the tips for writing Makefile, the magic character &#8216;@&#8217; Before continue, let&#8217;s think about one thing: when you want to build a project, write a shell script or use the Make for building your project, which one would you prefer? Ok, I&#8217;ll choose Make, the reasons are: The shell &#8230; <a title=\"A Tip of Writing Makefile &#8212; Using @\" class=\"read-more\" href=\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/\" aria-label=\"More on A Tip of Writing Makefile &#8212; Using @\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Tip of Writing Makefile - Using @ - Final Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Tip of Writing Makefile - Using @ - Final Blog\" \/>\n<meta property=\"og:description\" content=\"Ok, let&#8217;s talk about one of the tips for writing Makefile, the magic character &#8216;@&#8217; Before continue, let&#8217;s think about one thing: when you want to build a project, write a shell script or use the Make for building your project, which one would you prefer? Ok, I&#8217;ll choose Make, the reasons are: The shell ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/\" \/>\n<meta property=\"og:site_name\" content=\"Final Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hu.yuzhang\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-16T11:34:11+00:00\" \/>\n<meta name=\"author\" content=\"final\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:site\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"final\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/\",\"url\":\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/\",\"name\":\"A Tip of Writing Makefile - Using @ - Final Blog\",\"isPartOf\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#website\"},\"datePublished\":\"2013-11-16T11:34:11+00:00\",\"dateModified\":\"2013-11-16T11:34:11+00:00\",\"author\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\"},\"breadcrumb\":{\"@id\":\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/finaldie.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Tip of Writing Makefile &#8212; Using @\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/finaldie.com\/blog\/#website\",\"url\":\"https:\/\/finaldie.com\/blog\/\",\"name\":\"Final Blog\",\"description\":\"As simple as possible...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/finaldie.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\",\"name\":\"final\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"caption\":\"final\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Tip of Writing Makefile - Using @ - Final Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/","og_locale":"en_US","og_type":"article","og_title":"A Tip of Writing Makefile - Using @ - Final Blog","og_description":"Ok, let&#8217;s talk about one of the tips for writing Makefile, the magic character &#8216;@&#8217; Before continue, let&#8217;s think about one thing: when you want to build a project, write a shell script or use the Make for building your project, which one would you prefer? Ok, I&#8217;ll choose Make, the reasons are: The shell ... Read more","og_url":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/","og_site_name":"Final Blog","article_publisher":"https:\/\/www.facebook.com\/hu.yuzhang","article_published_time":"2013-11-16T11:34:11+00:00","author":"final","twitter_card":"summary_large_image","twitter_creator":"@hyzwowtools","twitter_site":"@hyzwowtools","twitter_misc":{"Written by":"final","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/","url":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/","name":"A Tip of Writing Makefile - Using @ - Final Blog","isPartOf":{"@id":"https:\/\/finaldie.com\/blog\/#website"},"datePublished":"2013-11-16T11:34:11+00:00","dateModified":"2013-11-16T11:34:11+00:00","author":{"@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3"},"breadcrumb":{"@id":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/finaldie.com\/blog\/a-tip-of-writing-makefile-using\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/finaldie.com\/blog\/"},{"@type":"ListItem","position":2,"name":"A Tip of Writing Makefile &#8212; Using @"}]},{"@type":"WebSite","@id":"https:\/\/finaldie.com\/blog\/#website","url":"https:\/\/finaldie.com\/blog\/","name":"Final Blog","description":"As simple as possible...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/finaldie.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3","name":"final","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","caption":"final"}}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/186"}],"collection":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":6,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/186\/revisions\/192"}],"wp:attachment":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}