Simplify vhook build.
[libav.git] / common.mak
CommitLineData
8b2121e3
MR
1#
2# common bits used by all libraries
3#
4
5SRC_DIR = $(SRC_PATH)/$(SUBDIR)
6VPATH = $(SRC_DIR)
7
8#FIXME: This should be in configure/config.mak
9ifeq ($(CONFIG_WIN32),yes)
10LDFLAGS = -Wl,--output-def,$(@:.dll=.def),--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
11endif
12
13ifeq ($(TARGET_GPROF),yes)
14CFLAGS+=-p
15LDFLAGS+=-p
16endif
17
18ifeq ($(TARGET_ARCH_SPARC64),yes)
19CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
20endif
21
1540cfdc 22SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
8b2121e3
MR
23OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
24STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
25SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
26
06aa32ff 27all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
8b2121e3
MR
28
29$(LIB): $(STATIC_OBJS)
30 rm -f $@
31 $(AR) rc $@ $^ $(EXTRAOBJS)
32 $(RANLIB) $@
33
baa3a937
MR
34$(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
35 ln -sf $^ $@
36
37$(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
8b2121e3
MR
38 $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
39ifeq ($(CONFIG_WIN32),yes)
40 -lib /machine:i386 /def:$(@:.dll=.def)
41endif
42
43%.o: %.c
44 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
45
46%.o: %.S
47 $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
48
49# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
50%.o: %.cpp
51 g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
52
53depend: $(SRCS)
54 $(CC) -MM $(CFLAGS) $^ 1>.depend
55
56dep: depend
57
58clean::
59 rm -f *.o *.d *~ *.a *.lib *.so *.dylib *.dll \
60 *.lib *.def *.dll.a *.exp
61
62distclean: clean
63 rm -f .depend
64
65ifeq ($(BUILD_SHARED),yes)
66INSTLIBTARGETS += install-lib-shared
67endif
68ifeq ($(BUILD_STATIC),yes)
69INSTLIBTARGETS += install-lib-static
70endif
71
72install: install-libs install-headers
73
74install-libs: $(INSTLIBTARGETS)
75
76install-lib-shared: $(SLIBNAME)
c7bb67c4 77 install -d "$(libdir)"
8b2121e3
MR
78ifeq ($(CONFIG_WIN32),yes)
79 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
80else
81 install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
82 $(libdir)/$(SLIBNAME_WITH_VERSION)
83 ln -sf $(SLIBNAME_WITH_VERSION) \
84 $(libdir)/$(SLIBNAME_WITH_MAJOR)
85 ln -sf $(SLIBNAME_WITH_VERSION) \
86 $(libdir)/$(SLIBNAME)
87endif
88
89install-lib-static: $(LIB)
c7bb67c4 90 install -d "$(libdir)"
8b2121e3
MR
91 install -m 644 $(LIB) "$(libdir)"
92
93install-headers:
c7bb67c4
MR
94 install -d "$(incdir)"
95 install -d "$(libdir)/pkgconfig"
8b2121e3
MR
96 install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
97 install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
98
99#
100# include dependency files if they exist
101#
102ifneq ($(wildcard .depend),)
103include .depend
104endif