replace some ifeq with prettier ifdef
[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)
8b2121e3 11
5671fc14
MR
12ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
13
71c61f62
MR
14CFLAGS = -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)
8b2121e3
MR
17
18%.o: %.c
19 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
20
21%.o: %.S
22 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
23
e4d86a57
MR
24%.ho: %.h
25 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
26
71c61f62 27install: install-libs install-headers
7716f7ff 28
71c61f62 29uninstall: uninstall-libs uninstall-headers
8b2121e3 30
71c61f62
MR
31.PHONY: all depend dep clean distclean install* uninstall* tests
32endif
8b2121e3 33
71c61f62
MR
34CFLAGS += $(CFLAGS-yes)
35OBJS += $(OBJS-yes)
36ASM_OBJS += $(ASM_OBJS-yes)
37CPP_OBJS += $(CPP_OBJS-yes)
38FFLIBS := $(FFLIBS-yes) $(FFLIBS)
dbe6c6ff 39TESTS += $(TESTS-yes)
8b2121e3 40
71c61f62
MR
41FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
42FFLDFLAGS := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
8b2121e3 43
71c61f62
MR
44SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPP_OBJS:.o=.cpp)
45OBJS := $(OBJS) $(ASM_OBJS) $(CPP_OBJS)
8b2121e3 46
71c61f62
MR
47SRCS := $(addprefix $(SUBDIR),$(SRCS))
48OBJS := $(addprefix $(SUBDIR),$(OBJS))
49TESTS := $(addprefix $(SUBDIR),$(TESTS))
8b2121e3 50
71c61f62
MR
51ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h))
52checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
8b2121e3 53
71c61f62 54depend dep: $(SUBDIR).depend
8b2121e3 55
71c61f62
MR
56CLEANFILES += *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
57 *.def *.dll.a *.exp *.ho *.map
76a448ed 58
71c61f62
MR
59define RULES
60$(SUBDIR)%: $(SUBDIR)%.o $(LIBNAME)
61 $(CC) $(FFLDFLAGS) -o $$@ $$^ $(FFEXTRALIBS)
8b2121e3 62
71c61f62
MR
63$(SUBDIR)%-test$(EXESUF): $(SUBDIR)%.c $(LIBNAME)
64 $(CC) $(CFLAGS) $(FFLDFLAGS) -DTEST -o $$@ $$^ $(FFEXTRALIBS)
f9edb717 65
71c61f62
MR
66$(SUBDIR).depend: $(SRCS)
67 $(DEPEND_CMD) > $$@
f9edb717 68
71c61f62
MR
69clean::
70 rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES))
f9edb717 71
71c61f62
MR
72distclean:: clean
73 rm -f $(SUBDIR).depend
74endef
bca9e0bc 75
71c61f62 76$(eval $(RULES))
bca9e0bc 77
71c61f62 78tests: $(TESTS)
3263626f 79
71c61f62 80-include $(SUBDIR).depend