|
|
| damn these make files |
|
Thomas Fjellstrom
Member #476
June 2000
|
Quote: and I typed exactly what you guys told me to.
Quote: do Unix users understand "beginners" Sure. Thats what Windows is for. If you don't ever need anything more complex than that, thats entirely fine. Now, If you do need something "more", try, try, try again. Took me a fair bit to get the idea behind makefiles... Basically you have things you're making. And usually you have to do them in some kind of order, ie compile first, link last. the compiling part would be said to be a "dependency" of the link stage. In makefiles, the "target" is the name before the ':', the dependencies of that target are listed after the ':'. Now usually those dependencies have thier own targets. Some people just list them all seperatly... I prefer to use a little trick to get "make" to handle certian "types"... myprog : $(MY_OBJECTFILES) $(CC) $(LDFLAGS) $(MY_OBJECTFILES) -o myprog # see, this following bit tells make to handle all requested targets that match the "%.o" pattern to be handled by this "meta" target. So It say that if say a "blah.o" file is requested It'll depend on "blah.c" and run $(CC) $(CFLAGS) -o blah.o -c blah.c %.o : %.c $(CC) $(CFLAGS) -o $@ -c $< Hope that helps a little... -- |
|
23yrold3yrold
Member #1,134
March 2001
|
I understand the basics. But lines like this: $(CC) $(CFLAGS) -o $@ -c $< Just look like nonsense. This (from my own makefile): TEMP = $(wildcard *.cpp) FILES = $(if $(TEMP), $(TEMP), $(error No source code found!)) OBJS = $(addsuffix .o, $(basename $(FILES))) Also confuses the puss out of me. I more or less understand that basic rules/dependancy stuff, but if I take a peek in Allegro's makefiles, there's some scary stuff in there ... EDIT: BTW, when you say "simple", I think "higher-level" is more appropriate. I remember setting compiler flags in RHIDE long before I knew what a makefile was, because you can call them up in a window and check off the ones you want. It's not a whole lot better since you still need to know what the flags mean, but if RH had put a short description after each one ((-s) strips out debugging information) then it would have been perfect. No need to know makefile syntax; just click and go. Now that's what I'm talkin' about! -- |
|
X-G
Member #856
December 2000
|
Just a question - are the makefiles to blame, or the people who wrote shoddy makefiles and then failed to document what they did? -- |
|
Korval
Member #1,538
September 2001
|
Quote: What if MSVC natively supported "unix" style Makefiles? Then you would love them. Um, no. I have the ability to see the bad in something regardless of whether or not I use the product frequently. Also, VC++ would not be an actual development environment if it exposed the makefile directly to you. I, personally, don't care whether VC++ uses a .dsp or a makefile internally behind the scenes. As long as I don't have to interact with it, it could be using a FORTRAN script to compile my code for all I care. Quote: What good would Korvals MSVC libraries do for a Java developer? Or a MacOS X developer? Or a UNIX developer? All of which, I believe are still being sold and used in this modern year of 2003. Um, I don't see what good a C/C++ library is to a Java developer. As for MacOS X developers... they deserve pity, not libraries. As for Unix developers, they were the start of the whole makefile crap to begin with. My point is that, if you're going to give out a library that is, ostensibly, for multiple platforms, then actually give it out for multiple platforms. Don't give it out for make environments, then tell me that, "Oh, I've certified that it compiles under VC++." For example, any library I release will come with VC++ compiled binaries, and a .dsp project. However, I also don't advertise that it is a Linux (or non-VC++) library either; if they can get it up and running with their OS/dev environment of choice, good for them. Quote: That was a simple example.. Some "find" tools will do something like that.. But I mean in the general sense of the command, the idea that you can tie various programs together to do a job, see instead of printing the files, I could have added them to a tar archive, emailed them with "sendmail", made a html index of all of them, etc... Which, of course, matters little. What's the point of being able to type in a single command line that does something powerful? Is it somehow better than doing it in multiple lines? Or with the equivalent operations in multiple programs? It may be faster, but consider what it took to write this command line: Quote: ls -Rf . | grep text - | perl -e 'for ( <STDIN> ) { chomp; if(/(.*):$/) { $d = $1; } else { print "$d/$_\n";} }' First, it took a firm understanding of the concept of "grep". That, in and of itself, requires a good 2 weeks of study to comprehend. Then, you have to understand Perl, which is hardly the easiest scripting language to get a grasp on. Finally, you have to understand the concept of command-line piping. While some may be impressed by that, I am not among them. Demonstraiting knowledge on esotheric concepts like Grep, Perl, etc, is not particularly impressive, or even useful. The fact that you merely can do something powerful in a single line doesn't mean that this is truly meaningful in any way. If you want to fairly and honestly evaluate tools, here is how to do it: 1: Does it perform the function required of them? Otherwise, it is a broken tool. Do makefiles perform the function? Yes. That's good. Do they require specialized knowledge that is, outside of using makefiles, useless? Yes. You have to know how to write the internals of a makefile. As such, you must understand them. That's bad. Are makefiles difficult to use? Yes. For a Win32 machine, you have to go find UNIX tools and compilers (which you are never going to use for anything else). That's bad. The resources for a makefile, outside of the 100MB of Unix tools, are not particularly onerous. Makefiles, and that style of development, is free. The only advantage makefiles have over VC++, and other integrated development environments, is cost. Consider that there is no feature that makefiles offer (a real feature towards compiling a C/C++ program) that VC++, and many other IDE's, do not also offer. If you have special, non-compiler, build steps, you can set these up. Remember, the goal is to compile a C/C++ project, not to learn a new language. If your tool requires learning a new language to do something that is offerred elsewhere in a much simpler, but no less powerful, fashion, then perhaps you should use that instead. |
|
Thomas Fjellstrom
Member #476
June 2000
|
Are you daft? At least 23 doesn't pretend he knows all and sees all One, my makefiles DO NOT require any unix tools other than gcc and make. Two fairly common tools when developing with mingw. Quote: First, it took a firm understanding of the concept of "grep". That, in and of itself, requires a good 2 weeks of study to comprehend Now you're just trying to make me laugh arn't you? I don't understand grep. Never have, other than the fact that it looks for text in files. '-' is the standard sign for "read from STDIN". Quote: Finally, you have to understand the concept of command-line piping. Quote: The fact that you merely can do something powerful in a single line doesn't mean that this is truly meaningful in any way. Quote: Is it somehow better than doing it in multiple lines? Or with the equivalent operations in multiple programs?
I could have put it in a .sh file, and directed everything to temp files. Would that have made you happy? It took a few seconds to write. I challenge you to do something like that in a similar amount of time. WITHOUT your oh so hated unix tools. Quote: Do they require specialized knowledge that is, outside of using makefiles, useless? No. Quote: Which, of course, matters little. Its all about time and efficiency. I can do things faster and better with my unix tools, than you can with your gui. Though SOME times thats not so true, but I really REALLY doubt those guis take less time to learn than my unix tools or their common arguments. Compare say a VCD or DVD authoring toolkit that supports full menus, hotspots, transitions, etc... I would probably choose <gasp> a command line tool (which just happens to be ported to linux.. started out on windows.) that reads in a XML format definition of the layout and contents, then builds you image. Last time I got a chance to use a GUI for a similar use, was last year sometime, and it was using an old commercial tool that had been discontinued and released for free (It was a Win16 app), It was utterly more confusing and complex than the XML format for the command line tool. Other GUI programs to do this kind of thing, I don't have access too. They cost up wards of $2000. Thank you but no thank you. (I could live for a year on that...) In my humble opinion, this is not really about makefiles is it? You just can't understand something, so you say "To he11 with it!" and bash it every chance you get. You do realize that MSVC has its own make? The syntax is eerily familiar. and guess what? It doesn't require unix tools. Please try not to write stuff when your in that "I like to listen to myself" mood. Its about as annoying as I am. edit: Quote: I understand the basics. But lines like this: $(CC) $(CFLAGS) -o $@ -c $< RTFM. Really. $(BLAH) things are variables. and the other two are also variables but they are "special" and very documented. Along with variables. I'm sure you know how variables work. Quote: TEMP = $(wildcard *.cpp)
And you say you're a programmer edit: One thing that may help... The lines/commands in makefiles are evaluated when they are executed... so my CC line would probably get turned into "gcc -W -Wall -gstabs+ -o file.o -c file.c" then executed. edit: Longest post evar. -- |
|
Karadoc ~~
Member #2,749
September 2002
|
I'm not into these long post; I normally just scan through them. So sorry in advance if what I'm saying is already covered. Korval said: Also, VC++ would not be an actual development environment if it exposed the makefile directly to you.
HA! Heaven forbid VC++ makes you look at a makefile! Quote: Do they require specialized knowledge that is, outside of using makefiles, useless? Yes. You have to know how to write the internals of a makefile. As such, you must understand them. That's bad.
You need 'Specialized knowledge' like that for practically anything you do! C++ programming itself requires a LOT of specialized knowledge that is useless outside of C++ programming. Quote: Are makefiles difficult to use? Yes. For a Win32 machine, you have to go find UNIX tools and compilers (which you are never going to use for anything else). That's bad.
For the basics, makefiles very simple to use. A programmer can be taught to use a makefile in less than 5 mins. However, if you want them to do more complicated things it takes longer. Quote: The resources for a makefile, outside of the 100MB of Unix tools, are not particularly onerous. Try 6MB. As compared to VC++ 100MB min. --- --- TF said: One, my makefiles DO NOT require any unix tools other than gcc and make. Two fairly common tools when developing with mingw. Mine don't either. --- ----------- |
|
Bob
Free Market Evangelist
September 2000
|
Quote: and it will be the fundamental reason why it fails to really catch on with the home user. The common way OSM libraries are distributed: How many home users do you know that need to install (even occasionally) programming libraries? If the libs don't come with the apps's binary package, then it's a problem with the app, not the library. Now that that's said, having an easy-to-use compile/install program/script/whatever to make these less painfull. -- |
|
Evert
Member #794
November 2000
|
Quote: I have the ability to see the bad in something regardless of whether or not I use the product frequently. Do you have any idea how condescending and arrogant that sounds? Quote: As for Unix developers, they were the start of the whole makefile crap to begin with. Perhaps you'd also like to switch to a different programming language than C? C was developped alongside UNIX, you know. Quote: My point is that, if you're going to give out a library that is, ostensibly, for multiple platforms, then actually give it out for multiple platforms. How am I going to release something with an MSVC build environment if I don't have MSVC? I can release binaries of my games for Windows (and I do) compiled with gcc, which is good enough for me. Quote: What's the point of being able to type in a single command line that does something powerful? Is it somehow better than doing it in multiple lines? Or with the equivalent operations in multiple programs? Actually, it is. Doing a batch job from the commandline and combining multiple commands into one makes it easier to go on doing other things. I have yet to see a GUI that offers the flexibility of the commandline. If you don't need that flexibility, fine, you don't have to use the commandline. If you do, it's there, ready to use. Quote: First, it took a firm understanding of the concept of "grep". That, in and of itself, requires a good 2 weeks of study to comprehend It takes you two weeks to understand the concept of a program that searches for strings in files? Wow! Quote: As such, you must understand them. That's bad. I'll be sure to quote you on that. Quote: Are makefiles difficult to use? Yes. For a Win32 machine, you have to go find UNIX tools and compilers Not really. Borland compilers came with their own version of make (which was rather crippled and unusable, but that's beside the point) and I'm pretty sure at least older versions of Microsoft's compilers came with a version of make too. Quote: One, my makefiles DO NOT require any unix tools other than gcc and make. Two fairly common tools when developing with mingw.
Mine, unfortunately, do, at least for the more exotic commands `make depend' and `make clean'. At least the latter could use del instead of rm on Windows, though, but I lack motivation to fix it for now @IronBob: if you still need the UNIX tools, do a google on `fileutils for win32' - it turns up a number of download sites. |
|
spellcaster
Member #1,493
September 2001
|
The idea behind makefiles is what is used in every ide. Using human readable plain text is also considered good style. $@ - name of the current target ( $? - all dependent files which are out-of-date. $< - the current source file And even this can be remembered easily. The AT sign tells you where you are (what you want to build). What do you need to recompile $? The current input file (the file that is piped into the command is stored in $< So, while these three symbols are cryptic, a coder should have no problems to remember their meaning Regarding commandline tools: Depends on the job. For some jobs they are great, for others a good graphical shell is better suited. As always, use whatever is suited to get the job done. And as always understand what you use. -- |
|
23yrold3yrold
Member #1,134
March 2001
|
Quote: RTFM. Really. Grrr; I did! Quote: $(BLAH) things are variables. and the other two are also variables but they are "special" and very documented. Along with variables. I'm sure you know how variables work. I don't recall seeing anything on them. I believe I found the makefile docs assumed too much of my knowledge. Spellcaster's post up there makes more sense, though that still seems unnecessarily confusing Quote: "TEMP", "FILES", and "OBJS" are variables. "wildcard", "if", "error", and "addsuffix" are functions. Which are ALSO very documented. If you say so ... -- |
|
spellcaster
Member #1,493
September 2001
|
I must admit, I'm puzzled. This whole argument makes no sense at all. Let's face it: make is simple. It contains only a few rules, some keywords and that's it. And yes, you have to learn it. When in doubt, try to google for "make tutorial" and start reading. And you don't have to use make. There're other tools as well which try to do the same job. Take a look at ANTLR for example. Gah. Who cares? -- |
|
Thomas Fjellstrom
Member #476
June 2000
|
info make said:
Make The GNU `make' utility automatically determines which pieces of a large program need to be recompiled, and issues the commands to recompile them. This edition of the `GNU Make Manual', last updated 08 July 2002, documents GNU `make' Version 3.80. This manual describes `make' and contains the following chapters:
Just a little part of the first info page. (comes in html too...) Heres the Varaibles section: Quote:
How to Use Variables A "variable" is a name defined in a makefile to represent a string Variables and functions in all parts of a makefile are expanded when Variables can represent lists of file names, options to pass to A variable name may be any sequence of characters not containing `:', Variable names are case-sensitive. The names `foo', `FOO', and It is traditional to use upper case letters in variable names, but we A few variables have names that are a single punctuation character or
I'd quote the entire info file, but its quite large, and is even installed commpressed. -- |
|
Bruce Perry
Member #270
April 2000
|
What a crazy argument this has been. I didn't read most of it. All I'll say is Korval's rant isn't against Makefiles. It's against all the people who think Linux and possibly other Unix-based systems are the only real operating systems. Inphernic phrased it much better. Oh, and Korval, what right do you have to flame free software projects if you haven't paid them for their work? Hmm? -- |
|
Korval
Member #1,538
September 2001
|
The point (that, I admit, I danced around) that I'm trying to make is that makefiles are not the beginning and end of compiling C/C++ code. Nowadays, even forgetting IDE's, there could be much friendlier compilation utilities than makefiles. For example, you can write build utilities as Perl/Python scripts. Or, you can make a Lua-based tool for building. Or, you could make up a language that is far cleaner and more C/C++ like (and therefore use current knowledge, as opposed to new knowledge that is, fundamentally, useless outside of make) than make. If you take the Perl or Lua approach, you're getting people to learn something that is actually useful, rather than simply forcing random, ultimately fruitless, knowledge down people's throats. To say that learning make is like learning C++ is absolutely wrong. After I learn make, all I can use it for is writing makefiles. After I learn C++, I can use it for writing any program, including make utilities. Ergo, learning C++ is far more useful than learning make. Also, consider that learning make is, typically, done as a means to an end (that end being compiling C/C++). Whereas learning C/C++ is the means to doing low-level programming. While there are a number of alternatives, both possible and currently existing, to make, there are no viable alternatives to C/C++ in the area of low-level, performance-based programming. As such, if you want to do this kind of programming, you have no choice but to learn C/C++. Whereas learning make is, ultimately, a dead-end knowledge. Quote: Besides, understanding how code is put together is important to most programmers, As it turns out, no. Most of the time, the standard configuration of a project is perfectly fine. Indeed, you can get pretty far in programming without altering any of the compilation switches in your development environment. Quote: For the basics, makefiles very simple to use. It depends on how you define "use". Being able to type, "make *" is only the beginning of being able to "use" makefiles. After all, if said person can't make a makefile on his own, what good is the make dev environment doing for him? He can't create new projects. Quote: You know what? If you think makefiles are so terrible, DON'T USE THEM! If people didn't force me to, I would happily do so. Quote: How am I going to release something with an MSVC build environment if I don't have MSVC? I can release binaries of my games for Windows (and I do) compiled with gcc, which is good enough for me. Libraries are different from games. Libraries need to be compiled for different compilers; games need to be compiled for OS's. As such, a Win32 .exe will always work on a Win32 machine, regardless of which compiler was used on it. By contrast, a '.a' file can't be used with VC++. Ergo, in order to use the library, I have to compile it myself. Quote: I'm pretty sure at least older versions of Microsoft's compilers came with a version of make too. Granted that it's Microsoft, it was called "nmake", and it used a different, probably more cryptic, form of the make language. Also, given that it requires VC++, they don't make you edit it by hand; which is the objectionable part. |
|
23yrold3yrold
Member #1,134
March 2001
|
Hey, how come no one commented on RHIDE's way of handling compiler flags? -- |
|
Bruce Perry
Member #270
April 2000
|
Aha! 23 admits that there's something good about DJGPP! -- |
|
BAF
Member #2,981
December 2002
|
this forum post has the most amount or larg posts i have seen |
|
23yrold3yrold
Member #1,134
March 2001
|
BD: Did I ever say otherwise? I cut my teeth on DJGPP, although I like MinGW better now ... -- |
|
MiquelFire
Member #3,110
January 2003
|
If only there was something as good as rhide on windows --- |
|
Bruce Perry
Member #270
April 2000
|
|
23yrold3yrold
Member #1,134
March 2001
|
Yeah; ditch it for MinGW. And can't you use RHIDE in a DOS box? That's what I did ... (what's so great about RHIDE over any other text editor anyway?) -- |
|
Mars
Member #971
February 2001
|
-- |
|
23yrold3yrold
Member #1,134
March 2001
|
I'll give you the first one (not that I ever used it -- |
|
Mars
Member #971
February 2001
|
It just worked really well. And it's hard to get the typical Borland DOS IDE look with your typical windows program. -- |
|
Thomas Fjellstrom
Member #476
June 2000
|
Quote: If people didn't force me to, I would happily do so. Who's forcing you to? Does it look like I have a gun to your head saying "Use them makefiles, or, or, I'll shoot your varmint head clean off!". All of that said, Learn Perl and use the MakeMaker module. Or aoutoconf. -- |
|
|
|