Fix configure for cross-compilation and --arch=amd64.
[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
bf237413
MR
36%$(EXESUF): %.c
37
71c61f62 38install: install-libs install-headers
7716f7ff 39
71c61f62 40uninstall: uninstall-libs uninstall-headers
8b2121e3 41
71c61f62
MR
42.PHONY: all depend dep clean distclean install* uninstall* tests
43endif
8b2121e3 44
71c61f62
MR
45CFLAGS += $(CFLAGS-yes)
46OBJS += $(OBJS-yes)
47ASM_OBJS += $(ASM_OBJS-yes)
48CPP_OBJS += $(CPP_OBJS-yes)
49FFLIBS := $(FFLIBS-yes) $(FFLIBS)
dbe6c6ff 50TESTS += $(TESTS-yes)
8b2121e3 51
71c61f62
MR
52FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
53FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 54
71c61f62
MR
55SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
56OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
8b2121e3 57
71c61f62
MR
58SRCS := $(addprefix $(SUBDIR),$(SRCS))
59OBJS := $(addprefix $(SUBDIR),$(OBJS))
60TESTS := $(addprefix $(SUBDIR),$(TESTS))
8b2121e3 61
76ca42a8
MR
62DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
63
71c61f62
MR
64ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
65checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
8b2121e3 66
caec74dd
MR
67DEPS := $(OBJS:.o=.d)
68depend dep: $(DEPS)
8b2121e3 69
d4210e2a
DB
70CLEANSUFFIXES = *.o *~ *.ho
71LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
95d2afec 72DISTCLEANSUFFIXES = *.d
76a448ed 73
71c61f62 74define RULES
b153c68b
MR
75$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
76 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
8b2121e3 77
b153c68b
MR
78$(SUBDIR)%-test.o: $(SUBDIR)%.c
79 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
80
81$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
82 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
f9edb717 83
71c61f62 84clean::
adc39350
DB
85 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
86 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
f9edb717 87
71c61f62 88distclean:: clean
95d2afec
DB
89 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
90 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
71c61f62 91endef
bca9e0bc 92
71c61f62 93$(eval $(RULES))
bca9e0bc 94
71c61f62 95tests: $(TESTS)
3263626f 96
caec74dd 97-include $(DEPS)