* Renamed all tags (eg. v0_2_83 -> 0.2.83).
[vlc.git] / Makefile.modules
blobd6c33f16418e561d8d627d4ee75c54e15fd5868d
1 ###############################################################################
2 # vlc (VideoLAN Client) common module Makefile
3 # (c)2001 VideoLAN
4 ###############################################################################
5 # This file should be included by all module Makefiles
6 ###############################################################################
9 # include the local Makefile
11 include Makefile
14 # Analyze the target we are asked to build
16 module_name := $(shell echo $(MAKECMDGOALS) | sed 's@.*/\(.*\)\..*@\1@')
17 suff := $(shell echo $(MAKECMDGOALS) | sed 's@.*\.@@' | tr so/a lo/o)
20 # Compiler flags
22 SRC_C := $(filter %.c,$($(module_name)_SOURCES))
23 SRC_CPP := $(filter %.cpp,$($(module_name)_SOURCES))
24 SRC_M := $(filter %.m,$($(module_name)_SOURCES))
26 ifeq (lo,$(suff))
27 extra_CFLAGS := $(plugins_CFLAGS) $($(module_name)_CFLAGS) \
28                 -DMODULE_NAME=$(module_name) -DMODULE_NAME_IS_$(module_name) \
29                 $($(module_name)_so_CFLAGS)
30 OBJ_ALL := $(SRC_C:%.c=%.lo.$(module_name)) $(SRC_CPP:%.cpp=%.lo.$(module_name))
31 else
32 extra_CFLAGS := $(builtins_CFLAGS) $($(module_name)_CFLAGS) \
33                 -DMODULE_NAME=$(module_name) -DMODULE_NAME_IS_$(module_name) \
34                 $($(module_name)_a_CFLAGS)
35 OBJ_ALL := $(SRC_C:%.c=%.o.$(module_name)) $(SRC_CPP:%.cpp=%.o.$(module_name)) \
36                 $(SRC_M:%.m=%.o.$(module_name))
37 endif
39
40 # Standard dependencies
42 C_DEP := $(SRC_C:%.c=.dep/%.d)
43 CPP_DEP := $(SRC_CPP:%.cpp=.dep/%.dpp)
44 M_DEP := $(SRC_M:%.m=.dep/%.dm)
46 export
49 # Virtual targets
51 all:
53 clean:
54 #       rm -f $(PLUGIN_ALL) $(BUILTIN_ALL)
55         rm -f *.o *.o.* *.lo *.lo.* *.obj *.moc *.moc.* *.bak
56         rm -rf .dep
58 FORCE:
60 $(OBJ_ALL): ../../Makefile.modules ../../Makefile.dep ../../Makefile ../../Makefile.opts Makefile
61 $(OBJ_ALL): $(H_DEP:%=../../include/%)
63 $(C_DEP): %.d: FORCE
64         @$(MAKE) -s --no-print-directory -f ../../Makefile.dep $@ CFLAGS="$(CFLAGS) $(extra_CFLAGS)"
66 $(CPP_DEP): %.dpp: FORCE
67         @$(MAKE) -s --no-print-directory -f ../../Makefile.dep $@ CFLAGS="$(CFLAGS) $(extra_CFLAGS)"
69 $(M_DEP): %.dm: FORCE
70         @$(MAKE) -s --no-print-directory -f ../../Makefile.dep $@ CFLAGS="$(CFLAGS) $(extra_CFLAGS)"
72 $(SRC_C:%.c=%.$(suff).$(module_name)): %.$(suff).$(module_name): .dep/%.d
73 $(SRC_C:%.c=%.$(suff).$(module_name)): %.$(suff).$(module_name): %.c
74         $(CC) $(CFLAGS) $(extra_CFLAGS) -c $< -o $@
76 $(SRC_CPP:%.cpp=%.$(suff).$(module_name)): %.$(suff).$(module_name): .dep/%.dpp
77 $(SRC_CPP:%.cpp=%.$(suff).$(module_name)): %.$(suff).$(module_name): %.cpp
78         $(CC) $(CFLAGS) $(extra_CFLAGS) -c $< -o $@
80 $(SRC_M:%.m=%.$(suff).$(module_name)): %.$(suff).$(module_name): .dep/%.dm
81 $(SRC_M:%.m=%.$(suff).$(module_name)): %.$(suff).$(module_name): %.m
82         $(CC) $(CFLAGS) $(extra_CFLAGS) -c $< -o $@
84 # foo_CUSTOM lets us override all target rules for foo.so and foo.a
85 ifeq (,$($(module_name)_CUSTOM))
86 ../$(module_name).so: $(EXTRA_DEP) $(OBJ_ALL)
87         $(CC) $(OBJ_ALL) $(LDFLAGS) $(plugins_LDFLAGS) $($(module_name)_LDFLAGS) -o $@
88         chmod a-x $@
90 ../$(module_name).a: $(EXTRA_DEP) $(OBJ_ALL)
91         rm -f $@
92         ar rc $@ $(OBJ_ALL)
93         $(RANLIB) $@
94 endif