Skip to content

Compile correctly under Cygwin using the following toolchains: #3

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
31 changes: 16 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,38 @@ LIBOBJ += MCInst.o

# by default, lib extension is .so
EXT = so
PERMS = 0644

# OSX is the exception
# OSX
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
EXT = dylib
endif

# Cygwin
UNAME_S := $(shell uname -s | sed 's|.*\(CYGWIN\).*|CYGWIN|')
ifeq ($(UNAME_S),CYGWIN)
EXT = dll
# Cygwin doesn't like -fPIC
CFLAGS := $(CFLAGS:-fPIC=)
# On Windows we need the shared library to be executable
PERMS = 0755
endif


.PHONY: all clean lib windows win_lib install uninstall
.PHONY: all clean lib install uninstall

all: lib
make -C tests
install -m0644 lib$(LIBNAME).$(EXT) tests
install -m$(PERMS) lib$(LIBNAME).$(EXT) tests

lib: $(LIBOBJ)
$(CC) $(LDFLAGS) $(LIBOBJ) -o lib$(LIBNAME).$(EXT)
# MacOS doesn't like strip
#strip lib$(LIBNAME).$(EXT)

install: lib
install -m0644 lib$(LIBNAME).$(EXT) /usr/lib
install -m$(PERMS) lib$(LIBNAME).$(EXT) /usr/lib
mkdir -p /usr/include/$(LIBNAME)
install -m0644 include/capstone.h /usr/include/$(LIBNAME)
install -m0644 include/x86.h /usr/include/$(LIBNAME)
Expand All @@ -52,18 +63,8 @@ uninstall:
rm -rf /usr/include/$(LIBNAME)
rm -rf /usr/lib/lib$(LIBNAME).$(EXT)

# Mingw32
windows: win_lib
install -m0644 $(LIBNAME).dll tests
make -C tests windows

# Mingw32
win_lib: $(LIBOBJ)
$(CC) $(LDFLAGS) $(LIBOBJ) -o $(LIBNAME).dll
strip $(LIBNAME).dll

clean:
rm -f $(LIBOBJ) lib$(LIBNAME).* $(LIBNAME).dll
rm -f $(LIBOBJ) lib$(LIBNAME).*
#cd bindings/ruby; make clean; rm -rf Makefile
cd bindings/python; make clean
cd bindings/csharp; make clean
Expand Down
2 changes: 1 addition & 1 deletion arch/AArch64/AArch64BaseInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static bool compare_lower_str(char *s1, char *s2)
{
char *lower = strdup(s2), *c;
for (c = lower; *c; c++)
*c = tolower(*c);
*c = tolower((int) *c);

bool res = (strcmp(s1, lower) == 0);
free(lower);
Expand Down
2 changes: 1 addition & 1 deletion arch/X86/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static enum {
X86_REG_BP_DI = 503,
X86_REG_sib = 504,
X86_REG_sib64 = 505
} _dummy;
} __attribute__((unused)) _dummy;

static x86_reg sib_index_map[] = {
X86_REG_INVALID,
Expand Down
20 changes: 8 additions & 12 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ CFLAGS += -fPIC -O3 -Wall -I$(INCDIR) -L$(LIBDIR)

LIBNAME = capstone

.PHONY: all clean win_test
# Cygwin
UNAME_S := $(shell uname -s | sed 's|.*\(CYGWIN\).*|CYGWIN|')
ifeq ($(UNAME_S),CYGWIN)
CFLAGS := $(CFLAGS:-fPIC=)
endif

.PHONY: all clean

all: test.o test_detail.o test_x86.o test_arm64.o test_arm.o test_mips.o
${CC} $(CFLAGS) test.o -O3 -Wall -l$(LIBNAME) -o test
Expand All @@ -20,24 +26,14 @@ all: test.o test_detail.o test_x86.o test_arm64.o test_arm.o test_mips.o
${CC} $(CFLAGS) test_arm.o -O3 -Wall -l$(LIBNAME) -o test_arm
${CC} $(CFLAGS) test_mips.o -O3 -Wall -l$(LIBNAME) -o test_mips

# Mingw32
windows: test.o test_detail.o test_x86.o test_arm64.o test_arm.o test_mips.o
${CC} test.o -O3 -Wall $(LIBNAME).dll -o test.exe
${CC} test_detail.o -O3 -Wall $(LIBNAME).dll -o test_detail.exe
${CC} test_x86.o -O3 -Wall $(LIBNAME).dll -o test_x86.exe
${CC} test_arm64.o -O3 -Wall $(LIBNAME).dll -o test_arm64.exe
${CC} test_arm.o -O3 -Wall $(LIBNAME).dll -o test_arm.exe
${CC} test_mips.o -O3 -Wall $(LIBNAME).dll -o test_mips.exe

clean:
rm -rf test_x86 test_x86.exe test_x86.o
rm -rf test_arm64 test_arm64.exe test_arm64.o
rm -rf test_arm test_arm.exe test_arm.o
rm -rf test_mips test_mips.exe test_mips.o
rm -rf test test.exe test.o
rm -rf test_detail test_detail.exe test_detail.o
rm -rf *.dll
rm -rf *.so
rm -f libcapstone.*

.c.o:
${CC} ${CFLAGS} -c $< -o $@
Expand Down