common.mak 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #
  2. # common bits used by all libraries
  3. #
  4. all: # make "all" default target
  5. ifndef SUBDIR
  6. vpath %.c $(SRC_DIR)
  7. vpath %.h $(SRC_DIR)
  8. vpath %.S $(SRC_DIR)
  9. vpath %.asm $(SRC_DIR)
  10. ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
  11. BUILD_ROOT_REL = .
  12. else
  13. BUILD_ROOT_REL = ..
  14. endif
  15. ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
  16. CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
  17. %.o: %.c
  18. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  19. %.o: %.S
  20. $(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  21. %.ho: %.h
  22. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
  23. %.d: %.c
  24. $(DEPEND_CMD) > $@
  25. %.d: %.S
  26. $(DEPEND_CMD) > $@
  27. %.d: %.cpp
  28. $(DEPEND_CMD) > $@
  29. %.o: %.d
  30. %$(EXESUF): %.c
  31. SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
  32. ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
  33. $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
  34. endif
  35. $(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
  36. $< $(SRC_PATH) $@ $(EXTRA_VERSION)
  37. install: install-libs install-headers
  38. uninstall: uninstall-libs uninstall-headers
  39. .PHONY: all depend dep *clean install* uninstall* examples testprogs
  40. endif
  41. CFLAGS += $(CFLAGS-yes)
  42. OBJS += $(OBJS-yes)
  43. FFLIBS := $(FFLIBS-yes) $(FFLIBS)
  44. TESTPROGS += $(TESTPROGS-yes)
  45. FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
  46. FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(ALLFFLIBS)) $(LDFLAGS)
  47. EXAMPLES := $(addprefix $(SUBDIR),$(addsuffix -example$(EXESUF),$(EXAMPLES)))
  48. OBJS := $(addprefix $(SUBDIR),$(OBJS))
  49. TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
  50. DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
  51. ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
  52. checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
  53. DEPS := $(OBJS:.o=.d)
  54. depend dep: $(DEPS)
  55. CLEANSUFFIXES = *.o *~ *.ho
  56. DISTCLEANSUFFIXES = *.d *.pc
  57. LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
  58. -include $(DEPS)