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