]> git.sesse.net Git - ffmpeg/blob - common.mak
c4054303087039d77819415c1cd6cc8a5c448e95
[ffmpeg] / common.mak
1 #
2 # common bits used by all libraries
3 #
4
5 all: # make "all" default target
6
7 ifeq ($(SUBDIR),)
8 vpath %.c $(SRC_DIR)
9 vpath %.h $(SRC_DIR)
10 vpath %.S $(SRC_DIR)
11
12 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
13
14 CFLAGS = -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)
17
18 %.o: %.c
19         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
20
21 %.o: %.S
22         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
23
24 %.ho: %.h
25         $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
26
27 install: install-libs install-headers
28
29 uninstall: uninstall-libs uninstall-headers
30
31 .PHONY: all depend dep clean distclean install* uninstall* tests
32 endif
33
34 CFLAGS   += $(CFLAGS-yes)
35 OBJS     += $(OBJS-yes)
36 ASM_OBJS += $(ASM_OBJS-yes)
37 CPP_OBJS += $(CPP_OBJS-yes)
38 FFLIBS   := $(FFLIBS-yes) $(FFLIBS)
39
40 FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
41 FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
42
43 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
44 OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
45
46 SRCS  := $(addprefix $(SUBDIR),$(SRCS))
47 OBJS  := $(addprefix $(SUBDIR),$(OBJS))
48 TESTS := $(addprefix $(SUBDIR),$(TESTS))
49
50 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
51 checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
52
53 depend dep: $(SUBDIR).depend
54
55 CLEANFILES += *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
56               *.def *.dll.a *.exp *.ho *.map
57
58 define RULES
59 $(SUBDIR)%: $(SUBDIR)%.o $(LIBNAME)
60         $(CC) $(FFLDFLAGS) -o $$@ $$^ $(FFEXTRALIBS)
61
62 $(SUBDIR)%-test$(EXESUF): $(SUBDIR)%.c $(LIBNAME)
63         $(CC) $(CFLAGS) $(FFLDFLAGS) -DTEST -o $$@ $$^ $(FFEXTRALIBS)
64
65 $(SUBDIR).depend: $(SRCS)
66         $(DEPEND_CMD) > $$@
67
68 clean::
69         rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES))
70
71 distclean:: clean
72         rm -f $(SUBDIR).depend
73 endef
74
75 $(eval $(RULES))
76
77 tests: $(TESTS)
78
79 -include $(SUBDIR).depend