Added a rule to the Makefile to build libwebm as a shared

library.

I'm building two different object files now: the ones for
libwebm.a are compiled normally (*_a.o), and the ones for
libwebm.so are compiled with -fPIC and linked with -shared
(*_so.o).

Change-Id: I76471ab225a006c7e169bc0d69df9a0731ff6681
This commit is contained in:
Michael Szal 2012-09-21 13:56:11 -07:00
parent 38173f9d49
commit 69c9348f07

View File

@ -1,29 +1,43 @@
CXX := g++
CXXFLAGS := -W -Wall -g
LIBWEBM := libwebm.a
WEBMOBJS := mkvparser.o mkvreader.o mkvmuxer.o mkvmuxerutil.o mkvwriter.o
OBJECTS1 := sample.o
OBJECTS2 := sample_muxer.o
OBJECTS3 := dumpvtt.o vttreader.o webvttparser.o
INCLUDES := -I.
EXES := samplemuxer sample dumpvtt
CXX := g++
CXXFLAGS := -W -Wall -g
LIBWEBMA := libwebm.a
LIBWEBMSO := libwebm.so
WEBMOBJS := mkvparser.o mkvreader.o mkvmuxer.o mkvmuxerutil.o mkvwriter.o
OBJSA := $(WEBMOBJS:.o=_a.o)
OBJSSO := $(WEBMOBJS:.o=_so.o)
OBJECTS1 := sample.o
OBJECTS2 := sample_muxer.o
OBJECTS3 := dumpvtt.o vttreader.o webvttparser.o
INCLUDES := -I.
EXES := samplemuxer sample dumpvtt
all: $(EXES)
sample: sample.o $(LIBWEBM)
sample: sample.o $(LIBWEBMA)
$(CXX) $^ -o $@
samplemuxer: sample_muxer.o $(LIBWEBM)
samplemuxer: sample_muxer.o $(LIBWEBMA)
$(CXX) $^ -o $@
dumpvtt: $(OBJECTS3)
$(CXX) $^ -o $@
libwebm.a: $(WEBMOBJS)
shared: $(LIBWEBMSO)
libwebm.a: $(OBJSA)
$(AR) rcs $@ $^
libwebm.so: $(OBJSSO)
$(CXX) $(CXXFLAGS) -shared $(OBJSSO) -o $(LIBWEBMSO)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@
%_a.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@
%_so.o: %.cpp
$(CXX) -c $(CXXFLAGS) -fPIC $(INCLUDES) $< -o $@
clean:
$(RM) -f $(OBJECTS1) $(OBJECTS2) $(OBJECTS3) $(WEBMOBJS) $(LIBWEBM) $(EXES) Makefile.bak
$(RM) -f $(OBJECTS1) $(OBJECTS2) $(OBJECTS3) $(OBJSA) $(OBJSSO) $(LIBWEBMA) $(LIBWEBMSO) $(EXES) Makefile.bak