Skip to content

Commit

Permalink
BLD: Add automatic detection of arch and version.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Nov 23, 2023
1 parent d072d2b commit 6bf99e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@ shared_windows:
gfortran -shared $(FPM_LDFLAGS) -o $(BUILD_DIR)/lib$(LIBNAME).dll -Wl,--out-implib=$(BUILD_DIR)/lib$(LIBNAME).dll.a,--export-all-symbols,--enable-auto-import,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive

copy_a:
cp $(shell find ./build -type f -name lib$(LIBNAME).a) $(BUILD_DIR)
cp -f $(shell find ./build -type f -name lib$(LIBNAME).a) $(BUILD_DIR)
cp -f $(BUILD_DIR)/lib$(LIBNAME).a $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).a

copy_h:
cp $(INCLUDE_DIR)/$(LIBNAME)*.h $(PYW_MOD_DIR)/
cp -f $(INCLUDE_DIR)/$(LIBNAME)*.h $(PYW_MOD_DIR)/

copy_shared_linux:
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).so
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(PYW_MOD_DIR)

copy_shared_darwin:
cp $(BUILD_DIR)/lib$(LIBNAME).dylib $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).dylib
cp -f $(BUILD_DIR)/lib$(LIBNAME).dylib $(PYW_MOD_DIR)

copy_shared_windows:
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).dll
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).dll.a
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(PYW_MOD_DIR)
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(PYW_MOD_DIR)

Expand Down
19 changes: 19 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ FPM_LDFLAGS="-static"
DEFAULT_INSTALL_DIR="$HOME/.local"
PLATFORM="linux"

IFS='-'
tmp=$(gcc -dumpmachine)
read -a tmp_arr <<< "$tmp"
ARCH="${tmp_arr[0]}"

IFS="="
while read -r line; do
# Reading line by line
if [[ $line == "version"* ]] then
read -a tmp_arr <<< "$line"
VERSION=${tmp_arr[1]:2:5}
break
fi
done < "fpm.toml"

if [[ "$OSTYPE" == "msys" ]]; then
DEFAULT_INSTALL_DIR="${APPDATA//\\//}/local"
PLATFORM="windows"
Expand All @@ -31,9 +46,13 @@ export PYW_MOD_DIR
export BUILD_DIR
export INCLUDE_DIR
export PLATFORM
export ARCH
export VERSION

echo "OS TYPE=" $OSTYPE
echo "PLATFORM=" $PLATFORM
echo "ARCH=" $ARCH
echo "VERSION=" $VERSION
echo "DEFAULT INSTALL DIR=" $DEFAULT_INSTALL_DIR
echo "FPM_FLAGS=" $FPM_FFLAGS
echo "FPM_CFLAGS=" $FPM_CFLAGS
Expand Down

0 comments on commit 6bf99e7

Please sign in to comment.