Update help output with previous --extra-ldflags change.
[mplayer/glamo.git] / common.mak
blob4be056c876cbfdeecf449706e99654cf371d1314
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) $(OPTFLAGS)
24 %.o: %.c
25 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
27 %.o: %.S
28 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
30 %.ho: %.h
31 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
33 %.d: %.c
34 $(DEPEND_CMD) > $@
36 %.d: %.S
37 $(DEPEND_CMD) > $@
39 %.d: %.cpp
40 $(DEPEND_CMD) > $@
42 %.o: %.d
44 %$(EXESUF): %.c
46 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
47 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
48 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
49 endif
51 $(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh
52 $< $(SRC_PATH) $@ $(EXTRA_VERSION)
54 install: install-libs install-headers
56 uninstall: uninstall-libs uninstall-headers
58 .PHONY: all depend dep clean distclean install* uninstall* tests
59 endif
61 CFLAGS += $(CFLAGS-yes)
62 OBJS += $(OBJS-yes)
63 FFLIBS := $(FFLIBS-yes) $(FFLIBS)
64 TESTS += $(TESTS-yes)
66 FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
67 FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
69 OBJS := $(addprefix $(SUBDIR),$(OBJS))
70 TESTS := $(addprefix $(SUBDIR),$(TESTS))
72 DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
74 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
75 checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
77 DEPS := $(OBJS:.o=.d)
78 depend dep: $(DEPS)
80 CLEANSUFFIXES = *.o *~ *.ho
81 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
82 DISTCLEANSUFFIXES = *.d *.pc
84 define RULES
85 $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
86 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
88 $(SUBDIR)%-test.o: $(SUBDIR)%.c
89 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
91 $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
92 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
94 $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
95 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
97 $(SUBDIR)x86/%.d: $(SUBDIR)x86/%.asm
98 $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
100 clean::
101 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
102 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
104 distclean:: clean
105 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
106 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
107 endef
109 $(eval $(RULES))
111 tests: $(TESTS)
113 -include $(DEPS)