4 The "dotmk" project is composed by a set of GNU make scripts that are able to
5 simplify drastically the Makefile creation process. If your project needs to
6 use GNU make to compile its software, "dotmk" can simplify all the complicated
7 process of rules definitions and compiler commands creation. This task
8 sometimes takes lots of time to understand, define and debug, but "dotmk" does
9 it just by setting a couple of variables and a "include" line.
11 For now "dotmk" is only able to handle two basic tasks: C/C++ software building
12 (compilation and linking) and recursive calling GNU make in subdirectories. We
13 intent to implement other objectives like Doxygen extraction, LaTeX documents
14 compilation or Java support but this will come over the time. The instructions
15 to install "dotmk" in your project and execute each task follows.
21 The installation process consists in the building of GNU make scripts under a
22 directory called "mk" in the project which will use "dotmk". The result will be
23 just that the project will contain that "mk" directory with some ".mk" files in
26 To do that, unpack the "dotmk" package and call its "install.sh" script with a
27 target directory as its argument:
29 $ tar -xzf dotmk-0.2.tar.gz
31 $ ./install.sh ~/my-project
33 And that will create the "~/my-project/mk" directory with a few ".mk" files in
34 it. That will enable the use of "dotmk" in that project and you can proceed
35 with the Makefile creation in the next section.
41 Building C/C++ Software
42 -----------------------
44 The building process of a software coded in the C/C++ language is usually
45 simple. It consists in compiling its source code and linking the resulted
46 objects into one binary module, which might be a library or a executable. There
47 may be more details in this process, but this is the simplest example.
49 To build a Makefile without the "dotmk" project you would need to know how to
50 define its rules (which are not that simple), call GCC with its compiling
51 arguments, linking options and maybe AR. With "dotmk" you need to include the
52 following 3 intuitive lines in the Makefile file:
58 This would instruct GNU make compile the "foo.c" and "bar.c" files and link
59 them into the "foobar" executable. The last line just tells make to include
60 "dotmk" scripts. After that you just need to execute the following line to
67 One of the great things of "dotmk" is that it doesn't only define the building
68 targets, but the dependency detection and cleaning ones also. To create the
69 ".depend" file (please look at "mkdep" manual to understand what it is) you
74 And to finally clean all that mess you can call:
78 It would clean all the built objects (create with the default "make" command),
79 but not the ".depend" file. To clean all the remaining file you would need to
86 If you need to build a library just change the "PROG" variable name to "LIB":
92 This would build the "libfoobar.so" and "libfoobar.a" binaries, but without
93 version definition. We intent to implement soon that too.
95 If you need to build more than one executable or library, use "PROGS" or "LIBS"
96 and prefix every "SRCS" line with the name of the program (or library) followed
97 by a underline. For example:
100 foobar_SRCS=foo.c bar.c
101 qwerty_SRCS=qwe.c rty.c
104 If you need to build the "foobar" and "qwerty" programs AND the "asdfgh" and
109 foobar_SRCS=foo.c bar.c
110 qwerty_SRCS=qwe.c rty.c
111 asdfgh_SRCS=asd.c fgh.c
112 zxcvbn_SRCS=zxc.c vbn.c
115 And if you need to include library dependency, dynamic (.so) or static (.a),
116 use the "LIBDIRS" and "DEPLIBS" variables:
119 foobar_SRCS=foo.c bar.c
120 # libfftw.so is under /usr/local/lib
121 foobar_LIBDIRS=/usr/local/lib
122 foobar_DEPLIBS=fftw /opt/gtest/lib/libgtest.a ../lame.a
125 To include already compiled objects in your binary use the OBJS variable:
129 OBJS=../closed/source.o
132 For headers dependency (include) there is the "INCDIRS" variable:
136 INCDIRS=/opt/bar/include
139 You could think that this is beginning to be too complicated but, believe me,
140 with only GNU make the Makefile would be *MUCH* more complicated.
143 Recursive Calling in Subdirectories
144 -----------------------------------
146 If you have a project with lots of programs or libraries to be compiled, maybe
147 a good way to organize them would be dividing it into subdirectories. For
148 example, if you have the "foo" program and the "bar" library, you could create
163 To simplify the "make" command calls without the need to enter it two or more
164 times, you could use "dotmk" by just creating the following Makefile the main
170 This would enable the recursive call for the "all", "clean", "distclean" and