mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 20:43:37 +01:00
42f2b5c175
This change adds a new way for fxconv to discover metadata for file conversions. This complements the existing mechanism of passing parameters on the command-line. The new mechanism activates when fxconv is called without a type argument. Type information and metadata are searched in an fxconv-metadata.txt file in the same folder as the resource. The metadata file lists parameters, with some additional flexibility enabled by the use of wildcards. This way of declaring will replace command-line argument passing, which currently read parameters from the unreadable and not-so-maitainable project.cfg file. Both the GNU make and CMake build systems should use it in the future. The current way is still supported only for older projects and one-shot conversions outside of projects.
117 lines
2.4 KiB
Makefile
Executable file
117 lines
2.4 KiB
Makefile
Executable file
#! /usr/bin/make -f
|
|
|
|
# Require config file if not cleaning up
|
|
ifeq "$(filter clean distclean,$(MAKECMDGOALS))" ""
|
|
include Makefile.cfg
|
|
endif
|
|
|
|
# Compiler flags
|
|
cflags = -Wall -Wextra -std=c11 -g -I $(dir $<) -D_GNU_SOURCE \
|
|
-DFXSDK_PREFIX='"$(PREFIX)"' $(CFLAGS)
|
|
# Linker flags
|
|
lflags = -lpng
|
|
# Dependency generation flags
|
|
dflags = -MT $@ -MMD -MP -MF $(@:%.o=%.d)
|
|
|
|
#
|
|
# Main targets and symbolic targets
|
|
# $TARGETS is provided by Makefile.cfg.
|
|
#
|
|
|
|
TARGETS := $(TARGETS:fxsdk=fxsdk.sh)
|
|
TARGETS := $(TARGETS:fxconv=fxconv-main.py)
|
|
bin = $(TARGETS:%=bin/%)
|
|
|
|
# fxconv has no sources files because it's written in Python, and fxsdk has no
|
|
# source either because it's written in Bash.
|
|
src-fxg1a := $(wildcard fxg1a/*.c)
|
|
obj-fxg1a := $(src-fxg1a:%=build/%.o)
|
|
|
|
# Sed command to copy install path to fxsdk.sh. On Mac OS, BSD sed is used so
|
|
# we need to do it a bit differently with a printf helper to insert a literal
|
|
# newline into the command.
|
|
sed := -E -e '/^PREFIX=.?.?.?\\$$/ a \$(PREFIX)'
|
|
ifeq "$(shell uname)" "Darwin"
|
|
sed := -e "$$(printf '/^PREFIX=.?.?.?/ a \\\n$(PREFIX)')"
|
|
endif
|
|
|
|
# Symbolic targets
|
|
|
|
all: $(bin)
|
|
|
|
all-fxsdk: bin/fxsdk.sh
|
|
all-fxg1a: bin/fxg1a
|
|
all-fxconv:
|
|
|
|
# Explicit targets
|
|
|
|
bin/fxsdk.sh: fxsdk/fxsdk.sh | bin/
|
|
sed $(sed) $< > $@
|
|
bin/fxg1a: $(obj-fxg1a) | bin/
|
|
gcc $^ -o $@ $(lflags)
|
|
|
|
bin/:
|
|
mkdir -p $@
|
|
|
|
#
|
|
# Source rules
|
|
#
|
|
|
|
build/%.c.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
gcc -c $< -o $@ $(cflags) $(dflags)
|
|
|
|
#
|
|
# Dependency system, misc.
|
|
#
|
|
|
|
include $(wildcard build/*/*.d)
|
|
|
|
# Dependency on configuration file
|
|
Makefile.cfg:
|
|
@ if [[ ! -f Makefile.cfg ]]; then \
|
|
echo "error: Makefile.cfg is missing, did you ./configure?" >&2; \
|
|
false; \
|
|
fi
|
|
|
|
.PHONY: all clean distclean
|
|
|
|
#
|
|
# Installing
|
|
#
|
|
|
|
m644 := -m 644
|
|
m755 := -m 755
|
|
|
|
# Disable -m on Mac OS
|
|
ifeq "$(shell uname)" "Darwin"
|
|
m644 :=
|
|
m755 :=
|
|
endif
|
|
|
|
install: $(bin)
|
|
install -d $(PREFIX)/bin
|
|
install -d $(PREFIX)/share/fxsdk
|
|
install $(filter bin/fxg1a,$(bin)) $(m755) $(PREFIX)/bin
|
|
install -d $(PREFIX)/share/fxsdk/assets
|
|
install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
|
|
install bin/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
|
|
install fxconv/fxconv-main.py $(m755) $(PREFIX)/bin/fxconv
|
|
install fxconv/fxconv.py $(m644) $(PREFIX)/bin
|
|
|
|
uninstall:
|
|
rm -f $(PREFIX)/bin/{fxsdk,fxg1a,fxconv,fxconv.py}
|
|
rm -rf $(PREFIX)/share/fxsdk
|
|
|
|
#
|
|
# Cleaning
|
|
#
|
|
|
|
clean-fxg1a:
|
|
@rm -rf build/fxg1a
|
|
|
|
clean:
|
|
@rm -rf build
|
|
distclean: clean
|
|
@rm -rf bin
|
|
@rm -f Makefile.cfg
|