Makefile: make it possible to avoid building static/shared library

v2
Ole André Vadla Ravnås 11 years ago
parent f536d4014b
commit 927fcbcf88
  1. 14
      Makefile
  2. 14
      config.mk
  3. 8
      tests/Makefile

@ -253,8 +253,12 @@ endif
endif
endif
ifeq ($(CAPSTONE_SHARED),yes)
LIBRARY = $(BLDIR)/lib$(LIBNAME).$(EXT)
endif
ifeq ($(CAPSTONE_STATIC),yes)
ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT)
endif
PKGCFGF = $(BLDIR)/$(LIBNAME).pc
.PHONY: all clean install uninstall dist
@ -265,8 +269,11 @@ ifndef BUILDDIR
else
$(MAKE) -C tests BUILDDIR=$(BLDIR)
endif
ifeq ($(CAPSTONE_SHARED),yes)
$(INSTALL_DATA) $(BLDIR)/lib$(LIBNAME).$(EXT) $(BLDIR)/tests/
endif
ifeq ($(CAPSTONE_SHARED),yes)
$(LIBRARY): $(LIBOBJ)
ifeq ($(V),0)
$(call log,CCLD,$(@:$(BLDIR)/%=%))
@ -274,6 +281,7 @@ ifeq ($(V),0)
else
$(create-library)
endif
endif
$(LIBOBJ): config.mk
@ -285,6 +293,7 @@ $(LIBOBJ_SPARC): $(DEP_SPARC)
$(LIBOBJ_SYSZ): $(DEP_SYSZ)
$(LIBOBJ_X86): $(DEP_X86)
ifeq ($(CAPSTONE_STATIC),yes)
$(ARCHIVE): $(LIBOBJ)
@rm -f $(ARCHIVE)
ifeq ($(V),0)
@ -293,6 +302,7 @@ ifeq ($(V),0)
else
$(create-archive)
endif
endif
$(PKGCFGF):
ifeq ($(V),0)
@ -304,6 +314,7 @@ endif
install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY)
mkdir -p $(LIBDIR)
ifeq ($(CAPSTONE_SHARED),yes)
# remove potential broken old libs
rm -f $(LIBDIR)/lib$(LIBNAME).*
$(INSTALL_LIB) $(BLDIR)/lib$(LIBNAME).$(EXT) $(LIBDIR)
@ -312,7 +323,10 @@ ifneq ($(VERSION_EXT),)
mv lib$(LIBNAME).$(EXT) lib$(LIBNAME).$(VERSION_EXT) && \
ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT)
endif
endif
ifeq ($(CAPSTONE_STATIC),yes)
$(INSTALL_DATA) $(BLDIR)/lib$(LIBNAME).$(AR_EXT) $(LIBDIR)
endif
mkdir -p $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME)
mkdir -p $(PKGCFGDIR)

@ -54,3 +54,17 @@ CAPSTONE_DIET ?= no
# thus supports complete X86 instructions.
CAPSTONE_X86_REDUCE ?= no
################################################################################
# Change 'CAPSTONE_STATIC = yes' to 'CAPSTONE_STATIC = no' to avoid building
# a static library.
CAPSTONE_STATIC ?= yes
################################################################################
# Change 'CAPSTONE_SHARED = yes' to 'CAPSTONE_SHARED = no' to avoid building
# a shared library.
CAPSTONE_SHARED ?= yes

@ -86,14 +86,22 @@ $(BINARY): $(OBJS)
$(TESTDIR)/%$(BIN_EXT): $(OBJDIR)/%.o
@mkdir -p $(@D)
ifeq ($(V),0)
ifeq ($(CAPSTONE_SHARED),yes)
$(call log,CCLD,$(notdir $@))
@$(link-dynamic)
endif
ifeq ($(CAPSTONE_STATIC),yes)
$(call log,CCLD,$(notdir $(call staticname,$@)))
@$(link-static)
endif
else
ifeq ($(CAPSTONE_SHARED),yes)
$(link-dynamic)
endif
ifeq ($(CAPSTONE_STATIC),yes)
$(link-static)
endif
endif
$(OBJDIR)/%.o: %.c
@mkdir -p $(@D)

Loading…
Cancel
Save