From boris at kolpackov.net Thu Jan 22 13:21:27 2004 From: boris at kolpackov.net (Boris Kolpackov) Date: Thu Jan 22 13:19:18 2004 Subject: GNU make: order-only prerequisites Message-ID: <20040122192127.GA3868@kolpackov.net> A new flavor of prerequisites was introduced in GNU make 3.80 called order-only prerequisites. They are essentially the same as normal ones except that an out-of-date order-only prerequisite does not render its targets out-of-date. I found this especially useful in the following context. Suppose I need to build 'foo.o' from 'foo.c' in $(out_dir). In the GNU make syntax such a desire can be expressed, for example, like this: $(out_dir)/foo.o : foo.c g++ -c $^ -o $@ So far so good. Now, suppose the directory $(out_dir) does not always exist and I need to create it before producing 'foo.o'. The first thing that comes to mind is to write something along these lines: $(out_dir) : mkdir -p $@ $(out_dir)/foo.o : $(out_dir) This doesn't work because now we have two prerequisites for '$(out_dir)/foo.o' and when the rule's command is executed, we get something like this (assuming $(out_dir) is /bar): gcc -c foo.c /bar -o /bar/foo.o Of course, we could filter out all prerequisites that don't have suffix '.c' but that wouldn't be a very elegant solution. A much cleaner approach would be to use an order-only prerequisite: $(out_dir)/foo.o : | $(out_dir) This will ensure that if $(out_dir) does not exist then it will be created before '$(out_dir)/foo.o' is built. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://www.kolpackov.net/pipermail/notes/attachments/20040122/1224e3f2/attachment.bin From boris at kolpackov.net Mon Jan 26 14:28:57 2004 From: boris at kolpackov.net (Boris Kolpackov) Date: Mon Jan 26 14:25:44 2004 Subject: c++: class-type enumeration Message-ID: <20040126202857.GA7467@kolpackov.net> Good day, I would like to announce two new articles which are available from my website: "Class-type Enumeration" describes a class-based alternative to potentially dangerous and inflexible C++ enumerations. http://kolpackov.net/projects/c++/enum/class.xhtml "Class-type Enumeration Synthesis" is a complementary article that provides details of the synthesis process results of which are presented in "Class-type Enumeration". http://kolpackov.net/projects/c++/enum/synthesis.xhtml -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://www.kolpackov.net/pipermail/notes/attachments/20040126/ccd730fb/attachment.bin