1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 14:52:43 +00:00
mpv/common.mak
Uoti Urpala 2a6178e5ab Makefile, common.mak: Create .d files when creating corresponding .o
The separate .d file creation logic has caused various problems, most
notably cases where 'make' exits without doing anybut but without
giving any error either. Change the Makefile so that .d files are
always created or updated when the corresponding .o file is. This
avoids the problems of current .d file generation and still gives
correct dependencies.

The common.mak change does the same for the libswscale build. However
it does not affect the directories under ffmpeg/ because those use
ffmpeg/common.mak. The MPlayer common.mak can be copied over the
ffmpeg/common.mak file to make the fix apply to the FFmpeg directories
too. This is not done automatically because the FFmpeg file is under
version control and changing it could cause problems.
2008-12-06 05:33:33 +02:00

101 lines
2.6 KiB
Makefile

#
# common bits used by all libraries
#
all: # make "all" default target
ifndef SUBDIR
vpath %.c $(SRC_DIR)
vpath %.h $(SRC_DIR)
vpath %.S $(SRC_DIR)
vpath %.asm $(SRC_DIR)
ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
BUILD_ROOT_REL = .
else
BUILD_ROOT_REL = ..
endif
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-I$(BUILD_ROOT_REL) -I$(SRC_PATH) -I$(SRC_PATH)/ffmpeg $(OPTFLAGS)
%.o: %.c
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ -MD -MP -MF $*.d $<
%.o: %.S
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ -MD -MP -MF $*.d $<
%.ho: %.h
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
%$(EXESUF): %.c
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
endif
$(BUILD_ROOT_REL)/version.h:
$(SRC_PATH)/version.sh $(SRC_PATH) $@ $(EXTRA_VERSION)
install: install-libs install-headers
uninstall: uninstall-libs uninstall-headers
.PHONY: all depend dep clean distclean install* uninstall* tests
endif
CFLAGS += $(CFLAGS-yes)
OBJS += $(OBJS-yes)
FFLIBS := $(FFLIBS-yes) $(FFLIBS)
TESTS += $(TESTS-yes)
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
OBJS := $(addprefix $(SUBDIR),$(OBJS))
TESTS := $(addprefix $(SUBDIR),$(TESTS))
DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
CLEANSUFFIXES = *.o *~ *.ho
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
DISTCLEANSUFFIXES = *.d *.pc
define RULES
$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
$(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
$(SUBDIR)%-test.o: $(SUBDIR)%.c
$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
$(SUBDIR)i386/%.o: $(SUBDIR)i386/%.asm
$(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
$(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$@ $$< > $$(@:%.o=%.d)
clean::
rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
$(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
distclean:: clean
rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
$(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
endef
$(eval $(RULES))
tests: $(TESTS)
-include $(DEPS)