[CentOS] mkdep vs. makedepend

Nicolas Thierry-Mieg Nicolas.Thierry-Mieg at imag.fr
Sat Jul 5 16:16:02 UTC 2008



MHR wrote:
> Where I work, we have an application that has been merrily running
> away (and being built) on FC1 (yes, you read that right).
> 
> One of my assignments is to bring this up to CentOS, but on my first
> effort, I ran into this interesting "feature."  The original build
> process (FC1) uses mkdep to generate the dependency files that are
> subsequently used by the makes to build the app.  mkdep does not exist
> in CentOS 5.2.  There is a makedepend command that operates slightly
> differently.
> 
> Can someone enlighten me on this, particularly w.r.t. 1) how do I use
> makedepend to generate the same files mkdep did and is this a good
> idea (my impression is that it's not really that hard but also not
> necessarily a good idea or 2) convert all the makefiles to be
> makedepend friendly (seems relatively easy, though fairly extensive,
> but probably a better idea and also harmless should I wish/need to
> continue to build on the FC1 system?
> 


At some point a long time ago I was using makedep/makedepend, but I 
replaced that with gcc -MM to generate the Makefile dependancies 
automatically.

man gcc, search for -MM will tell you more.


Here's an excerpt from one of my project's Makefile, in case it helps.


#################################################################
# making the dependancy files
#################################################################
# each .c file has a corresponding .d file in the deps/ subdir.
# This .d file holds the dependancies for the .o.
# The .d is rebuilt automatically whenever the deps may have changed.

# the dependency files
# following only seems to work with gnu make, patsubst should be more 
standard
#DEPS := $(SRCS:%.c=deps/%.d)
DEPS := $(patsubst %.c,deps/%.d,$(SRCS))

# rule to build the .d files
# the output of gcc -MM is something like:
# $ gcc -MM pools.c
# pools.o: pools.c config.h types.h pools.h fonc.h
# the perl line then changes this into:
# pools.o deps/pools.d: pools.c config.h types.h pools.h fonc.h
# Therefore each .d depends on all the files that the corresponding
# .o depends on, and will be rebuilt when necessary.
# I think this can be useful for conditional includes, for example
# if pools.c has a block:
#  #ifdef GMP
#  #include "gmp.h"
#  #endif
# and GMP is defined in config.h...

deps/%.d: %.c
	@echo rebuilding dependancy file $@
	@$(SHELL) -ec '$(CC) -MM $(CFLAGS) $< | $(PERL) -e 
'\''while(<>){s/^(.*)\.o:/$$1.o deps\/$$1.d:/g;print;}'\''> $@'

# include all dep files
include $(DEPS)





More information about the CentOS mailing list