cosmetics: Reformat paragraphs and other cosmetic changes.
[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)
304d586d 11vpath %.asm $(SRC_DIR)
8b2121e3 12
9e6165b5
MR
13ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
14BUILD_ROOT_REL = .
15else
16BUILD_ROOT_REL = ..
17endif
18
5671fc14
MR
19ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
20
9d821fc2 21CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
8b2121e3
MR
22
23%.o: %.c
24 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
25
26%.o: %.S
313c46a6 27 $(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
8b2121e3 28
e4d86a57
MR
29%.ho: %.h
30 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
31
caec74dd
MR
32%.d: %.c
33 $(DEPEND_CMD) > $@
34
35%.d: %.S
36 $(DEPEND_CMD) > $@
37
38%.d: %.cpp
39 $(DEPEND_CMD) > $@
40
18c64005
MR
41%.o: %.d
42
bf237413
MR
43%$(EXESUF): %.c
44
9e6165b5
MR
45SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
46ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
47$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
48endif
49
873b0923 50$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
1db2c5c9 51 $< $(SRC_PATH) $@ $(EXTRA_VERSION)
9e6165b5 52
71c61f62 53install: install-libs install-headers
7716f7ff 54
71c61f62 55uninstall: uninstall-libs uninstall-headers
8b2121e3 56
661ce289 57.PHONY: all depend dep *clean install* uninstall* examples testprogs
71c61f62 58endif
8b2121e3 59
71c61f62
MR
60CFLAGS += $(CFLAGS-yes)
61OBJS += $(OBJS-yes)
71c61f62 62FFLIBS := $(FFLIBS-yes) $(FFLIBS)
661ce289 63TESTPROGS += $(TESTPROGS-yes)
8b2121e3 64
71c61f62
MR
65FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
66FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 67
6708cfc4 68EXAMPLES := $(addprefix $(SUBDIR),$(EXAMPLES))
71c61f62 69OBJS := $(addprefix $(SUBDIR),$(OBJS))
661ce289 70TESTPROGS := $(addprefix $(SUBDIR),$(TESTPROGS))
8b2121e3 71
76ca42a8
MR
72DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
73
7b5e8a27 74ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
71c61f62 75checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
8b2121e3 76
caec74dd
MR
77DEPS := $(OBJS:.o=.d)
78depend dep: $(DEPS)
8b2121e3 79
0147b92e 80CLEANSUFFIXES = *.o *~ *.ho
d4210e2a 81LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
25cd5cb3 82DISTCLEANSUFFIXES = *.d *.pc
76a448ed 83
71c61f62 84define RULES
b153c68b
MR
85$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
86 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
8b2121e3 87
b153c68b
MR
88$(SUBDIR)%-test.o: $(SUBDIR)%.c
89 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
90
91$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
92 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
f9edb717 93
a6493a8f 94$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
304d586d
LM
95 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
96
a6493a8f 97$(SUBDIR)x86/%.d: $(SUBDIR)x86/%.asm
304d586d
LM
98 $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
99
71c61f62 100clean::
661ce289 101 rm -f $(EXAMPLES) $(TESTPROGS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
adc39350 102 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
f9edb717 103
71c61f62 104distclean:: clean
95d2afec
DB
105 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
106 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
71c61f62 107endef
bca9e0bc 108
71c61f62 109$(eval $(RULES))
bca9e0bc 110
6708cfc4 111examples: $(EXAMPLES)
661ce289 112testprogs: $(TESTPROGS)
3263626f 113
488b1ca4 114-include $(DEPS)