158 lines
4.6 KiB
Makefile
158 lines
4.6 KiB
Makefile
# Java include directory pathnames
|
|
# The Windows files need to be copied from a Windows JDK installation
|
|
include_linux = /usr/lib/jvm/java-13-openjdk-`\
|
|
uname -r | sed 's/.*-//'`/include
|
|
include_windows = jni-windows-include
|
|
|
|
# Default goal
|
|
.PHONY: default
|
|
default:
|
|
@echo
|
|
@echo "Planet Virtual Boy Emulator"
|
|
@echo " https://www.planetvb.com/"
|
|
@echo " July 30, 2020"
|
|
@echo
|
|
@echo "Intended build environment: Debian i386 or amd64"
|
|
@echo " gcc-multilib"
|
|
@echo " mingw-w64"
|
|
@echo " openjdk-13-jdk"
|
|
@echo
|
|
@echo "Usage: make <recipe>"
|
|
@echo " Package recipes:"
|
|
@echo " build Produces a .jar and deletes all intermediate files"
|
|
@echo " clean Deletes all output files"
|
|
@echo " core Check the native core library for style errors"
|
|
@echo " desktop Compiles the Java desktop application"
|
|
@echo " native Builds all native modules"
|
|
@echo " pack Bundles everything in a .jar file"
|
|
@echo " Native recipes:"
|
|
@echo " lin32 Builds native module linux_x86"
|
|
@echo " lin64 Builds native module linux_x86-64"
|
|
@echo " win32 Builds native module windows_x86"
|
|
@echo " win64 Builds native module windows_x86-64"
|
|
@echo
|
|
|
|
|
|
|
|
###############################################################################
|
|
# Package Recipes #
|
|
###############################################################################
|
|
|
|
# Perform a full build process
|
|
.PHONY: build
|
|
build:
|
|
@make -s core
|
|
@make -s desktop
|
|
@make -s native
|
|
@make -s pack
|
|
@echo " Removing temporary files"
|
|
@make -s clean_most
|
|
|
|
# Delete all output files
|
|
.PHONY: clean
|
|
clean: clean_most
|
|
@rm -f pvbemu_*.jar
|
|
|
|
# Check the native core library for style errors
|
|
.PHONY: core
|
|
core:
|
|
@echo " Checking native core library for style errors"
|
|
$(eval coreargs = -c -Isrc/core/include -Wall -Wextra \
|
|
-fno-strict-aliasing -fsyntax-only src/core/vue.c)
|
|
@gcc -std=c90 $(coreargs)
|
|
@gcc -std=c99 $(coreargs)
|
|
@gcc -std=c11 $(coreargs)
|
|
|
|
# Compile the Java desktop application
|
|
.PHONY: desktop
|
|
desktop: clean_desktop
|
|
@echo " Compiling Java desktop application"
|
|
@javac -sourcepath src/desktop -d . src/desktop/Main.java
|
|
|
|
# Build all native modules
|
|
.PHONY: native
|
|
native:
|
|
@make -s lin32
|
|
@make -s lin64
|
|
@make -s win32
|
|
@make -s win64
|
|
|
|
# Package the release into a .jar file
|
|
.PHONY: pack
|
|
pack:
|
|
$(eval jarname = "pvbemu_`date +%Y%m%d`.jar")
|
|
@echo " Bundling into $(jarname)"
|
|
@jar -cfe $(jarname) Main *.class \
|
|
locale native src vue makefile license.txt
|
|
|
|
# Delete only Java .class files
|
|
.PHONY: clean_desktop
|
|
clean_desktop:
|
|
@rm -r -f *.class vue
|
|
|
|
# Delete everything but the .jar
|
|
.PHONY: clean_most
|
|
clean_most: clean_desktop
|
|
@rm -f src/desktop/native/vue_NativeVUE.h native/*
|
|
|
|
|
|
|
|
###############################################################################
|
|
# Native Recipes #
|
|
###############################################################################
|
|
|
|
# JNI header file
|
|
src/desktop/native/vue_NativeVUE.h: src/desktop/vue/NativeVUE.java
|
|
@javac -h src/desktop/native -sourcepath src/desktop -d . \
|
|
src/desktop/vue/NativeVUE.java
|
|
|
|
# linux_x86
|
|
.PHONY: lin32_pre
|
|
lin32_pre: src/desktop/native/vue_NativeVUE.h
|
|
$(eval name = linux_x86)
|
|
$(eval prefix = `uname -m`-linux-gnu-)
|
|
$(eval include = -I$(include_linux) -I$(include_linux)/linux)
|
|
$(eval gccargs = -m32 -lm)
|
|
$(eval ext = .so)
|
|
.PHONY: lin32
|
|
lin32: lin32_pre native_common
|
|
|
|
# linux_x86-64
|
|
.PHONY: lin64_pre
|
|
lin64_pre: src/desktop/native/vue_NativeVUE.h
|
|
$(eval name = linux_x86-64)
|
|
$(eval prefix = `uname -m`-linux-gnu-)
|
|
$(eval include = -I$(include_linux) -I$(include_linux)/linux)
|
|
$(eval gccargs = -m64 -lm)
|
|
$(eval ext = .so)
|
|
.PHONY: lin64
|
|
lin64: lin64_pre native_common
|
|
|
|
# windows_x86
|
|
.PHONY: win32_pre
|
|
win32_pre: src/desktop/native/vue_NativeVUE.h
|
|
$(eval name = windows_x86)
|
|
$(eval prefix = i686-w64-mingw32-)
|
|
$(eval include = -I$(include_windows) -I$(include_windows)/win32)
|
|
$(eval ext = .dll)
|
|
.PHONY: win32
|
|
win32: win32_pre native_common
|
|
|
|
# windows_x86-64
|
|
.PHONY: win64_pre
|
|
win64_pre: src/desktop/native/vue_NativeVUE.h
|
|
$(eval name = windows_x86-64)
|
|
$(eval prefix = x86_64-w64-mingw32-)
|
|
$(eval include = -I$(include_windows) -I$(include_windows)/win32)
|
|
$(eval ext = .dll)
|
|
.PHONY: win64
|
|
win64: win64_pre native_common
|
|
|
|
# Common recipe for building native modules
|
|
.PHONY: native_common
|
|
native_common:
|
|
@echo " Building native module $(name)"
|
|
@$(prefix)gcc $(include) -Isrc/core/include $(gccargs) -s -shared -Os \
|
|
-fno-strict-aliasing \
|
|
-o native/$(name)$(ext) src/desktop/native/native.c src/core/vue.c
|