diff --git a/Makefile b/Makefile index 628f37b5..08d3fe9d 100644 --- a/Makefile +++ b/Makefile @@ -275,11 +275,25 @@ endif endif ifeq ($(CAPSTONE_SHARED),yes) +ifeq ($(IS_MINGW),1) +LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) +else ifeq ($(IS_CYGWIN),1) +LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT) +else # *nix LIBRARY = $(BLDIR)/lib$(LIBNAME).$(EXT) endif +endif + ifeq ($(CAPSTONE_STATIC),yes) +ifeq ($(IS_MINGW),1) +ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) +else ifeq ($(IS_CYGWIN),1) +ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT) +else ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT) endif +endif + PKGCFGF = $(BLDIR)/$(LIBNAME).pc .PHONY: all clean install uninstall dist @@ -291,7 +305,7 @@ else cd tests && $(MAKE) BUILDDIR=$(BLDIR) endif ifeq ($(CAPSTONE_SHARED),yes) - $(INSTALL_DATA) $(BLDIR)/lib$(LIBNAME).$(EXT) $(BLDIR)/tests/ + $(INSTALL_DATA) $(LIBRARY) $(BLDIR)/tests/ endif ifeq ($(CAPSTONE_SHARED),yes) @@ -339,7 +353,7 @@ install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY) ifeq ($(CAPSTONE_SHARED),yes) # remove potential broken old libs rm -f $(LIBDIR)/lib$(LIBNAME).* - $(INSTALL_LIB) $(BLDIR)/lib$(LIBNAME).$(EXT) $(LIBDIR) + $(INSTALL_LIB) $(LIBRARY) $(LIBDIR) ifneq ($(VERSION_EXT),) cd $(LIBDIR) && \ mv lib$(LIBNAME).$(EXT) lib$(LIBNAME).$(VERSION_EXT) && \ @@ -347,7 +361,7 @@ ifneq ($(VERSION_EXT),) endif endif ifeq ($(CAPSTONE_STATIC),yes) - $(INSTALL_DATA) $(BLDIR)/lib$(LIBNAME).$(AR_EXT) $(LIBDIR) + $(INSTALL_DATA) $(ARCHIVE) $(LIBDIR) endif mkdir -p $(INCDIR)/$(LIBNAME) $(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME) @@ -361,7 +375,7 @@ uninstall: clean: rm -f $(LIBOBJ) - rm -f $(BLDIR)/lib$(LIBNAME).* + rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).* rm -f $(PKGCFGF) cd tests && $(MAKE) clean rm -f $(BLDIR)/tests/lib$(LIBNAME).$(EXT) diff --git a/tests/Makefile b/tests/Makefile index 53c4ccaa..3c307bc7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -49,6 +49,16 @@ AR_EXT = lib endif endif +ifeq ($(CAPSTONE_STATIC),yes) +ifeq ($(IS_MINGW),1) +ARCHIVE = $(LIBDIR)/$(LIBNAME).$(AR_EXT) +else ifeq ($(IS_CYGWIN),1) +ARCHIVE = $(LIBDIR)/$(LIBNAME).$(AR_EXT) +else +ARCHIVE = $(LIBDIR)/lib$(LIBNAME).$(AR_EXT) +endif +endif + .PHONY: all clean SOURCES = test.c test_detail.c test_skipdata.c @@ -83,7 +93,7 @@ BINARY = $(addprefix $(TESTDIR)/,$(SOURCES:.c=$(BIN_EXT))) all: $(BINARY) clean: - rm -rf $(OBJS) $(BINARY) $(TESTDIR)/*.exe $(TESTDIR)/*.static $(OBJDIR)/lib$(LIBNAME).* + rm -rf $(OBJS) $(BINARY) $(TESTDIR)/*.exe $(TESTDIR)/*.static $(OBJDIR)/lib$(LIBNAME).* $(OBJDIR)/$(LIBNAME).* $(BINARY): $(OBJS) @@ -123,7 +133,7 @@ endef define link-static - ${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall $(LIBDIR)/lib$(LIBNAME).$(AR_EXT) -o $(call staticname,$@) + ${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall $(ARCHIVE) -o $(call staticname,$@) endef