Split arch variable into arch and subarch.
[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
9e6165b5 21CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
ad1d8710 22 -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
8b2121e3
MR
23
24%.o: %.c
25 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
26
27%.o: %.S
28 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
29
e4d86a57
MR
30%.ho: %.h
31 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
32
caec74dd
MR
33%.d: %.c
34 $(DEPEND_CMD) > $@
35
36%.d: %.S
37 $(DEPEND_CMD) > $@
38
39%.d: %.cpp
40 $(DEPEND_CMD) > $@
41
18c64005
MR
42%.o: %.d
43
bf237413
MR
44%$(EXESUF): %.c
45
9e6165b5
MR
46SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
47ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
48$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
49endif
50
51$(BUILD_ROOT_REL)/version.h:
ac63af34 52 $(SRC_PATH)/version.sh $(SRC_PATH) $@ $(EXTRA_VERSION)
9e6165b5 53
71c61f62 54install: install-libs install-headers
7716f7ff 55
71c61f62 56uninstall: uninstall-libs uninstall-headers
8b2121e3 57
71c61f62
MR
58.PHONY: all depend dep clean distclean install* uninstall* tests
59endif
8b2121e3 60
71c61f62
MR
61CFLAGS += $(CFLAGS-yes)
62OBJS += $(OBJS-yes)
71c61f62 63FFLIBS := $(FFLIBS-yes) $(FFLIBS)
dbe6c6ff 64TESTS += $(TESTS-yes)
8b2121e3 65
71c61f62
MR
66FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
67FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 68
71c61f62
MR
69OBJS := $(addprefix $(SUBDIR),$(OBJS))
70TESTS := $(addprefix $(SUBDIR),$(TESTS))
8b2121e3 71
76ca42a8
MR
72DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
73
71c61f62
MR
74ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
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::
adc39350
DB
101 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
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
71c61f62 111tests: $(TESTS)
3263626f 112
488b1ca4 113-include $(DEPS)