Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
COMMON-5148 Cleaned up makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
joellawrencetucci committed May 2, 2023
1 parent 629e50b commit 265aa7e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
6 changes: 3 additions & 3 deletions compress/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# util-compress

## About
util-compress is a library for compressing and uncompressing data. Includes snappy and gzip.
util-compress is a library for compressing and uncompressing data. Includes snappy and gzip and a pluggable framework to support other codecs.

A binary is included for Linux-amd64 and Linux-aarch64. It will not work on 32-bit platforms. Other platforms will need to compile from source and may not compile or work as-is.
A binary is included for X86_64 and AARCH64 on both Linux and MacOS. Other platforms, including 32 bit platforms, will need to compile from source and may not compile or work as-is.

## Compiling native code on 64-bit linux

**Requires libsnappy-dev and libz-dev**

You can build the native code for compress yourself by executing the `updateNative` task. It compiles the native code
using the provided Makefile, which depends on GCC.
For Linux if you are running on an x86 and you wish to build the ARM compatible library, you will need to install "aarch64-linux-gnu-gcc", if you are running on an AARCH64 and wish to build the x86 version of the library you will need to install "x86_64-linux-gnu-gcc". If you do not wish to cross-compile for local testing you can invoke the buildX86/buildAARCH64/installX86/installAARCH64 targets to build just for your current architecture. However we ask when comitting changes that modify the C code that you rebuild for all the supported architectures.
For Linux if you are running on an x86 you will need to install "aarch64-linux-gnu-gcc" compiler, if you are running on an AARCH64 you will need to install "x86_64-linux-gnu-gcc" compiler.

On macOS, a universal dylib for both `x86_64` and `arm64` is built automatically. Binaries are installed to `compress/src/main/resources/`. for inclusion in the packaged jar.

Expand Down
36 changes: 19 additions & 17 deletions compress/src/main/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ else
endif
LIBTYPE := so
LD_FLAGS += -shared
#LD_FLAGS += -shared -Wl,-soname,$(LIBSONAME)

ifeq ($(ARCH),$(REALARCH))
ifeq ($(ARCH),x86_64)
ADDITIONAL_ARCH := aarch64
ADDITIONAL_CC := aarch64-linux-gnu-gcc
else
ADDITIONAL_ARCH := x86_64
ADDITIONAL_CC := x86_64-linux-gnu-gcc
endif
endif
endif

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
Expand All @@ -56,27 +65,20 @@ OBJS = \
$(LIBNAME): $(OBJS)
$(CC) $(LD_FLAGS) -o $@ $(OBJS)

buildAARCH64OnX86:
$(MAKE) CC=aarch64-linux-gnu-gcc ARCH=aarch64 build
buildX86OnAARCH64:
$(MAKE) CC=x86_64-linux-gnu-gcc ARCH=x86_64 build
build: $(LIBNAME) $(if $(OS:linux=),,$(if $(ARCH:$(REALARCH)=),,$(if $(ARCH:x86_64=),buildX86OnAARCH64,buildAARCH64OnX86)))
buildAdditional:
$(MAKE) CC=$(ADDITIONAL_CC) ARCH=$(ADDITIONAL_ARCH)
build: $(LIBNAME) $(if $(ADDITIONAL_ARCH),buildAdditional)

$(DEST_DIR):
mkdir -p $(DEST_DIR)

install: build $(DEST_DIR) $(if $(OS:linux=),,$(if $(ARCH:$(REALARCH)=),,$(if $(ARCH:x86_64=),installX86,installAARCH64)))
install: build $(DEST_DIR) $(if $(ADDITIONAL_ARCH),installAdditional)
cp $(LIBNAME) $(DEST_DIR)/$(subst -$(ARCH),,$(LIBNAME))

installX86:
$(MAKE) ARCH=x86_64 install

installAARCH64:
$(MAKE) ARCH=aarch64 install
installAdditional:
$(MAKE) ARCH=$(ADDITIONAL_ARCH) install

