Do not shift F[I] twice, it is also clearer and smaller now.
[libav.git] / common.mak
... / ...
CommitLineData
1#
2# common bits used by all libraries
3#
4
5all: # make "all" default target
6
7ifndef SUBDIR
8vpath %.c $(SRC_DIR)
9vpath %.h $(SRC_DIR)
10vpath %.S $(SRC_DIR)
11
12ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
13
14CFLAGS = -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
15 -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) $(OPTFLAGS)
16
17%.o: %.c
18 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
19
20%.o: %.S
21 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
22
23%.ho: %.h
24 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
25
26%.d: %.c
27 $(DEPEND_CMD) > $@
28
29%.d: %.S
30 $(DEPEND_CMD) > $@
31
32%.d: %.cpp
33 $(DEPEND_CMD) > $@
34
35%$(EXESUF): %.c
36
37install: install-libs install-headers
38
39uninstall: uninstall-libs uninstall-headers
40
41.PHONY: all depend dep clean distclean install* uninstall* tests
42endif
43
44CFLAGS += $(CFLAGS-yes)
45OBJS += $(OBJS-yes)
46ASM_OBJS += $(ASM_OBJS-yes)
47CPP_OBJS += $(CPP_OBJS-yes)
48FFLIBS := $(FFLIBS-yes) $(FFLIBS)
49TESTS += $(TESTS-yes)
50
51FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
52FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
53
54SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
55OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
56
57SRCS := $(addprefix $(SUBDIR),$(SRCS))
58OBJS := $(addprefix $(SUBDIR),$(OBJS))
59TESTS := $(addprefix $(SUBDIR),$(TESTS))
60
61DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
62
63ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
64checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
65
66DEPS := $(OBJS:.o=.d)
67depend dep: $(DEPS)
68
69CLEANSUFFIXES = *.o *~ *.ho
70LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
71DISTCLEANSUFFIXES = *.d *.pc
72
73define RULES
74$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
75 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
76
77$(SUBDIR)%-test.o: $(SUBDIR)%.c
78 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
79
80$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
81 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
82
83clean::
84 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
85 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
86
87distclean:: clean
88 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
89 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
90endef
91
92$(eval $(RULES))
93
94tests: $(TESTS)
95
96-include $(DEPS)