Compile .S files with $(AS), set it in configure
[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
71c61f62
MR
57.PHONY: all depend dep clean distclean install* uninstall* tests
58endif
8b2121e3 59
71c61f62
MR
60CFLAGS += $(CFLAGS-yes)
61OBJS += $(OBJS-yes)
71c61f62 62FFLIBS := $(FFLIBS-yes) $(FFLIBS)
dbe6c6ff 63TESTS += $(TESTS-yes)
8b2121e3 64
71c61f62
MR
65FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
66FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 67
71c61f62
MR
68OBJS := $(addprefix $(SUBDIR),$(OBJS))
69TESTS := $(addprefix $(SUBDIR),$(TESTS))
8b2121e3 70
76ca42a8
MR
71DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
72
7b5e8a27 73ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
71c61f62 74checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
8b2121e3 75
caec74dd
MR
76DEPS := $(OBJS:.o=.d)
77depend dep: $(DEPS)
8b2121e3 78
0147b92e 79CLEANSUFFIXES = *.o *~ *.ho
d4210e2a 80LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
25cd5cb3 81DISTCLEANSUFFIXES = *.d *.pc
76a448ed 82
71c61f62 83define RULES
b153c68b
MR
84$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
85 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
8b2121e3 86
b153c68b
MR
87$(SUBDIR)%-test.o: $(SUBDIR)%.c
88 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
89
90$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
91 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
f9edb717 92
a6493a8f 93$(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
304d586d
LM
94 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
95
a6493a8f 96$(SUBDIR)x86/%.d: $(SUBDIR)x86/%.asm
304d586d
LM
97 $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
98
71c61f62 99clean::
adc39350
DB
100 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
101 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
f9edb717 102
71c61f62 103distclean:: clean
95d2afec
DB
104 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
105 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
71c61f62 106endef
bca9e0bc 107
71c61f62 108$(eval $(RULES))
bca9e0bc 109
71c61f62 110tests: $(TESTS)
3263626f 111
488b1ca4 112-include $(DEPS)