diff --git a/Makefile b/Makefile index f156d301..0a468617 100644 --- a/Makefile +++ b/Makefile @@ -48,31 +48,120 @@ LDFLAGS ?= PLATFORM ?= UNIX TESTS ?= yes -all:: $(OBJDIR)/build.ninja - @ninja -f $< -t compdb > compile_commands.json - @ninja -f $< +CFLAGS += \ + -Iarch \ + -Ilib \ + -I. \ + -I$(OBJDIR)/arch \ + -I$(OBJDIR)/lib \ + -I$(OBJDIR) \ -$(OBJDIR)/build.ninja: Makefile $(shell find . -name '*.lua') - @mkdir -p $(OBJDIR) - @$(LUA) build/ackbuilder.lua build/build.lua build.lua \ - --ninja \ - AR="$(AR)" \ - CC="$(CC)" \ - CFLAGS="$(CFLAGS)" \ - CXX="$(CXX)" \ - CXXFLAGS="$(CXXFLAGS)" \ - LDFLAGS="$(LDFLAGS)" \ - OBJDIR="$(OBJDIR)" \ - PKG_CONFIG="$(PKG_CONFIG)" \ - PLATFORM="$(PLATFORM)" \ - PROTOC="$(PROTOC)" \ - TESTS="$(TESTS)" \ - WX_CONFIG="$(WX_CONFIG)" \ - > $@ +LDFLAGS += \ + -lz \ + -lfmt + +.SUFFIXES: + +use-library = $(eval $(use-library-impl)) +define use-library-impl +$(1): | $(call $(3)_LIB) +$(1): private LDFLAGS += $(call $(3)_LDFLAGS) +$(2): private CFLAGS += $(call $(3)_CFLAGS) +endef + +all: $(OBJDIR) fluxengine.exe + +PROTOS = \ + arch/aeslanier/aeslanier.proto \ + arch/amiga/amiga.proto \ + arch/apple2/apple2.proto \ + arch/brother/brother.proto \ + arch/c64/c64.proto \ + arch/f85/f85.proto \ + arch/fb100/fb100.proto \ + arch/ibm/ibm.proto \ + arch/macintosh/macintosh.proto \ + arch/mx/mx.proto \ + arch/victor9k/victor9k.proto \ + arch/zilogmcz/zilogmcz.proto \ + arch/tids990/tids990.proto \ + arch/micropolis/micropolis.proto \ + arch/northstar/northstar.proto \ + arch/agat/agat.proto \ + lib/decoders/decoders.proto \ + lib/encoders/encoders.proto \ + lib/fluxsink/fluxsink.proto \ + lib/fluxsource/fluxsource.proto \ + lib/imagereader/imagereader.proto \ + lib/imagewriter/imagewriter.proto \ + lib/usb/usb.proto \ + lib/common.proto \ + lib/fl2.proto \ + lib/config.proto \ + lib/mapper.proto \ + lib/drive.proto \ + tests/testproto.proto \ + +PROTO_HDRS = $(patsubst %.proto, $(OBJDIR)/%.pb.h, $(PROTOS)) +PROTO_SRCS = $(patsubst %.proto, $(OBJDIR)/%.pb.cc, $(PROTOS)) +PROTO_OBJS = $(patsubst %.cc, %.o, $(PROTO_SRCS)) +PROTO_CFLAGS = $(shell pkg-config --cflags protobuf) +$(PROTO_SRCS): | $(PROTO_HDRS) +$(PROTO_OBJS): CFLAGS += $(PROTO_CFLAGS) +PROTO_LIB = $(OBJDIR)/libproto.a +$(PROTO_LIB): $(PROTO_OBJS) +PROTO_LDFLAGS = $(shell pkg-config --libs protobuf) -pthread $(PROTO_LIB) +.PRECIOUS: $(PROTO_HDRS) $(PROTO_SRCS) + +include dep/agg/build.mk +include dep/libusbp/build.mk +include dep/stb/build.mk +include dep/fmt/build.mk + +include lib/build.mk +include arch/build.mk +include src/build.mk + +$(OBJDIR)/%.a: + @mkdir -p $(dir $@) + @echo AR $@ + @$(AR) rc $@ $^ + +%.exe: + @mkdir -p $(dir $@) + @echo LINK $@ + @$(CXX) -o $@ $^ -Wl,--start-group $(LDFLAGS) -Wl,--end-group + +$(OBJDIR)/%.o: %.cpp + @mkdir -p $(dir $@) + @echo CXX $< + @$(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +$(OBJDIR)/%.o: %.cc + @mkdir -p $(dir $@) + @echo CXX $< + @$(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +$(OBJDIR)/%.o: $(OBJDIR)/%.cc + @mkdir -p $(dir $@) + @echo CXX $< + @$(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +$(OBJDIR)/%.o: %.c + @mkdir -p $(dir $@) + @echo CC $< + @$(CC) $(CFLAGS) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< + +$(OBJDIR)/%.pb.h: %.proto + @mkdir -p $(dir $@) + @echo PROTOC $@ + @$(PROTOC) -I. --cpp_out=$(OBJDIR) $< clean: rm -rf $(OBJDIR) +-include $(LIB_OBJS:%.o=%.d) + #PACKAGES = zlib sqlite3 protobuf # #export CFLAGS = \ diff --git a/arch/build.mk b/arch/build.mk new file mode 100644 index 00000000..d8a453d4 --- /dev/null +++ b/arch/build.mk @@ -0,0 +1,39 @@ +LIBARCH_SRCS = \ + arch/aeslanier/decoder.cc \ + arch/amiga/amiga.cc \ + arch/amiga/decoder.cc \ + arch/amiga/encoder.cc \ + arch/apple2/decoder.cc \ + arch/apple2/encoder.cc \ + arch/brother/decoder.cc \ + arch/brother/encoder.cc \ + arch/c64/c64.cc \ + arch/c64/decoder.cc \ + arch/c64/encoder.cc \ + arch/f85/decoder.cc \ + arch/fb100/decoder.cc \ + arch/ibm/decoder.cc \ + arch/ibm/encoder.cc \ + arch/macintosh/decoder.cc \ + arch/macintosh/encoder.cc \ + arch/mx/decoder.cc \ + arch/victor9k/decoder.cc \ + arch/victor9k/encoder.cc \ + arch/zilogmcz/decoder.cc \ + arch/tids990/decoder.cc \ + arch/tids990/encoder.cc \ + arch/micropolis/decoder.cc \ + arch/micropolis/encoder.cc \ + arch/northstar/decoder.cc \ + arch/northstar/encoder.cc \ + arch/agat/agat.cc \ + arch/agat/decoder.cc \ + +LIBARCH_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(LIBARCH_SRCS)) +$(LIBARCH_SRCS): | $(PROTO_HDRS) +$(LIBARCH_SRCS): CFLAGS += $(PROTO_CFLAGS) +LIBARCH_LIB = $(OBJDIR)/libarch.a +$(LIBARCH_LIB): $(LIBARCH_OBJS) + +LIBARCH_LDFLAGS = $(LIBARCH_LIB) + diff --git a/dep/agg/build.mk b/dep/agg/build.mk new file mode 100644 index 00000000..1108d821 --- /dev/null +++ b/dep/agg/build.mk @@ -0,0 +1,37 @@ +AGG_SRCS = \ + dep/agg/src/agg_arrowhead.cpp \ + dep/agg/src/agg_line_aa_basics.cpp \ + dep/agg/src/agg_vcgen_bspline.cpp \ + dep/agg/src/agg_vpgen_segmentator.cpp \ + dep/agg/src/agg_color_rgba.cpp \ + dep/agg/src/agg_sqrt_tables.cpp \ + dep/agg/src/agg_bspline.cpp \ + dep/agg/src/agg_curves.cpp \ + dep/agg/src/agg_rounded_rect.cpp \ + dep/agg/src/agg_vcgen_markers_term.cpp \ + dep/agg/src/agg_vcgen_dash.cpp \ + dep/agg/src/agg2d.cpp \ + dep/agg/src/agg_trans_affine.cpp \ + dep/agg/src/agg_gsv_text.cpp \ + dep/agg/src/agg_vcgen_smooth_poly1.cpp \ + dep/agg/src/agg_trans_single_path.cpp \ + dep/agg/src/agg_vpgen_clip_polygon.cpp \ + dep/agg/src/agg_embedded_raster_fonts.cpp \ + dep/agg/src/agg_trans_double_path.cpp \ + dep/agg/src/agg_vcgen_stroke.cpp \ + dep/agg/src/agg_arc.cpp \ + dep/agg/src/agg_image_filters.cpp \ + dep/agg/src/agg_trans_warp_magnifier.cpp \ + dep/agg/src/agg_vpgen_clip_polyline.cpp \ + dep/agg/src/agg_bezier_arc.cpp \ + dep/agg/src/agg_line_profile_aa.cpp \ + dep/agg/src/agg_vcgen_contour.cpp \ + +AGG_OBJS = $(patsubst %.cpp, $(OBJDIR)/%.o, $(AGG_SRCS)) +AGG_LIB = $(OBJDIR)/libagg.a +$(AGG_LIB): $(AGG_OBJS) +AGG_LDFLAGS = $(AGG_LIB) +AGG_CFLAGS = -Idep/agg/include + +$(AGG_OBJS): CFLAGS += $(AGG_CFLAGS) + diff --git a/dep/fmt/build.mk b/dep/fmt/build.mk new file mode 100644 index 00000000..0dc4487b --- /dev/null +++ b/dep/fmt/build.mk @@ -0,0 +1,12 @@ +ifeq ($(shell $(PKG_CONFIG) fmt; echo $$?), 0) + +LIBFMT_LIB = +LIBFMT_CFLAGS := $(shell $(PKG_CONFIG) --cflags fmt) +LIBFMT_LDFLAGS := $(shell $(PKG_CONFIG) --libs fmt) + +else + +$(error required dependency 'fmt' missing) + +endif + diff --git a/dep/libusbp/build.mk b/dep/libusbp/build.mk new file mode 100644 index 00000000..90e82031 --- /dev/null +++ b/dep/libusbp/build.mk @@ -0,0 +1,26 @@ +LIBUSBP_SRCS = \ + dep/libusbp/src/async_in_pipe.c \ + dep/libusbp/src/error.c \ + dep/libusbp/src/error_hresult.c \ + dep/libusbp/src/find_device.c \ + dep/libusbp/src/linux/async_in_transfer_linux.c \ + dep/libusbp/src/linux/device_linux.c \ + dep/libusbp/src/linux/error_linux.c \ + dep/libusbp/src/linux/generic_handle_linux.c \ + dep/libusbp/src/linux/generic_interface_linux.c \ + dep/libusbp/src/linux/list_linux.c \ + dep/libusbp/src/linux/serial_port_linux.c \ + dep/libusbp/src/linux/udev_linux.c \ + dep/libusbp/src/linux/usbfd_linux.c \ + dep/libusbp/src/list.c \ + dep/libusbp/src/pipe_id.c \ + dep/libusbp/src/string.c \ + +LIBUSBP_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(LIBUSBP_SRCS)) +$(LIBUSBP_OBJS): CFLAGS += -Idep/libusbp/src -Idep/libusbp/include +LIBUSBP_LIB = $(OBJDIR)/libusbp.a +LIBUSBP_CFLAGS = -Idep/libusbp/include $(shell pkg-config --cflags libudev) +LIBUSBP_LDFLAGS = $(LIBUSBP_LIB) $(shell pkg-config --libs libudev) +$(LIBUSBP_LIB): $(LIBUSBP_OBJS) + + diff --git a/dep/stb/build.mk b/dep/stb/build.mk new file mode 100644 index 00000000..0ba63d8b --- /dev/null +++ b/dep/stb/build.mk @@ -0,0 +1,37 @@ +ifeq ($(shell $(PKG_CONFIG) stb; echo $$?), 0) + +# System libstb present. + +STB_LIB = +STB_CFLAGS := $(shell $(PKG_CONFIG) --cflags stb) +STB_LDFLAGS := $(shell $(PKG_CONFIG) --libs stb) + +else + +STB_SRCS = \ + dep/libusbp/src/async_in_pipe.c \ + dep/libusbp/src/error.c \ + dep/libusbp/src/error_hresult.c \ + dep/libusbp/src/find_device.c \ + dep/libusbp/src/linux/async_in_transfer_linux.c \ + dep/libusbp/src/linux/device_linux.c \ + dep/libusbp/src/linux/error_linux.c \ + dep/libusbp/src/linux/generic_handle_linux.c \ + dep/libusbp/src/linux/generic_interface_linux.c \ + dep/libusbp/src/linux/list_linux.c \ + dep/libusbp/src/linux/serial_port_linux.c \ + dep/libusbp/src/linux/udev_linux.c \ + dep/libusbp/src/linux/usbfd_linux.c \ + dep/libusbp/src/list.c \ + dep/libusbp/src/pipe_id.c \ + dep/libusbp/src/string.c \ + +STB_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(STB_SRCS)) +$(STB_OBJS): CFLAGS += -Idep/libusbp/src +STB_LIB = $(OBJDIR)/libubsp.a +$(STB_LIB): $(STB_OBJS) +STB_CFLAGS = +STB_LDFLAGS = $(STB_LIB) + +endif + diff --git a/lib/build.mk b/lib/build.mk new file mode 100644 index 00000000..b9d428ba --- /dev/null +++ b/lib/build.mk @@ -0,0 +1,78 @@ +LIBFLUXENGINE_SRCS = \ + lib/decoders/fluxdecoder.cc \ + lib/decoders/fluxmapreader.cc \ + lib/decoders/fmmfm.cc \ + lib/decoders/decoders.cc \ + lib/encoders/encoders.cc \ + lib/fluxsink/aufluxsink.cc \ + lib/fluxsink/fl2fluxsink.cc \ + lib/fluxsink/fluxsink.cc \ + lib/fluxsink/hardwarefluxsink.cc \ + lib/fluxsink/scpfluxsink.cc \ + lib/fluxsink/vcdfluxsink.cc \ + lib/fluxsource/cwffluxsource.cc \ + lib/fluxsource/erasefluxsource.cc \ + lib/fluxsource/fl2fluxsource.cc \ + lib/fluxsource/fluxsource.cc \ + lib/fluxsource/hardwarefluxsource.cc \ + lib/fluxsource/kryoflux.cc \ + lib/fluxsource/kryofluxfluxsource.cc \ + lib/fluxsource/scpfluxsource.cc \ + lib/fluxsource/testpatternfluxsource.cc \ + lib/imagereader/d64imagereader.cc \ + lib/imagereader/d88imagereader.cc \ + lib/imagereader/dimimagereader.cc \ + lib/imagereader/diskcopyimagereader.cc \ + lib/imagereader/fdiimagereader.cc \ + lib/imagereader/imagereader.cc \ + lib/imagereader/imdimagereader.cc \ + lib/imagereader/imgimagereader.cc \ + lib/imagereader/jv3imagereader.cc \ + lib/imagereader/nfdimagereader.cc \ + lib/imagereader/nsiimagereader.cc \ + lib/imagereader/td0imagereader.cc \ + lib/imagewriter/d64imagewriter.cc \ + lib/imagewriter/diskcopyimagewriter.cc \ + lib/imagewriter/imagewriter.cc \ + lib/imagewriter/imgimagewriter.cc \ + lib/imagewriter/ldbsimagewriter.cc \ + lib/imagewriter/nsiimagewriter.cc \ + lib/imagewriter/rawimagewriter.cc \ + lib/imagewriter/d88imagewriter.cc \ + lib/usb/fluxengineusb.cc \ + lib/usb/greaseweazle.cc \ + lib/usb/greaseweazleusb.cc \ + lib/usb/serial.cc \ + lib/usb/usb.cc \ + lib/usb/usbfinder.cc \ + lib/ldbs.cc \ + lib/logger.cc \ + lib/proto.cc \ + lib/bitmap.cc \ + lib/bytes.cc \ + lib/crc.cc \ + lib/fluxmap.cc \ + lib/readerwriter.cc \ + lib/sector.cc \ + lib/csvreader.cc \ + lib/globals.cc \ + lib/utils.cc \ + lib/flags.cc \ + lib/hexdump.cc \ + lib/mapper.cc \ + lib/image.cc \ + lib/imginputoutpututils.cc \ + +LIBFLUXENGINE_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(LIBFLUXENGINE_SRCS)) +$(LIBFLUXENGINE_SRCS): | $(PROTO_HDRS) +LIBFLUXENGINE_LIB = $(OBJDIR)/libfluxengine.a +LIBFLUXENGINE_CFLAGS = +LIBFLUXENGINE_LDFLAGS = $(LIBFLUXENGINE_LIB) + +$(LIBFLUXENGINE_LIB): $(LIBFLUXENGINE_OBJS) + +$(LIBFLUXENGINE_OBJS): CFLAGS += $(FMT_CFLAGS) +$(LIBFLUXENGINE_OBJS): CFLAGS += $(LIBARCH_CFLAGS) +$(LIBFLUXENGINE_OBJS): CFLAGS += $(LIBUSBP_CFLAGS) +$(LIBFLUXENGINE_OBJS): CFLAGS += $(PROTO_CFLAGS) + diff --git a/src/build.mk b/src/build.mk new file mode 100644 index 00000000..815b34b4 --- /dev/null +++ b/src/build.mk @@ -0,0 +1,29 @@ +include src/formats/build.mk + +FLUXENGINE_SRCS = \ + src/fe-analysedriveresponse.cc \ + src/fe-analyselayout.cc \ + src/fe-inspect.cc \ + src/fe-rawread.cc \ + src/fe-rawwrite.cc \ + src/fe-read.cc \ + src/fe-rpm.cc \ + src/fe-seek.cc \ + src/fe-testbandwidth.cc \ + src/fe-testvoltages.cc \ + src/fe-write.cc \ + src/fluxengine.cc \ + +FLUXENGINE_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(FLUXENGINE_SRCS)) +$(FLUXENGINE_SRCS): | $(PROTO_HDRS) +fluxengine.exe: $(FLUXENGINE_OBJS) + +$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), AGG) +$(call use-library, fluxengine.exe, $(FLUXENGINE_OBJS), FMT) +$(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) + diff --git a/src/formats/build.mk b/src/formats/build.mk new file mode 100644 index 00000000..dde830d9 --- /dev/null +++ b/src/formats/build.mk @@ -0,0 +1,80 @@ +FORMATS = \ + 40track_drive \ + acornadfs \ + acorndfs \ + aeslanier \ + agat840 \ + amiga \ + ampro \ + apple2_drive \ + apple2 \ + appledos \ + atarist360 \ + atarist370 \ + atarist400 \ + atarist410 \ + atarist720 \ + atarist740 \ + atarist800 \ + atarist820 \ + bk800 \ + brother120 \ + brother240 \ + commodore1541 \ + commodore1581 \ + eco1 \ + f85 \ + fb100 \ + hp9121 \ + hplif770 \ + ibm1200 \ + ibm1232 \ + ibm1440 \ + ibm180 \ + ibm360 \ + ibm720 \ + ibm \ + mac400 \ + mac800 \ + micropolis143 \ + micropolis287 \ + micropolis315 \ + micropolis630 \ + mx \ + n88basic \ + northstar175 \ + northstar350 \ + northstar87 \ + prodos \ + rx50 \ + shugart_drive \ + tids990 \ + vgi \ + victor9k_ds \ + victor9k_ss \ + zilogmcz \ + +$(OBJDIR)/protoencode.exe: $(OBJDIR)/scripts/protoencode.o +$(call use-library, $(OBJDIR)/protoencode.exe, $(OBJDIR)/scripts/protoencode.o, PROTO) + +$(OBJDIR)/src/formats/format_%.o: $(OBJDIR)/src/formats/format_%.cc +$(OBJDIR)/src/formats/format_%.cc: $(OBJDIR)/protoencode.exe src/formats/%.textpb + @mkdir -p $(dir $@) + @echo PROTOENCODE $* + @$^ $@ formats_$*_pb + +$(OBJDIR)/src/formats/table.cc: scripts/mktable.sh + @mkdir -p $(dir $@) + @echo MKTABLE $@ + @scripts/mktable.sh formats $(FORMATS) > $@ + +LIBFORMATS_SRCS = \ + $(patsubst %, $(OBJDIR)/src/formats/format_%.cc, $(FORMATS)) \ + $(OBJDIR)/src/formats/table.cc +LIBFORMATS_OBJS = $(patsubst %.cc, %.o, $(LIBFORMATS_SRCS)) +.PRECIOUS: $(LIBFORMATS_SRCS) + +LIBFORMATS_LIB = $(OBJDIR)/libformats.a +LIBFORMATS_LDFLAGS = $(LIBFORMATS_LIB) +$(LIBFORMATS_LIB): $(LIBFORMATS_OBJS) +