Add-in development tools for fx-9860G and fx-CG 50, to use with GCC and gint.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.6 KiB

#! /usr/bin/make -f
# Require config file if not cleaning up
ifeq "$(filter clean distclean,$(MAKECMDGOALS))" ""
include Makefile.cfg
# Compiler flags
cflags = -Wall -Wextra -std=c11 -g -I $(dir $<) -D_GNU_SOURCE \
# 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.
INSTALL := $(TARGETS:%=install-%)
TARGETS := $(TARGETS:%=all-%)
# 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 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)')"
# Symbolic targets
all: $(TARGETS)
all-fxsdk: bin/
all-fxg1a: bin/fxg1a
# Explicit targets
bin/ fxsdk/ | bin/
sed $(sed) $< > $@
bin/fxg1a: $(obj-fxg1a) | bin/
gcc $^ -o $@ $(lflags)
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
@ if [[ ! -f Makefile.cfg ]]; then \
echo "error: Makefile.cfg is missing, did you ./configure?" >&2; \
false; \
.PHONY: all clean distclean
# Installing
m644 := -m 644
m755 := -m 755
# Disable -m on Mac OS
ifeq "$(shell uname)" "Darwin"
m644 :=
m755 :=
install: $(INSTALL)
install-fxsdk: all-fxsdk
install -d $(PREFIX)/bin
install bin/ $(PREFIX)/bin/fxsdk
install -d $(PREFIX)/share/fxsdk/assets
cp -ra fxsdk/assets $(PREFIX)/share/fxsdk/
install bin/ $(m755) $(PREFIX)/bin/fxsdk
install -d $(PREFIX)/lib/cmake/fxsdk
install fxsdk/cmake/* $(m644) $(PREFIX)/lib/cmake/fxsdk
install-fxg1a: all-fxg1a
install -d $(PREFIX)/bin
install bin/fxg1a $(m755) $(PREFIX)/bin
install-fxconv: all-fxconv
install -d $(PREFIX)/bin
install fxconv/ $(m755) $(PREFIX)/bin/fxconv
install fxconv/ $(m644) $(PREFIX)/bin
rm -f $(PREFIX)/bin/{fxsdk,fxg1a,fxconv,}
rm -rf $(PREFIX)/share/fxsdk
rm -rf $(PREFIX)/lib/cmake/fxsdk
# Cleaning
@rm -rf build/fxg1a
@rm -rf build
distclean: clean
@rm -rf bin
@rm -f Makefile.cfg