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