libsm64/configure

50 lines
No EOL
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
CC='cc -g'
CFLAGS='-Wall -fPIC'
BIN_FILE='dist/libsm64.so'
LDFLAGS='-lm'
c_to_obj() {
printf 'build/'
echo "$1" | sed 's/cp*$/o/;s:/:_:g'
}
make_cmd() {
local obj_file="$(c_to_obj "$1")"
$CC $CFLAGS -MM -MT "$obj_file" -c "$1"
echo -e "\t$CC $CFLAGS -o $obj_file -c $1"
}
file_list() {
find src -iname '*.c'
}
print_makefile() {
local all_objs=''
for f in $(file_list); do
all_objs="$all_objs $(c_to_obj $f)"
done
echo "$BIN_FILE: $all_objs dist/include/libsm64.h"
echo -e "\t$CC -shared -o $BIN_FILE $all_objs $LDFLAGS"
for f in $(file_list); do
make_cmd "$f"
done
echo -e "src/mario/geo.inc.c: import-mario-geo.py\n\t ./import-mario-geo.py"
echo -e "src/mario/model.inc.c: import-mario-geo.py\n\t ./import-mario-geo.py"
echo -e "dist/include/libsm64.h: src/libsm64.h\n\t cp src/libsm64.h dist/include/libsm64.h"
echo -e "clean:\n\t rm -rf build && rm -rf dist && mkdir -p build && mkdir -p dist/include"
echo '.PHONY: clean'
}
./import-mario-geo.py
mkdir -p build
mkdir -p dist/include
print_makefile > Makefile