| 1 |
# |
| 2 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 |
# you may not use this file except in compliance with the License. |
| 4 |
# You may obtain a copy of the License at |
| 5 |
# |
| 6 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
# |
| 8 |
# Unless required by applicable law or agreed to in writing, software |
| 9 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
# See the License for the specific language governing permissions and |
| 12 |
# limitations under the License. |
| 13 |
# |
| 14 |
include Makefile.common |
| 15 |
|
| 16 |
.PHONY: all package native native-all deploy crossbuild ducible clean-native |
| 17 |
|
| 18 |
linux-armv6-digest:=@sha256:a90a7deda7f561932d9ad658f8d661d17eeb44f4e7f7024ac087db1d0b95c6f5 |
| 19 |
linux-x86-digest:=@sha256:fbe45fcb0c2ce82f84a998a1d37d67b3906502723ed89f8191c3243d9d835d17 |
| 20 |
windows-static-x86-digest:=@sha256:b205eeeafaef4f44482d16254670da815d5679b03cf8e51e4adc3539d1c4a9c0 |
| 21 |
windows-static-x64-digest:=@sha256:f159861bc80b29e5dafb223477167bec53ecec6cdacb051d31e90c5823542100 |
| 22 |
windows-arm64-digest:=@sha256:5a8e872064c5f600386e4124f9425d3e2ce2e168cadb6626655b2d69ed748849 |
| 23 |
cross-build-digest:=@sha256:8dbaa86462270db93ae1b1b319bdd88d89272faf3a68632daf4fa36b414a326e |
| 24 |
freebsd-crossbuild-digest:=@sha256:cda62697a15d8bdc0bc26e780b1771ee78f12c55e7d5813e62c478af5a747c43 |
| 25 |
mcandre-snek-digest:=@sha256:e5aaf20daece19796dcd0553feb971143b71cc67d13d79d73649cc689fb87287 |
| 26 |
|
| 27 |
all: package |
| 28 |
|
| 29 |
JANSI_OUT:=target/native-$(OS_NAME)-$(OS_ARCH) |
| 30 |
|
| 31 |
CCFLAGS:= -I$(JANSI_OUT) $(CCFLAGS) |
| 32 |
|
| 33 |
target: |
| 34 |
@test -d target || mkdir target |
| 35 |
|
| 36 |
download-includes: target |
| 37 |
@test -d target/inc || mkdir target/inc |
| 38 |
@test -d target/inc/unix || mkdir target/inc/unix |
| 39 |
@test -d target/inc/windows || mkdir target/inc/windows |
| 40 |
test -f target/inc/jni.h || wget -O target/inc/jni.h https://raw.githubusercontent.com/openjdk/jdk/jdk-11%2B28/src/java.base/share/native/include/jni.h |
| 41 |
test -f target/inc/unix/jni_md.h || wget -O target/inc/unix/jni_md.h https://raw.githubusercontent.com/openjdk/jdk/jdk-11%2B28/src/java.base/unix/native/include/jni_md.h |
| 42 |
test -f target/inc/windows/jni_md.h || wget -O target/inc/windows/jni_md.h https://raw.githubusercontent.com/openjdk/jdk/jdk-11%2B28/src/java.base/windows/native/include/jni_md.h |
| 43 |
|
| 44 |
dockcross: target |
| 45 |
@test -d target/dockcross || mkdir target/dockcross |
| 46 |
|
| 47 |
# This target does not generate the same image digest that the one uploaded |
| 48 |
#crossbuild: target |
| 49 |
# test -d target/crossbuild || git clone https://github.com/multiarch/crossbuild.git target/crossbuild |
| 50 |
# git -C target/crossbuild reset --hard d06cdc31fce0c85ad78408b44794366dafd59554 |
| 51 |
# docker build target/crossbuild -t multiarch/crossbuild |
| 52 |
|
| 53 |
ducible: target |
| 54 |
test -d target/ducible || git clone --branch v1.2.2 https://github.com/jasonwhite/ducible.git target/ducible |
| 55 |
make --directory=target/ducible ducible CROSS_PREFIX= CXX=g++ CC=gcc |
| 56 |
|
| 57 |
clean-native: |
| 58 |
rm -rf $(JANSI_OUT) |
| 59 |
|
| 60 |
$(JANSI_OUT)/%.o: src/main/native/%.c |
| 61 |
@mkdir -p $(@D) |
| 62 |
$(info running: $(CC) $(CCFLAGS) -c $< -o $@) |
| 63 |
$(CC) $(CCFLAGS) -c $< -o $@ |
| 64 |
|
| 65 |
ifeq ($(OS_NAME), Windows) |
| 66 |
$(JANSI_OUT)/$(LIBNAME): ducible |
| 67 |
endif |
| 68 |
$(JANSI_OUT)/$(LIBNAME): $(JANSI_OUT)/jansi.o $(JANSI_OUT)/jansi_isatty.o $(JANSI_OUT)/jansi_structs.o $(JANSI_OUT)/jansi_ttyname.o |
| 69 |
@mkdir -p $(@D) |
| 70 |
$(CC) $(CCFLAGS) -o $@ $(JANSI_OUT)/jansi.o $(JANSI_OUT)/jansi_isatty.o $(JANSI_OUT)/jansi_structs.o $(JANSI_OUT)/jansi_ttyname.o $(LINKFLAGS) |
| 71 |
ifeq ($(OS_NAME), Windows) |
| 72 |
target/ducible/ducible $(JANSI_OUT)/$(LIBNAME) |
| 73 |
endif |
| 74 |
|
| 75 |
NATIVE_DIR=src/main/resources/org/fusesource/jansi/internal/native/$(OS_NAME)/$(OS_ARCH) |
| 76 |
NATIVE_TARGET_DIR:=target/classes/org/fusesource/jansi/internal/native/$(OS_NAME)/$(OS_ARCH) |
| 77 |
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME) |
| 78 |
|
| 79 |
# For cross-compilation, install docker. See also https://github.com/dockcross/dockcross |
| 80 |
# Disabled linux-armv6 build because of this issue; https://github.com/dockcross/dockcross/issues/190 |
| 81 |
native-all: linux-x86 linux-x86_64 linux-arm linux-armv6 linux-armv7 \ |
| 82 |
linux-arm64 linux-ppc64 win-x86 win-x86_64 win-arm64 mac-x86 mac-x86_64 mac-arm64 freebsd-x86 freebsd-x86_64 |
| 83 |
|
| 84 |
native: $(NATIVE_DLL) |
| 85 |
|
| 86 |
$(NATIVE_DLL): $(JANSI_OUT)/$(LIBNAME) |
| 87 |
@mkdir -p $(@D) |
| 88 |
cp $< $@ |
| 89 |
@mkdir -p $(NATIVE_TARGET_DIR) |
| 90 |
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME) |
| 91 |
|
| 92 |
target/dockcross/dockcross-linux-x86: dockcross |
| 93 |
docker run --rm dockcross/linux-x86$(linux-x86-digest) > target/dockcross/dockcross-linux-x86 |
| 94 |
chmod +x target/dockcross/dockcross-linux-x86 |
| 95 |
linux-x86: download-includes target/dockcross/dockcross-linux-x86 |
| 96 |
target/dockcross/dockcross-linux-x86 bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=x86' |
| 97 |
|
| 98 |
linux-x86_64: download-includes |
| 99 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 100 |
-e CROSS_TRIPLE=x86_64-linux-gnu multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Linux OS_ARCH=x86_64 |
| 101 |
|
| 102 |
linux-arm: download-includes |
| 103 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 104 |
-e CROSS_TRIPLE=arm-linux-gnueabi multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Linux OS_ARCH=arm |
| 105 |
|
| 106 |
target/dockcross/dockcross-linux-armv6: dockcross |
| 107 |
docker run --rm dockcross/linux-armv6$(linux-armv6-digest) > target/dockcross/dockcross-linux-armv6 |
| 108 |
chmod +x target/dockcross/dockcross-linux-armv6 |
| 109 |
linux-armv6: download-includes target/dockcross/dockcross-linux-armv6 |
| 110 |
target/dockcross/dockcross-linux-armv6 bash -c 'make clean-native native CROSS_PREFIX=armv6-unknown-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armv6' |
| 111 |
|
| 112 |
linux-armv7: download-includes |
| 113 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 114 |
-e CROSS_TRIPLE=arm-linux-gnueabihf multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Linux OS_ARCH=armv7 |
| 115 |
|
| 116 |
linux-arm64: download-includes |
| 117 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 118 |
-e CROSS_TRIPLE=aarch64-linux-gnu multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Linux OS_ARCH=arm64 |
| 119 |
|
| 120 |
linux-ppc64: download-includes |
| 121 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 122 |
-e CROSS_TRIPLE=powerpc64le-linux-gnu multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Linux OS_ARCH=ppc64 |
| 123 |
|
| 124 |
target/dockcross/dockcross-windows-static-x86: dockcross |
| 125 |
docker run --rm dockcross/windows-static-x86$(windows-static-x86-digest) > target/dockcross/dockcross-windows-static-x86 |
| 126 |
chmod +x target/dockcross/dockcross-windows-static-x86 |
| 127 |
win-x86: download-includes target/dockcross/dockcross-windows-static-x86 |
| 128 |
target/dockcross/dockcross-windows-static-x86 bash -c 'make clean-native native CROSS_PREFIX=i686-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86' |
| 129 |
|
| 130 |
target/dockcross/dockcross-windows-static-x64: dockcross |
| 131 |
docker run --rm dockcross/windows-static-x64$(windows-static-x64-digest) > target/dockcross/dockcross-windows-static-x64 |
| 132 |
chmod +x target/dockcross/dockcross-windows-static-x64 |
| 133 |
win-x86_64: download-includes target/dockcross/dockcross-windows-static-x64 |
| 134 |
target/dockcross/dockcross-windows-static-x64 bash -c 'make clean-native native CROSS_PREFIX=x86_64-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86_64' |
| 135 |
|
| 136 |
target/dockcross/dockcross-windows-arm64: dockcross |
| 137 |
docker run --rm dockcross/windows-arm64$(windows-arm64-digest) > target/dockcross/dockcross-windows-arm64 |
| 138 |
chmod +x target/dockcross/dockcross-windows-arm64 |
| 139 |
win-arm64: download-includes target/dockcross/dockcross-windows-arm64 |
| 140 |
target/dockcross/dockcross-windows-arm64 bash -c 'make clean-native native CROSS_PREFIX=aarch64-w64-mingw32- OS_NAME=Windows OS_ARCH=arm64' |
| 141 |
|
| 142 |
mac-x86: download-includes |
| 143 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 144 |
-e CROSS_TRIPLE=i386-apple-darwin multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Mac OS_ARCH=x86 |
| 145 |
|
| 146 |
mac-x86_64: download-includes |
| 147 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 148 |
-e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild$(cross-build-digest) make clean-native native OS_NAME=Mac OS_ARCH=x86_64 |
| 149 |
|
| 150 |
mac-arm64: download-includes |
| 151 |
docker run -it --rm -v $$PWD:/src --user $$(id -u):$$(id -g) \ |
| 152 |
-e TARGET=arm64-apple-darwin mcandre/snek$(mcandre-snek-digest) sh -c "make clean-native native CROSS_PREFIX=arm64-apple-darwin20.4- OS_NAME=Mac OS_ARCH=arm64" |
| 153 |
|
| 154 |
freebsd-x86: download-includes |
| 155 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 156 |
empterdose/freebsd-cross-build$(freebsd-crossbuild-digest) make clean-native native CROSS_PREFIX=i386-freebsd9- OS_NAME=FreeBSD OS_ARCH=x86 |
| 157 |
|
| 158 |
freebsd-x86_64: download-includes |
| 159 |
docker run -it --rm -v $$PWD:/workdir --user $$(id -u):$$(id -g) \ |
| 160 |
empterdose/freebsd-cross-build$(freebsd-crossbuild-digest) make clean-native native CROSS_PREFIX=x86_64-freebsd9- OS_NAME=FreeBSD OS_ARCH=x86_64 |
| 161 |
|
| 162 |
#sparcv9: |
| 163 |
# $(MAKE) native OS_NAME=SunOS OS_ARCH=sparcv9 |
| 164 |
|