common.mak 2.41 KB
Newer Older
1 2 3 4
#
# common bits used by all libraries
#

Måns Rullgård's avatar
Måns Rullgård committed
5
all: # make "all" default target
6

7
ifndef SUBDIR
8 9 10
vpath %.c $(SRC_DIR)
vpath %.h $(SRC_DIR)
vpath %.S $(SRC_DIR)
11

12 13
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

Måns Rullgård's avatar
Måns Rullgård committed
14 15 16
CFLAGS = -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
         -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
         $(addprefix -I$(SRC_PATH)/lib,$(ALLFFLIBS)) $(OPTFLAGS)
17 18 19 20 21 22 23

%.o: %.c
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<

%.o: %.S
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<

Måns Rullgård's avatar
Måns Rullgård committed
24 25 26
%.ho: %.h
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<

27 28 29 30 31 32 33 34 35
%.d: %.c
	$(DEPEND_CMD) > $@

%.d: %.S
	$(DEPEND_CMD) > $@

%.d: %.cpp
	$(DEPEND_CMD) > $@

Måns Rullgård's avatar
Måns Rullgård committed
36
install: install-libs install-headers
37

Måns Rullgård's avatar
Måns Rullgård committed
38
uninstall: uninstall-libs uninstall-headers
39

Måns Rullgård's avatar
Måns Rullgård committed
40 41
.PHONY: all depend dep clean distclean install* uninstall* tests
endif
42

Måns Rullgård's avatar
Måns Rullgård committed
43 44 45 46 47
CFLAGS   += $(CFLAGS-yes)
OBJS     += $(OBJS-yes)
ASM_OBJS += $(ASM_OBJS-yes)
CPP_OBJS += $(CPP_OBJS-yes)
FFLIBS   := $(FFLIBS-yes) $(FFLIBS)
48
TESTS    += $(TESTS-yes)
49

Måns Rullgård's avatar
Måns Rullgård committed
50 51
FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
52

Måns Rullgård's avatar
Måns Rullgård committed
53 54
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
55

Måns Rullgård's avatar
Måns Rullgård committed
56 57 58
SRCS  := $(addprefix $(SUBDIR),$(SRCS))
OBJS  := $(addprefix $(SUBDIR),$(OBJS))
TESTS := $(addprefix $(SUBDIR),$(TESTS))
59

Måns Rullgård's avatar
Måns Rullgård committed
60 61
DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))

Måns Rullgård's avatar
Måns Rullgård committed
62 63
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
64

65 66
DEPS := $(OBJS:.o=.d)
depend dep: $(DEPS)
67

68 69
CLEANSUFFIXES = *.o *~ *.ho
LIBSUFFIXES   = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
70
DISTCLEANSUFFIXES = *.d
71

Måns Rullgård's avatar
Måns Rullgård committed
72
define RULES
73 74
$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
	$(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
75

76 77 78 79 80
$(SUBDIR)%-test.o: $(SUBDIR)%.c
	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^

$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
	$(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
Diego Biurrun's avatar
Diego Biurrun committed
81

Måns Rullgård's avatar
Måns Rullgård committed
82
clean::
83 84
	rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
Diego Biurrun's avatar
Diego Biurrun committed
85

Måns Rullgård's avatar
Måns Rullgård committed
86
distclean:: clean
87 88
	rm -f  $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
            $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
Måns Rullgård's avatar
Måns Rullgård committed
89
endef
90

Måns Rullgård's avatar
Måns Rullgård committed
91
$(eval $(RULES))
92

Måns Rullgård's avatar
Måns Rullgård committed
93
tests: $(TESTS)
94

95
-include $(DEPS)