Makefile.dep 2.73 KB
Newer Older
Michel Kaempf's avatar
Michel Kaempf committed
1
################################################################################
Sam Hocevar's avatar
 
Sam Hocevar committed
2
# vlc (VideoLAN Client) dependencies makefile
Michel Kaempf's avatar
Michel Kaempf committed
3 4 5 6 7 8
# (c)1998 VideoLAN
################################################################################
# This Makefile is dedicated to build of .d files. It should not be called
# directly by user, but only through main Makefile.
################################################################################

Sam Hocevar's avatar
 
Sam Hocevar committed
9
###############################################################################
Sam Hocevar's avatar
 
Sam Hocevar committed
10
# Note on generic rules and dependencies
Sam Hocevar's avatar
 
Sam Hocevar committed
11 12
###############################################################################

Sam Hocevar's avatar
 
Sam Hocevar committed
13
# Note on dependencies: each .c file is associated with a .d file, which
Sam Hocevar's avatar
 
Sam Hocevar committed
14 15 16 17 18
# depends of it. The .o file associated with a .c file depends of the .d, of the
# .c itself, and of Makefile. The .d files are stored in a separate .dep/
# directory.
# The dep directory should be ignored by CVS.

Sam Hocevar's avatar
 
Sam Hocevar committed
19
# Note on inclusions: depending of the target, the dependencies files must
Sam Hocevar's avatar
 
Sam Hocevar committed
20 21 22 23 24 25
# or must not be included. The problem is that if we ask make to include a file,
# and this file does not exist, it is made before it can be included. In a
# general way, a .d file should be included if and only if the corresponding .o
# needs to be re-made.

# The object Makefile knows how to make a .o from a .c, and includes
Sam Hocevar's avatar
 
Sam Hocevar committed
26
# dependencies for the target, but only those required.
Sam Hocevar's avatar
 
Sam Hocevar committed
27

Michel Kaempf's avatar
Michel Kaempf committed
28 29 30 31 32 33 34
# All settings and options are passed through main Makefile

################################################################################
# Default target
################################################################################

default:
35 36
	@echo "This Makefile should not be called directly,"
	@echo "see notes at end of main Makefile."
Michel Kaempf's avatar
Michel Kaempf committed
37 38

################################################################################
Sam Hocevar's avatar
 
Sam Hocevar committed
39
# Dependencies creation
Michel Kaempf's avatar
Michel Kaempf committed
40 41
################################################################################

Sam Hocevar's avatar
 
Sam Hocevar committed
42 43
# A dependencies file needs to be rebuilt if the .c  changed or if one of the 
# dependencies files have been changed. In other words, it depends from the
Michel Kaempf's avatar
Michel Kaempf committed
44 45 46
# .c and from itself.

-include $(MAKECMDGOALS)
Jean-Marc Dressler's avatar
 
Jean-Marc Dressler committed
47

Sam Hocevar's avatar
 
Sam Hocevar committed
48 49
CFLAGS += -DMAKE_DEP

Sam Hocevar's avatar
 
Sam Hocevar committed
50
$(C_DEP): .dep/%.d: %.c
Sam Hocevar's avatar
 
Sam Hocevar committed
51
	@test -d .dep/$(dir $*) || mkdir -p $(shell dirname .dep/$*)
Sam Hocevar's avatar
 
Sam Hocevar committed
52
	#@echo "regenerating dependencies for $*.c"
Sam Hocevar's avatar
 
Sam Hocevar committed
53
	@$(SHELL) -ec '$(CC) -M $(CFLAGS) 2>/dev/null $< \
54 55 56 57
	| sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
	.dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
	[ -s $@ ] || rm -f $@'

Sam Hocevar's avatar
 
Sam Hocevar committed
58
$(CPP_DEP): .dep/%.dpp: %.cpp
Sam Hocevar's avatar
 
Sam Hocevar committed
59
	@test -d .dep/$(dir $*) || mkdir -p $(shell dirname .dep/$*)
Sam Hocevar's avatar
 
Sam Hocevar committed
60
	#@echo "regenerating dependencies for $*.c"
Sam Hocevar's avatar
 
Sam Hocevar committed
61
	@$(SHELL) -ec '$(CC) -M $(CFLAGS) 2>/dev/null $< \
Jean-Marc Dressler's avatar
 
Jean-Marc Dressler committed
62 63 64 65
	| sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
	.dep\/$(subst /,\/,$*).dpp : /g'\'' > $@; \
	[ -s $@ ] || rm -f $@'