common.mak 2.38 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
CFLAGS = -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
15
         -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) $(OPTFLAGS)
16 17 18 19 20 21 22

%.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
23 24 25
%.ho: %.h
	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<

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

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

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

Måns Rullgård's avatar
Måns Rullgård committed
35 36
%$(EXESUF): %.c

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

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

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

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

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

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

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

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

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

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

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

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

77 78 79 80 81
$(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
82

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

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

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

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

96
-include $(DEPS)