(4) The current Win32 build requires the open source Cygwin DLL. There are rumors that it is possible to build a DLL with gcc that doesnt require the Cygwin DLL. If someone knows how to do this, it would be an improvement
This is the guts of what we use for Xj3D and a number of our other combined Java/native code makefiles:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| OS_NAME=$(shell uname) ifeq (, $(strip $(findstring CYGWIN, $(OS_NAME)))) PATH_SEP=':' LIB_SUFFIX=so LIB_PREFIX=lib INCLUDE_LIST+=$(JNI_HEADER_DIR)/linux CC_LINK_OPTIONS = -Wl -shared $(CFLAGS) ifdef LIBRARY_3RDPARTY 3RDPARTY_LIBS = $(patsubst %,-l%, $(LIBRARY_3RDPARTY)) endif else PATH_SEP=';' LIB_SUFFIX=dll LIB_PREFIX= INCLUDE_LIST+=$(JNI_HEADER_DIR)/win32 /usr/include/win32api CFLAGS +=-D_WIN32 -mno-cygwin CC_LINK_OPTIONS = -Wl,--add-stdcall-alias -shared $(CFLAGS) ifdef LIBRARY_3RDPARTY 3RDPARTY_LIBS = $(patsubst %,$(3RDPARTY_DLL_DIR)/lib%.dll,$(LIBRARY_3RDPARTY)) endif endif
INCS=$(subst $(SPACE)$(SPACE),$(SPACE),$(INCLUDE_LIST)) INC_DIRS=$(subst $(SPACE),$(SPACE)-I,$(INCS))
# # Option listing for the various commands # CC_OPTIONS = -c -O2 $(INC_DIRS) $(CFLAGS)
# # Build rules. #
ifdef LIBRARY LIB_DIR = $(DESTINATION)/$(LIBRARY) OBJ_FILE_LIST = $(SOURCE_FILES:%.c=%.o) OBJ_FILES = $(SOURCE_FILES:%.c=$(DESTINATION)/$(LIBRARY)/%.o) LIB_FILES = $(LIB_DESTINATION)/$(LIB_PREFIX)$(LIBRARY).$(LIB_SUFFIX) endif
SOURCE_FILES = $(filter %.c,$(C_SOURCE))
LIB_LIST_CLEAN = $(patsubst %,$(NATIVE_SRC_DIR)/%/.clean,$(LIBRARY_LIST)) LIB_LIST_BUILD = $(patsubst %,$(NATIVE_SRC_DIR)/%/.build,$(LIBRARY_LIST))
....
# Rule 4. Building a .o object file from a .java file $(LIB_DIR)/%.o : $(NATIVE_DIR)/$(LIBRARY)/%.c $(PRINT) Compiling $*.c cd $(LIB_DIR) && $(CC) $(CC_OPTIONS) $<
# Rule 5. Building a .o file from a .c file. Invokes rule 4. %.o : $(NATIVE_DIR)/$(LIBRARY)/%.c $(PRINT) creating $(LIB_DIR)/$(LIBRARY) $(MAKE) -k $(LIB_DIR)/$@
# Rule 6. Building a .dll or .so from .o files. $(LIB_DESTINATION)/$(LIB_PREFIX)$(LIBRARY).$(LIB_SUFFIX): $(OBJ_FILES) $(PRINT) Building $@ cd $(LIB_DIR) && $(CC) $(CC_LINK_OPTIONS) -o $(LIB_DESTINATION)/$(LIB_PREFIX)$(LIBRARY).$(LIB_SUFFIX) $(3RDPARTY_LIBS) $(OBJ_FILES) |
If need be, I can send you the entire makefile setup that you can then disassemble as needed.