{"id":186,"date":"2008-08-03T00:52:28","date_gmt":"2008-08-03T08:52:28","guid":{"rendered":"http:\/\/wp.colliertech.org\/cj\/?p=186"},"modified":"2008-08-03T00:52:28","modified_gmt":"2008-08-03T08:52:28","slug":"writing-free-software-part-2-makefiles","status":"publish","type":"post","link":"https:\/\/wp.c9h.org\/cj\/?p=186","title":{"rendered":"Writing Free Software &#8211; Part 2: Makefiles"},"content":{"rendered":"<p>Okay, so now we know how to write hello world in C#, compile it and run it.  Next, let&#8217;s try to automate the build portion a bit.  It&#8217;s not going to be very much of an improvement to start out with; we&#8217;re just replacing the gmcs command with a make command.  But it&#8217;s laying a framework, so let&#8217;s ignore that for the time being.<\/p>\n<h3>Get back to the workspace<\/h3>\n<p><code><b>$<\/b> cd ~\/src\/greeting<\/code><\/p>\n<h3>Create a simple Makefile<\/h3>\n<pre style=\"margin: 0px; padding: 0px; color: grey;\">\r\n<b>$<\/b> cat &gt; Makefile\r\n# the first target is the one executed when no target is named\r\nall: Greeting.exe\r\n#don't do anything\r\n\r\n# running 'make clean' will execute this target\r\nclean:\r\n\trm Greeting.exe\r\n\r\n# running 'make Greeting.exe' will execute this target\r\nGreeting.exe: Greeting.cs\r\n# the same as gmcs -out:Greeting.exe Greeting.cs\r\n\tgmcs -out:$@ $^\r\n<\/pre>\n<h3>Test the Makefile<\/h3>\n<pre style=\"margin: 0px; padding: 0px; color: grey;\">\r\n<b>$<\/b> make\r\ngmcs -out:Greeting.exe Greeting.cs\r\n<b>$<\/b> make clean\r\nrm Greeting.exe\r\n<b>$<\/b> make Greeting.exe\r\ngmcs -out:Greeting.exe Greeting.cs\r\n<b>$<\/b> .\/Greeting.exe \r\nGreetings, World!\r\n<\/pre>\n<h3>Conclusion<\/h3>\n<p>So, there&#8217;s a quick overview of writing a Makefile.  If you want to learn all of the nitty-gritty details, I recommend reading the <a href=\"http:\/\/www.gnu.org\/software\/make\/manual\/html_node\/index.html\">manual<\/a> over at <a href=\"http:\/\/www.gnu.org\/\">gnu.org<\/a>.<\/p>\n<p>We&#8217;ll use these short lessons as building blocks for larger tasks, like creating a distribution using automake and autoconf.  Baby steps first :)<\/p>\n\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=cjamescollier\" class=\"twitter-share-button\">Tweet<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Okay, so now we know how to write hello world in C#, compile it and run it. Next, let&#8217;s try to automate the build portion a bit. It&#8217;s not going to be very much of an improvement to start out with; we&#8217;re just replacing the gmcs command with a make command. But it&#8217;s laying a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[180,38,188,190,79,7,166],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-autotools","category-c","category-cli","category-compiler","category-free-software","category-mono","category-software"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1YDIB-30","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186"}],"version-history":[{"count":0,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}