common.mak 1.96 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

Måns Rullgård's avatar
Måns Rullgård committed
7
ifeq ($(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 $<

Måns Rullgård's avatar
Måns Rullgård committed
27
install: install-libs install-headers
28

Måns Rullgård's avatar
Måns Rullgård committed
29
uninstall: uninstall-libs uninstall-headers
30

Måns Rullgård's avatar
Måns Rullgård committed
31 32
.PHONY: all depend dep clean distclean install* uninstall* tests
endif
33

Måns Rullgård's avatar
Måns Rullgård committed
34 35 36 37 38
CFLAGS   += $(CFLAGS-yes)
OBJS     += $(OBJS-yes)
ASM_OBJS += $(ASM_OBJS-yes)
CPP_OBJS += $(CPP_OBJS-yes)
FFLIBS   := $(FFLIBS-yes) $(FFLIBS)
39
TESTS    += $(TESTS-yes)
40

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

Måns Rullgård's avatar
Måns Rullgård committed
44 45
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
46

Måns Rullgård's avatar
Måns Rullgård committed
47 48 49
SRCS  := $(addprefix $(SUBDIR),$(SRCS))
OBJS  := $(addprefix $(SUBDIR),$(OBJS))
TESTS := $(addprefix $(SUBDIR),$(TESTS))
50

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

Måns Rullgård's avatar
Måns Rullgård committed
54
depend dep: $(SUBDIR).depend
55

Måns Rullgård's avatar
Måns Rullgård committed
56 57
CLEANFILES += *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
              *.def *.dll.a *.exp *.ho *.map
58

Måns Rullgård's avatar
Måns Rullgård committed
59 60 61
define RULES
$(SUBDIR)%: $(SUBDIR)%.o $(LIBNAME)
	$(CC) $(FFLDFLAGS) -o $$@ $$^ $(FFEXTRALIBS)
62

Måns Rullgård's avatar
Måns Rullgård committed
63 64
$(SUBDIR)%-test$(EXESUF): $(SUBDIR)%.c $(LIBNAME)
	$(CC) $(CFLAGS) $(FFLDFLAGS) -DTEST -o $$@ $$^ $(FFEXTRALIBS)
Diego Biurrun's avatar
Diego Biurrun committed
65

Måns Rullgård's avatar
Måns Rullgård committed
66 67
$(SUBDIR).depend: $(SRCS)
	$(DEPEND_CMD) > $$@
Diego Biurrun's avatar
Diego Biurrun committed
68

Måns Rullgård's avatar
Måns Rullgård committed
69 70
clean::
	rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES))
Diego Biurrun's avatar
Diego Biurrun committed
71

Måns Rullgård's avatar
Måns Rullgård committed
72 73 74
distclean:: clean
	rm -f $(SUBDIR).depend
endef
75

Måns Rullgård's avatar
Måns Rullgård committed
76
$(eval $(RULES))
77

Måns Rullgård's avatar
Måns Rullgård committed
78
tests: $(TESTS)
79

Måns Rullgård's avatar
Måns Rullgård committed
80
-include $(SUBDIR).depend