{"id":12,"date":"2015-07-10T17:26:33","date_gmt":"2015-07-10T16:26:33","guid":{"rendered":"http:\/\/watchdiana.fail\/blog\/?p=12"},"modified":"2015-09-06T08:24:26","modified_gmt":"2015-09-06T07:24:26","slug":"learn-c-the-hard-way-making-and-making-and-gnumaking-and-throwing-things-across-the-room","status":"publish","type":"post","link":"https:\/\/watchdiana.fail\/blog\/2015\/07\/10\/learn-c-the-hard-way-making-and-making-and-gnumaking-and-throwing-things-across-the-room\/","title":{"rendered":"Learn C the Hard Way &#8211; Making and making and GNUmaking and throwing things across the room"},"content":{"rendered":"<p>Ex 2 of Learn C the Hard Way introduces how the makefile works. I&#8217;ve tried and failed to use this before, when trying to make an Arch package, so it&#8217;ll be good to work out how to do that. I&#8217;m not looking forward to failure, of course. This blog is basically a lie.<\/p>\n<pre>emacs Makefile<\/pre>\n<p>and I created the file as I was told to. My ex1 still has<\/p>\n<pre>#include&lt;stdio.h&gt;<\/pre>\n<p>in it, so it didn&#8217;t throw up any warnings, but when I commented that line out, it did. So my computer&#8217;s now in much the same state as what Zed was using to write, and I&#8217;m not getting my compiler screaming where his wasn&#8217;t. I did have to read down his page to a note saying that he had an unfixed ex1, but I was pretty sure that&#8217;s what had happened. I&#8217;d put that note up at the top.<\/p>\n<p>If I have two tabs instead of none, I don&#8217;t have any errors thrown. This is unlike Python&#8217;s unexpected indent. I wonder why it needs an indent at all, but I&#8217;m going to go with BECAUSE and ignore that for the moment.<\/p>\n<p>I had to go looking for more information for extra credit. According to<br \/>\n<a href=\"http:\/\/www.cs.colby.edu\/maxwell\/courses\/tutorials\/maketutor\">www.cs.colby.edu\/maxwell\/courses\/tutorials\/maketutor<\/a><br \/>\n&#8216;make&#8217; on its own will execute the first command in the file. So, my first attempt at putting all: ex1 into the file was after clean: and it didn&#8217;t work. My second attempt had line breaks, which was a guess at how to separate functions. I then went without separating functions at all. -o is a flag that should take one file name, and then the next bit of info should be separate by default. And whaddyaknow, this works. I have, readers may have noticed, a way of making things difficult for myself, mostly by assuming they will be more complicated than they actually are.<\/p>\n<p>I&#8217;ve decided I want to add -d to the makefile flags, if that does what I think it will. I like debugging info.<br \/>\n-o seems to mean we&#8217;ve got an old file, which is&#8230; odd. So it must be that the internal makefile syntax and the syntax we use to call it are different. It sort of makes sense.<\/p>\n<pre>man make<\/pre>\n<p>has a typo in it.<\/p>\n<pre>$ man cc<\/pre>\n<p>&#8211; no manual entry for cc. Yerwhat? I assume cc is the c compiler&#8230;<\/p>\n<pre>$ which cc<\/pre>\n<p>&#8211; \/usr\/bin\/cc . So I have it. I just don&#8217;t have a man page.<\/p>\n<pre>$ man -k '^cc$'<\/pre>\n<p>&#8211; nothing appropriate. This isn&#8217;t about an adult filter, either. This man page isn&#8217;t in my distro. So, over to<\/p>\n<pre>https:\/\/www.ma.utexas.edu\/cgi-bin\/man-cgi?cc+1<\/pre>\n<p>to get my fix. And aaaah. &#8216;gcc&#8217; exists.<\/p>\n<pre>$ man gcc<\/pre>\n<p>&#8211; Result! And wow, that&#8217;s complicated. I mean, that&#8217;s a whole set of stuff that I could do, with huge options lists I can&#8217;t (yet) hope to comprehend. But here I am failing in public, so let&#8217;s look at the last bit of the Extra Credit. I don&#8217;t know what &#8216;better&#8217; means in this case, for a future case of what a Makefile does.<\/p>\n<p>Online research &#8211; http:\/\/mrbook.org\/blog\/tutorials\/make\/ is helpful. It&#8217;s coming from the angle of people who can code and want to automate it, but it&#8217;s still explaining things simply. all: is a default. Anything after the colon is dependencies. I think this should be expanded and explained more. I&#8217;m not getting it from Zed&#8217;s explanation, and a couple of sentences there would have made the first part of the Extra Credit much easier to understand. I think I&#8217;m learning too far ahead of things, though. I went back and stopped ex1 from being a dependency of all: and that&#8217;s where I&#8217;m leaving it. I&#8217;ve cruised through a few examples, but there&#8217;s too much to hold in my head to stay here. I need to move on and see how it works.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ex 2 of Learn C the Hard Way introduces how the makefile works. I&#8217;ve tried and failed to use this before, when trying to make an Arch package, so it&#8217;ll be good to work out how to do that. I&#8217;m not looking forward to failure, of course. This blog is basically a lie. emacs Makefile [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[7,9,10,11,14,13],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-coding","tag-c","tag-coding","tag-fun-with-arch-linux","tag-learn-c-the-hard-way","tag-makefiles","tag-things-i-do-because-im-stubborn","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":1,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":190,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions\/190"}],"wp:attachment":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}