diff --git a/Makefile b/Makefile index b081a0db..aea6b6f6 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ ifeq ($(OS), Windows_NT) # Required to get the gcc run-time libraries on the path. export PATH := $(PATH):$(MINGWBIN) + EXT ?= .exe endif # Special OSX settings. @@ -47,6 +48,7 @@ CXXFLAGS ?= -std=c++17 \ LDFLAGS ?= PLATFORM ?= UNIX TESTS ?= yes +EXT ?= CFLAGS += \ -Iarch \ @@ -84,6 +86,7 @@ $(1): private LDFLAGS += $(shell $(PKG_CONFIG) --libs $(3)) $(2): private CFLAGS += $(shell $(PKG_CONFIG) --cflags $(3)) endef +.PHONY: all tests all: tests PROTOS = \ @@ -145,10 +148,10 @@ do-encodedecodetest = $(eval $(do-encodedecodetest-impl)) define do-encodedecodetest-impl tests: $(OBJDIR)/$1.encodedecode -$(OBJDIR)/$1.encodedecode: scripts/encodedecodetest.sh fluxengine.exe $2 +$(OBJDIR)/$1.encodedecode: scripts/encodedecodetest.sh $(FLUXENGINE_BIN) $2 @mkdir -p $(dir $$@) @echo ENCODEDECODETEST $1 - @scripts/encodedecodetest.sh $1 flux $2 > $$@ + @scripts/encodedecodetest.sh $1 flux $(FLUXENGINE_BIN) $2 > $$@ endef diff --git a/doc/building.md b/doc/building.md index 8392ce03..0c91e5ac 100644 --- a/doc/building.md +++ b/doc/building.md @@ -203,11 +203,9 @@ anything. Windows and Linux (and other Unixes) build by just doing `make`. OSX builds by doing `gmake` (we're using a feature which the elderly default make in OSX doesn't have). You should end up with some executables in the current -directory, one of which is called `fluxengine.exe`. It has minimal dependencies -and you should be able to put it anywhere. The others may also be of interest. - -**Note:** The executable is called `fluxengine.exe` on Linux and OSX because -that makes the build simpler. Feel free to rename it to `fluxengine`. +directory, one of which is called `fluxengine` or `fluxengine.exe` depending on +your platform. It has minimal dependencies and you should be able to put it +anywhere. The other binaries may also be of interest. If it doesn't build, please [get in touch](https://github.com/davidgiven/fluxengine/issues/new). diff --git a/scripts/encodedecodetest.sh b/scripts/encodedecodetest.sh index 2ec35100..c43e6392 100755 --- a/scripts/encodedecodetest.sh +++ b/scripts/encodedecodetest.sh @@ -6,6 +6,8 @@ tmp=/tmp/$$-$format srcfile=$tmp.src.img fluxfile=$tmp.$2 destfile=$tmp.dest.img +fluxengine=$3 +shift shift shift @@ -13,8 +15,8 @@ trap "rm -f $srcfile $fluxfile $destfile" EXIT dd if=/dev/urandom of=$srcfile bs=1048576 count=2 2>&1 -./fluxengine.exe write $format -i $srcfile -d $fluxfile --drive.rotational_period_ms=200 "$@" -./fluxengine.exe read $format -s $fluxfile -o $destfile --drive.rotational_period_ms=200 "$@" +$fluxengine write $format -i $srcfile -d $fluxfile --drive.rotational_period_ms=200 "$@" +$fluxengine read $format -s $fluxfile -o $destfile --drive.rotational_period_ms=200 "$@" if [ ! -s $destfile ]; then echo "Zero length output file!" >&2 exit 1 diff --git a/src/build.mk b/src/build.mk index d59efe59..adbf2f1e 100644 --- a/src/build.mk +++ b/src/build.mk @@ -16,16 +16,22 @@ FLUXENGINE_SRCS = \ FLUXENGINE_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(FLUXENGINE_SRCS)) $(FLUXENGINE_SRCS): | $(PROTO_HDRS) -fluxengine.exe: $(FLUXENGINE_OBJS) +FLUXENGINE_BIN = $(OBJDIR)/fluxengine.exe +$(FLUXENGINE_BIN): $(FLUXENGINE_OBJS) -$(call use-pkgconfig, fluxengine.exe, $(FLUXENGINE_OBJS), fmt) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), AGG) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), LIBARCH) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), LIBFLUXENGINE) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), LIBFORMATS) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), LIBUSBP) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), PROTO) -$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), STB) +$(call use-pkgconfig, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), fmt) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), AGG) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBARCH) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBFLUXENGINE) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBFORMATS) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBUSBP) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), PROTO) +$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), STB) + +all: fluxengine$(EXT) + +fluxengine$(EXT): $(FLUXENGINE_BIN) + @echo CP $@ + @cp $< $@ -all: fluxengine.exe diff --git a/src/gui/build.mk b/src/gui/build.mk index 5f17b8c0..15a38bad 100644 --- a/src/gui/build.mk +++ b/src/gui/build.mk @@ -12,17 +12,22 @@ FLUXENGINE_GUI_OBJS = \ ) $(FLUXENGINE_GUI_SRCS): | $(PROTO_HDRS) $(FLUXENGINE_GUI_OBJS): CFLAGS += $(shell $(WX_CONFIG) --cxxflags core base) -fluxengine-gui.exe: LDFLAGS += $(shell $(WX_CONFIG) --libs core base) -fluxengine-gui.exe: $(FLUXENGINE_GUI_OBJS) +FLUXENGINE_GUI_BIN = $(OBJDIR)/fluxengine-gui.exe +$(FLUXENGINE_GUI_BIN): LDFLAGS += $(shell $(WX_CONFIG) --libs core base) +$(FLUXENGINE_GUI_BIN): $(FLUXENGINE_GUI_OBJS) -$(call use-pkgconfig, fluxengine-gui.exe, $(FLUXENGINE_GUI_OBJS), fmt) -$(call use-library, fluxengine-gui.exe, $(FLUXENGINE_GUI_OBJS), LIBARCH) -$(call use-library, fluxengine-gui.exe, $(FLUXENGINE_GUI_OBJS), LIBFLUXENGINE) -$(call use-library, fluxengine-gui.exe, $(FLUXENGINE_GUI_OBJS), LIBFORMATS) -$(call use-library, fluxengine-gui.exe, $(FLUXENGINE_GUI_OBJS), LIBUSBP) -$(call use-library, fluxengine-gui.exe, $(FLUXENGINE_GUI_OBJS), PROTO) +$(call use-pkgconfig, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), fmt) +$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBARCH) +$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBFLUXENGINE) +$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBFORMATS) +$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBUSBP) +$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), PROTO) -all: fluxengine-gui.exe +all: fluxengine-gui$(EXT) + +fluxengine-gui$(EXT): $(FLUXENGINE_GUI_BIN) + @echo CP $@ + @cp $< $@ else diff --git a/tools/build.mk b/tools/build.mk index 91b1aa9a..9d8e6aa3 100644 --- a/tools/build.mk +++ b/tools/build.mk @@ -1,19 +1,31 @@ -brother120tool.exe: $(OBJDIR)/tools/brother120tool.o -brother240tool.exe: $(OBJDIR)/tools/brother240tool.o -upgrade-flux-file.exe: $(OBJDIR)/tools/upgrade-flux-file.o +$(OBJDIR)/brother120tool.exe: $(OBJDIR)/tools/brother120tool.o +$(OBJDIR)/brother240tool.exe: $(OBJDIR)/tools/brother240tool.o +$(OBJDIR)/upgrade-flux-file.exe: $(OBJDIR)/tools/upgrade-flux-file.o -$(call use-library, brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, PROTO) -$(call use-library, brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, LIBFLUXENGINE) -$(call use-library, brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, PROTO) -$(call use-library, brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, EMU) +$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, PROTO) +$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, LIBFLUXENGINE) +$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, PROTO) +$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, EMU) -$(call use-library, brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, PROTO) -$(call use-library, brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, LIBFLUXENGINE) -$(call use-library, brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, EMU) +$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, PROTO) +$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, LIBFLUXENGINE) +$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, EMU) -$(call use-pkgconfig, upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, sqlite3) -$(call use-library, upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, LIBFLUXENGINE) -$(call use-library, upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, PROTO) +$(call use-pkgconfig, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, sqlite3) +$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, LIBFLUXENGINE) +$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, PROTO) -all: brother120tool.exe brother240tool.exe upgrade-flux-file.exe +brother120tool$(EXT): $(OBJDIR)/brother120tool.exe + @echo CP $@ + @cp $< $@ + +brother240tool$(EXT): $(OBJDIR)/brother240tool.exe + @echo CP $@ + @cp $< $@ + +upgrade-flux-file$(EXT): $(OBJDIR)/upgrade-flux-file.exe + @echo CP $@ + @cp $< $@ + +all: brother120tool$(EXT) brother240tool$(EXT) upgrade-flux-file$(EXT)