Generate pkg-config files in each library subdirectory so that they do
[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 14CFLAGS = -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
9b3cdc2e 15 -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) $(OPTFLAGS)
8b2121e3
MR
16
17%.o: %.c
18 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
19
20%.o: %.S
21 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
22
e4d86a57
MR
23%.ho: %.h
24 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
25
caec74dd
MR
26%.d: %.c
27 $(DEPEND_CMD) > $@
28
29%.d: %.S
30 $(DEPEND_CMD) > $@
31
32%.d: %.cpp
33 $(DEPEND_CMD) > $@
34
bf237413
MR
35%$(EXESUF): %.c
36
71c61f62 37install: install-libs install-headers
7716f7ff 38
71c61f62 39uninstall: uninstall-libs uninstall-headers
8b2121e3 40
71c61f62
MR
41.PHONY: all depend dep clean distclean install* uninstall* tests
42endif
8b2121e3 43
71c61f62
MR
44CFLAGS += $(CFLAGS-yes)
45OBJS += $(OBJS-yes)
46ASM_OBJS += $(ASM_OBJS-yes)
47CPP_OBJS += $(CPP_OBJS-yes)
48FFLIBS := $(FFLIBS-yes) $(FFLIBS)
dbe6c6ff 49TESTS += $(TESTS-yes)
8b2121e3 50
71c61f62
MR
51FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
52FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 53
71c61f62
MR
54SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
55OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
8b2121e3 56
71c61f62
MR
57SRCS := $(addprefix $(SUBDIR),$(SRCS))
58OBJS := $(addprefix $(SUBDIR),$(OBJS))
59TESTS := $(addprefix $(SUBDIR),$(TESTS))
8b2121e3 60
76ca42a8
MR
61DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
62
71c61f62
MR
63ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
64checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
8b2121e3 65
caec74dd
MR
66DEPS := $(OBJS:.o=.d)
67depend dep: $(DEPS)
8b2121e3 68
0147b92e 69CLEANSUFFIXES = *.o *~ *.ho
d4210e2a 70LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
25cd5cb3 71DISTCLEANSUFFIXES = *.d *.pc
76a448ed 72
71c61f62 73define RULES
b153c68b
MR
74$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
75 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
8b2121e3 76
b153c68b
MR
77$(SUBDIR)%-test.o: $(SUBDIR)%.c
78 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
79
80$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
81 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
f9edb717 82
71c61f62 83clean::
adc39350
DB
84 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
85 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
f9edb717 86
71c61f62 87distclean:: clean
95d2afec
DB
88 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
89 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
71c61f62 90endef
bca9e0bc 91
71c61f62 92$(eval $(RULES))
bca9e0bc 93
71c61f62 94tests: $(TESTS)
3263626f 95
caec74dd 96-include $(DEPS)