Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable build of dynamic linked library #76

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,70 @@
# limitations under the License.
#*******************************************************************************
ARCH?=$(shell uname -m)
TARGET=lib/libxbyak_aarch64.a
all: $(TARGET)
NAME=libxbyak_aarch64
SONAME_MAJOR=1
SONAME_MID=0
SONAME_MINOR=0
STATIC_TARGET=lib/$(NAME).a
DYNAMIC_TARGET=lib/$(NAME).so
SONAME_TARGET=$(DYNAMIC_TARGET).so.$(SONAME_MAJOR)
LINK_TARGET=$(SONAME_TARGET).$(SONAME_MID).$(SONAME_MINOR)
all: $(STATIC_TARGET) $(DYNAMIC_TARGET)
static: $(STATIC_TARGET)
dynamic: $(DYNAMIC_TARGET)

CFLAGS=-std=c++11 -DNDEBUG -g -I ./xbyak_aarch64 -Wall -Wextra -fPIC
CXXFLAGS=-std=c++11 -DNDEBUG -g -I ./xbyak_aarch64 -Wall -Wextra -fPIC
ifneq ($(DEBUG),1)
CFLAGS+=-O2
CXXFLAGS+=-O2
endif

LIB_OBJ=obj/xbyak_aarch64_impl.o obj/util_impl.o

obj/%.o: src/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@ -MMD -MP -MF $(@:.o=.d)
$(CXX) $(CXXFLAGS) -c $< -o $@ -MMD -MP -MF $(@:.o=.d)

-include obj/xbyak_aarch64_impl.d

$(TARGET): $(LIB_OBJ)
$(LINK_TARGET): $(LIB_OBJ)
$(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(NAME).so.$(SONAME_MAJOR) -o $@ $^

$(SONAME_TARGET):
ln -sf $(LINK_TARGET) $@

$(DYNAMIC_TARGET):
ln -sf $(SONAME_TARGET) $@

$(STATIC_TARGET): $(LIB_OBJ)
ar r $@ $^

test: $(TARGET)
test: $(STATIC_TARGET)
$(MAKE) -C test

clean:
rm -rf obj/*.o obj/*.d $(TARGET)
rm -rf obj/*.o obj/*.d $(STATIC_TARGET) $(DYNAMIC_TARGET)

MKDIR=mkdir -p
PREFIX?=/usr/local
prefix?=$(PREFIX)
includedir?=$(prefix)/include
libdir?=$(prefix)/lib
INSTALL?=install
INSTALL_DATA?=$(INSTALL) -m 644
install: $(TARGET)
$(MKDIR) $(DESTDIR)$(includedir)/xbyak_aarch64 $(DESTDIR)$(libdir)
INSTALL_DATA?=$(INSTALL) -m 755
install: $(install_static) $(install_dynamic)

install_setup:
$(MKDIR) $(DESTDIR)$(includedir)/$(NAME) $(DESTDIR)$(libdir)
$(INSTALL_DATA) xbyak_aarch64/*.h $(DESTDIR)$(includedir)/xbyak_aarch64
$(INSTALL_DATA) $(TARGET) $(DESTDIR)$(libdir)

install_static: $(STATIC_TARGET)
$(install_setup)
$(INSTALL_DATA) $(STATIC_TARGET) $(DESTDIR)$(libdir)

install_dynamic: $(DYNAMIC_TARGET)
$(install_setup)
$(INSTALL_DATA) $(LINK_TARGET) $(DESTDIR)$(libdir)
$(INSTALL_DATA) $(SONAME_TARGET) $(DESTDIR)$(libdir)
$(INSTALL_DATA) $(DYNAMIC_TARGET) $(DESTDIR)$(libdir)

.PHONY: clean test

Expand Down