Motion - Makefile With Auto Dependencies

Makefile with Auto Dependencies


Ok, so this isn't really a patch. It's a new that automatically calculates dependencies between source and header files. It is also a bit more informative and clean than the original version.

Description of Patch

When make is run, the makefile (derived from will generate a dependency file, .depend, which contains dependencies between all source and header files for Motion and Motion-control. The next time make is run, the dependency file will be included in the makefile. This means that all files that need to be re-compiled because of a change will be re-compiled.

Note that the dependency file will be re-generated if any source or header file has changed, because the dependency tree may have changed as a consequence.

In addition to the above, the makefile is more informative than before, in order to make it easier to understand what's going on. In line with this, the build commands are not printed to the screen during the build process. Personally, I think error messages are more important, and if I want to check the build command, I can look in the makefile.

Installation of Patch

  1. Copy the attached to a fresh Motion source directory.
  2. Run ./configure to configure Motion and to create the makefile, Makefile.
  3. Run make to build Motion.
  4. Change some header file, e.g. add an #define to ffmpeg.h.
  5. Re-run make and see what happens.
  6. Also try other targets, such as install, uninstall, clean and distclean.

Discussion and Comments

It is now in my 3.1.18 sources for testing.

I really like the idea. I need to get used all the output text when running make smile

But if it is better for newbies it is better for me

-- KennethLavrsen - 24 Oct 2004

After 30 minutes of using the new Makefile I must say that I love it and I hate it.

Love it for its solving the missing make clean issue.

Hate it because I can no longer see what is happening. I only get some nice polished messages that tells me nothing what is going on. When things go bad I want full verbose output when Motion is built and installed. Hiding it all behind @ is not something I like.

And one more problem. It fails. It will not build motion-control.

And I don't know why because it is all hidden for me.

I removed all @ except from the echo statements. Much better. A lot of information. But when things do not work, this is what you need. I want to see the includes and everything when I develop Motion.

Here is the error I get when building motion-control

Linking Motion-control...
(CC) -Wl,-rpath,/usr/lib -o motion-control motion-control.o -L/usr/lib -L/usr/lib -lxmlrpc_client -L/usr/lib -lmd5 -lwwwxml -lxmltok -lxmlparse -lwwwzip -lwwwinit -lwwwapp -lwwwhtml -lwwwtelnet -lwwwnews -lwwwhttp -lwwwmime -lwwwgopher -lwwwftp -lwwwfile -lwwwdir -lwwwcache -lwwwstream -lwwwmux -lwwwtrans -lwwwcore -lwwwutils -ldl -lz -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok
/bin/sh: -c: line 1: syntax error near unexpected token `-Wl,-rpath,/usr/lib'
/bin/sh: -c: line 1: `(CC) -Wl,-rpath,/usr/lib -o motion-control motion-control.o -L/usr/lib -L/usr/lib -lxmlrpc_client -L/usr/lib -lmd5 -lwwwxml -lxmltok -lxmlparse -lwwwzip -lwwwinit -lwwwapp -lwwwhtml -lwwwtelnet -lwwwnews -lwwwhttp -lwwwmime -lwwwgopher -lwwwftp -lwwwfile -lwwwdir -lwwwcache -lwwwstream -lwwwmux -lwwwtrans -lwwwcore -lwwwutils -ldl -lz -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok  '
make: *** [motion-control] Error 2

-- KennethLavrsen - 24 Oct 2004

A compromise is to be verbose about the compile commands, i.e. to remove the @ for the %.o: %.c target.

Motion-control does get built properly for me. But I agree; if it doesn't then you want to know what's going on.

Try the updated It prints out compile, build, install and uninstall commands, but still has a somewhat clean/structured look. Also, now it won't re-generate dependencies for clean or distclean (hopefully).

-- PerJonsson - 24 Oct 2004

The line:

(CC) -Wl,-rpath,/usr/lib -o motion-control ...

should be (and is in my

$(CC) -Wl,-rpath,/usr/lib -o motion-control ...

  • I probably mistakenly removed the $ when I removed all the @ -- KennethLavrsen - 24 Oct 2004

-- PerJonsson - 24 Oct 2004

Hold on, the latest I uploaded contains errors... frown, sad smile But I have to eat now. I'll fix it when I get back!

-- PerJonsson - 24 Oct 2004

Sorry about that! I've just uploaded version 1.3 which hopefully works.

-- PerJonsson - 24 Oct 2004

Now I like it smile It will be in 3.1.18 (with modifications maybe). It is in the sources for 3.1.18 on my machine now.

There is a section commented out. Is that something you forgot to delete or something you want to add later?

Why does it link again when you run make install? I removed the progs that follows install:. Then it behaves as I think it should behave.

-- KennethLavrsen - 24 Oct 2004

Great! smile

The section commented out is the rule that compiles source files into object files (.c -> .o). The reason I had it was to print the "Compiling video.c into video.o..." messages, but then I commented it out to get the default behaviour, i.e. just a verbose compile. You can safely remove it.

I added progs to install: to ensure that Motion is built before installing. Otherwise, if you do make install without building first, it fails with an error message complaining about a missing file (one of the not-yet-built binaries). As you point out, make insists on re-linking for some reason. I guess it has to do with the phony info targets. I see two alternatives:

  1. Let install force a build (my version), in which case we need to solve the re-linking issue (not because it breaks anything, but because it's annoying).
  2. As it was before, in which case we should check that the binaries exist before installing.

-- PerJonsson - 24 Oct 2004
Topic revision: r6 - 30 Jan 2005, KennethLavrsen
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.