Globally rename the header inclusion guard names.
[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)
304d586d 11vpath %.asm $(SRC_DIR)
8b2121e3 12
9e6165b5
MR
13ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
14BUILD_ROOT_REL = .
15else
16BUILD_ROOT_REL = ..
17endif
18
5671fc14
MR
19ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
20
9e6165b5 21CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
ad1d8710 22 -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
8b2121e3
MR
23
24%.o: %.c
25 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
26
27%.o: %.S
28 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
29
e4d86a57
MR
30%.ho: %.h
31 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
32
caec74dd
MR
33%.d: %.c
34 $(DEPEND_CMD) > $@
35
36%.d: %.S
37 $(DEPEND_CMD) > $@
38
39%.d: %.cpp
40 $(DEPEND_CMD) > $@
41
18c64005
MR
42%.o: %.d
43
bf237413
MR
44%$(EXESUF): %.c
45
9e6165b5
MR
46SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
47ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
48$(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
49endif
50
51$(BUILD_ROOT_REL)/version.h:
52 $(SRC_PATH)/version.sh $(SRC_PATH) $@
53
71c61f62 54install: install-libs install-headers
7716f7ff 55
71c61f62 56uninstall: uninstall-libs uninstall-headers
8b2121e3 57
71c61f62
MR
58.PHONY: all depend dep clean distclean install* uninstall* tests
59endif
8b2121e3 60
71c61f62
MR
61CFLAGS += $(CFLAGS-yes)
62OBJS += $(OBJS-yes)
63ASM_OBJS += $(ASM_OBJS-yes)
64CPP_OBJS += $(CPP_OBJS-yes)
65FFLIBS := $(FFLIBS-yes) $(FFLIBS)
dbe6c6ff 66TESTS += $(TESTS-yes)
8b2121e3 67
71c61f62
MR
68FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
69FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 70
71c61f62
MR
71SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
72OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
8b2121e3 73
71c61f62
MR
74SRCS := $(addprefix $(SUBDIR),$(SRCS))
75OBJS := $(addprefix $(SUBDIR),$(OBJS))
76TESTS := $(addprefix $(SUBDIR),$(TESTS))
8b2121e3 77
76ca42a8
MR
78DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
79
71c61f62
MR
80ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
81checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
8b2121e3 82
caec74dd
MR
83DEPS := $(OBJS:.o=.d)
84depend dep: $(DEPS)
8b2121e3 85
0147b92e 86CLEANSUFFIXES = *.o *~ *.ho
d4210e2a 87LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
25cd5cb3 88DISTCLEANSUFFIXES = *.d *.pc
76a448ed 89
71c61f62 90define RULES
b153c68b
MR
91$(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
92 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(SUBDIR)$(LIBNAME) $(FFEXTRALIBS)
8b2121e3 93
b153c68b
MR
94$(SUBDIR)%-test.o: $(SUBDIR)%.c
95 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
96
97$(SUBDIR)%-test.o: $(SUBDIR)%-test.c
98 $(CC) $(CFLAGS) -DTEST -c -o $$@ $$^
f9edb717 99
304d586d
LM
100$(SUBDIR)i386/%.o: $(SUBDIR)i386/%.asm
101 $(YASM) $(YASMFLAGS) -I $$(<D)/ -o $$@ $$<
102
103$(SUBDIR)i386/%.d: $(SUBDIR)i386/%.asm
104 $(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
105
71c61f62 106clean::
adc39350
DB
107 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
108 $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
f9edb717 109
71c61f62 110distclean:: clean
95d2afec
DB
111 rm -f $(addprefix $(SUBDIR),$(DISTCLEANSUFFIXES)) \
112 $(addprefix $(SUBDIR), $(foreach suffix,$(DISTCLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
71c61f62 113endef
bca9e0bc 114
71c61f62 115$(eval $(RULES))
bca9e0bc 116
71c61f62 117tests: $(TESTS)
3263626f 118
488b1ca4 119-include $(DEPS)