clean: $(if $(OS:linux=),,$(if $(ARCH:$(REALARCH)=),,$(if $(ARCH:x86_64=),cleanX86,cleanAARCH64)))
clean: $(if $(ADDITIONAL_ARCH),cleanAdditional)
rm -rf $(OBJS) $(TARGET)
cleanX86:
$(MAKE) ARCH=x86_64 clean
cleanAARCH64:
$(MAKE) ARCH=aarch64 clean
cleanAdditional:
$(MAKE) ARCH=$(ADDITIONAL_ARCH) clean
2 changes: 1 addition & 1 deletion mmap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You can build the native code for util-mmap yourself by executing the `updateNat
using the provided Makefile, which depends on GCC. On Linux you will need a 64 bit x86 or aarch64 environment, other architectures are not currently supported. On macOS, a universal dylib for both `x86_64` and `arm64`
is built automatically. Binaries are installed to `mmap/src/main/resources/`. for inclusion in the packaged jar.

For Linux if you are running on an x86 and you wish to build the ARM compatible library, you will need to install "aarch64-linux-gnu-gcc", if you are running on an AARCH64 and wish to build the x86 version of the library you will need to install "x86_64-linux-gnu-gcc". If you do not wish to cross-compile for local testing you can invoke the buildX86/buildAARCH64/installX86/installAARCH64 targets to build just for your current architecture. However we ask when comitting changes that modify the C code that you rebuild for all the supported architectures.
For Linux if you are running on an x86 you will need to install "aarch64-linux-gnu-gcc" to build the AARCH64 library, if you are running on an AARCH64 you will need to install "x86_64-linux-gnu-gcc" to build the x86 compatible library

The makefile can also be invoked directly with:

Expand Down
38 changes: 19 additions & 19 deletions mmap/src/main/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ else
else
DEST_DIR := "../resources/native/Linux-$(ARCH)/"
endif
ifeq ($(ARCH), $(REALARCH))
ifeq ($(ARCH), x86_64)
ADDITIONAL_ARCH := aarch64
ADDITIONAL_CC := aarch64-linux-gnu-gcc
else
ADDITIONAL_ARCH := x86_64
ADDITIONAL_CC := x86_64-linux-gnu-gcc
endif
endif

LIBTYPE := so
LD_FLAGS += -shared -Wl,-soname,$(LIBSONAME)
endif
Expand All @@ -54,28 +64,18 @@ OBJS = \
$(REALLIBNAME): $(OBJS)
$(CC) $(LD_FLAGS) -o $@ $(OBJS)

buildAARCH64OnX86:
$(MAKE) CC=aarch64-linux-gnu-gcc ARCH=aarch64 build

buildX86OnAARCH64:
$(MAKE) CC=x86_64-linux-gnu-gcc ARCH=x86_64 build
build: $(REALLIBNAME) $(if $(ADDITIONAL_ARCH),buildAdditional)

build: $(REALLIBNAME) $(if $(OS:linux=),,$(if $(ARCH:$(REALARCH)=),,$(if $(ARCH:x86_64=),buildX86OnAARCH64,buildAARCH64OnX86)))
buildAdditional:
$(MAKE) CC=$(ADDITIONAL_CC) ARCH=$(ADDITIONAL_ARCH)

install: build $(if $(OS:linux=),,$(if $(ARCH:$(REALARCH)=),,$(if $(ARCH:x86_64=),installX86,installAARCH64)))
install: build $(if $(ADDITIONAL_ARCH),installAdditional)
cp $(REALLIBNAME) $(DEST_DIR)/$(subst -$(ARCH),,$(REALLIBNAME))

installX86:
$(MAKE) ARCH=x86_64 install
installAdditional:
$(MAKE) ARCH=$(ADDITIONAL_ARCH) install

installAARCH64:
$(MAKE) ARCH=aarch64 install

clean: $(if $(OS:linux=),,$(if $(ARCH:$(REALARCH)=),,$(if $(ARCH:x86_64=),cleanX86,cleanAARCH64)))
clean: $(if $(ADDITIONAL_ARCH),cleanAdditional)
rm -rf $(OBJS) $(TARGET)

cleanX86:
$(MAKE) ARCH=x86_64 clean
cleanAARCH64:
$(MAKE) ARCH=aarch64 clean

cleanAdditional:
$(MAKE) ARCH=$(ADDITIONAL_ARCH) clean
Binary file not shown.
Binary file modified mmap/src/main/resources/native/Linux-amd64/libindeedmmap.so.1.0.1
Binary file not shown.

0 comments on commit 265aa7e

Please sign in to comment.