Makefile: Rebuild FFmpeg libraries when .asm and .o files change
[mplayer/glamo.git] / common.mak
blob4a606fb5cf9ad6b21c1bdbe5d6af618f72d9dc37
2 # common bits used by all libraries
5 all: # make "all" default target
7 ifndef SUBDIR
8 vpath %.c $(SRC_DIR)
9 vpath %.h $(SRC_DIR)
10 vpath %.S $(SRC_DIR)
11 vpath %.asm $(SRC_DIR)
13 ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
14 BUILD_ROOT_REL = .
15 else
16 BUILD_ROOT_REL = ..
17 endif
19 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
21 CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
22 -I$(BUILD_ROOT_REL) -I$(SRC_PATH) -I$(SRC_PATH)/ffmpeg $(OPTFLAGS)
24 %.o: %.c
25 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ -MD -MP -MF $*.d $<
27 %.o: %.S
28 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ -MD -MP -MF $*.d $<
30 %.ho: %.h
31 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
33 %$(EXESUF): %.c
35 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
36 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
37 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
38 endif
40 $(BUILD_ROOT_REL)/version.h:
41 $(SRC_PATH)/version.sh $(SRC_PATH) $@ $(EXTRA_VERSION)
43 install: install-libs install-headers
45 uninstall: uninstall-libs uninstall-headers
47 .PHONY: all depend dep clean distclean install* uninstall* tests
48 endif
50 CFLAGS += $(CFLAGS-yes)
51 OBJS += $(OBJS-yes)
52 FFLIBS := $(FFLIBS-yes) $(FFLIBS)
53 TESTS += $(TESTS-yes)
55 FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
56 FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
58 OBJS := $(addprefix $(SUBDIR),$(OBJS))
59 TESTS := $(addprefix $(SUBDIR),$(TESTS))
61 DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
63 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
64 checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
66 DEPS := $(OBJS:.o=.d)
67 depend dep: $(DEPS)
69 CLEANSUFFIXES = *.o *~ *.ho
70 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
71 DISTCLEANSUFFIXES = *.d *.pc
73 define RULES
74 $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
75 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
77 $(SUBDIR)%-test.o: $(SUBDIR)%.c
78 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
80 $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
81 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
83 $(SUBDIR)i386/%.o: $(SUBDIR)i386/%.asm
84 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
85 $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:%.o=%.d)
87 clean::
88 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
89 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
91 distclean:: clean
92 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
93 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
94 endef
96 $(eval $(RULES))
98 tests: $(TESTS)
100 -include $(DEPS)