diff --git a/Makefile b/Makefile index b2e8448..252af13 100644 --- a/Makefile +++ b/Makefile @@ -6,69 +6,36 @@ # For details see the UNLICENSE file at the root of the source tree. # -PREFIX ?= /usr/local -# ----- Verbosity control ----------------------------------------------------- +CFLAGS += `pkg-config libxml-2.0 --cflags` +CFLAGS += -I$(CURDIR)/libs -CPP := $(CPP) # make sure changing CC won't affect CPP +LDLIBS += `pkg-config libxml-2.0 --libs` -CC_normal := $(CC) -AR_normal := $(AR) rsc -DEPEND_normal := $(CPP) $(CFLAGS) -D__OPTIMIZE__ -MM -MG - -CC_quiet = @echo " CC " $@ && $(CC_normal) -AR_quiet = @echo " AR " $@ && $(AR_normal) -DEPEND_quiet = @$(DEPEND_normal) - -ifeq ($(V),1) - CC = $(CC_normal) - AR = $(AR_normal) - DEPEND = $(DEPEND_normal) -else - CC = $(CC_quiet) - AR = $(AR_quiet) - DEPEND = $(DEPEND_quiet) -endif - -# ----- Rules ----------------------------------------------------------------- - -.PHONY: all test clean install uninstall -.SECONDARY: - -# -fno-omit-frame-pointer and -ggdb add almost nothing to execution -# time right now, so we can leave them in all the time. -CFLAGS_DBG = -fno-omit-frame-pointer -ggdb -CFLAGS += $(CFLAGS_DBG) - -CFLAGS += -Wall -Wshadow -Wmissing-prototypes -Wmissing-declarations \ - -Wno-format-zero-length -Ofast -CFLAGS += `pkg-config libxml-2.0 --cflags` -LDLIBS += `pkg-config libxml-2.0 --libs` -LDFLAGS += -Wl,-rpath,$(CURDIR) - -LIBFPGA_BIT_OBJS = bit_frames.o bit_regs.o -LIBFPGA_MODEL_OBJS = model_main.o model_tiles.o model_devices.o \ - model_ports.o model_conns.o model_switches.o model_helper.o -LIBFPGA_FLOORPLAN_OBJS = floorplan.o -LIBFPGA_CONTROL_OBJS = control.o -LIBFPGA_CORES_OBJS = parts.o helper.o +LDFLAGS += -Wl,-rpath,$(CURDIR)/libs OBJS = autotest.o bit2fp.o draw_svg_tiles.o fp2bit.o hstrrep.o \ - merge_seq.o new_fp.o pair2net.o sort_seq.o + merge_seq.o new_fp.o pair2net.o sort_seq.o hello_world.o -OBJS += $(LIBFPGA_BIT_OBJS) $(LIBFPGA_MODEL_OBJS) $(LIBFPGA_FLOORPLAN_OBJS) \ - $(LIBFPGA_CONTROL_OBJS) $(LIBFPGA_CORES_OBJS) +DYNAMIC_LIBS = libs/libfpga-model.so libs/libfpga-bit.so \ + libs/libfpga-floorplan.so libs/libfpga-control.so \ + libs/libfpga-cores.so -DYNAMIC_LIBS = libfpga-model.so libfpga-bit.so libfpga-floorplan.so \ - libfpga-control.so libfpga-cores.so - -DYNAMIC_HEADS = bit.h control.h floorplan.h helper.h model.h parts.h -#- libfpga-test autotest suite -#- libfpga-design larger design elements on top of libfpga-control +.PHONY: all test clean install uninstall FAKE +.SECONDARY: all: new_fp fp2bit bit2fp draw_svg_tiles autotest hstrrep \ sort_seq merge_seq pair2net hello_world +include Makefile.common + +%.o: %.c + $(CC) $(CFLAGS) -o $@ -c $< + $(MKDEP) + +libs/%.so: FAKE + @make -C libs $(notdir $@) + test: test_logic_cfg test_routing_sw test_logic_cfg: autotest.out/autotest_logic_cfg.diff_to_gold @@ -103,24 +70,6 @@ merge_seq: merge_seq.o $(DYNAMIC_LIBS) hstrrep: hstrrep.o $(DYNAMIC_LIBS) -libfpga-cores.so: $(addprefix build-libs/,$(LIBFPGA_CORES_OBJS)) - -libfpga-bit.so: $(addprefix build-libs/,$(LIBFPGA_BIT_OBJS)) - -libfpga-model.so: $(addprefix build-libs/,$(LIBFPGA_MODEL_OBJS)) - -libfpga-floorplan.so: $(addprefix build-libs/,$(LIBFPGA_FLOORPLAN_OBJS)) - -libfpga-control.so: $(addprefix build-libs/,$(LIBFPGA_CONTROL_OBJS)) - -%.so: - $(CC) -shared -Wl,-soname,$@ -o $@ $^ - -build-libs/%.o: %.c - @mkdir -p build-libs - $(CC) $(CFLAGS) -fPIC -o $@ -c $< - $(MKDEP) - xc6slx9.fp: new_fp ./new_fp > $@ @@ -170,13 +119,14 @@ compare_%: xc6slx9.% ./bit2fp --printf-swbits | sort > $@ clean: + @make -C libs clean + rm -f $(OBJS) *.d rm -f $(foreach test,$(TESTS),"autotest.out/autotest_$(test).diff_to_gold") rm -f $(foreach test,$(TESTS),"autotest.out/autotest_$(test).log") rmdir --ignore-fail-on-non-empty autotest.out || exit 0 - rm -rf build-libs - rm -f $(OBJS) *.d *.so \ - draw_svg_tiles new_fp hstrrep sort_seq merge_seq autotest fp2bit bit2fp pair2net \ - xc6slx9.fp xc6slx9.svg \ + rm -f draw_svg_tiles new_fp hstrrep sort_seq merge_seq autotest fp2bit bit2fp pair2net \ + hello_world + rm -f xc6slx9.fp xc6slx9.svg \ xc6slx9.tiles xc6slx9.devs xc6slx9.conns \ xc6slx9.ports xc6slx9.sw xc6slx9.cnets xc6slx9.swbits \ compare_tiles_matching.txt compare_tiles_diff.txt compare_tiles_extra.txt \ @@ -188,32 +138,11 @@ clean: compare_swbits_matching.txt compare_swbits_diff.txt compare_swbits_extra.txt install: all - mkdir -p $(DESTDIR)/$(PREFIX)/bin/ - mkdir -p $(DESTDIR)/$(PREFIX)/lib/ - install -m 755 fp2bit $(DESTDIR)/$(PREFIX)/bin/ - install -m 755 bit2fp $(DESTDIR)/$(PREFIX)/bin/ - install -m 755 $(DYNAMIC_LIBS) $(DESTDIR)/$(PREFIX)/lib/ - mkdir -p $(DESTDIR)/$(PREFIX)/include/ - install -m 644 $(DYNAMIC_HEADS) $(DESTDIR)/$(PREFIX)/include/ + @make -C libs install + mkdir -p $(DESTDIR)/$(PREFIX)/bin/ + install -m 755 fp2bit $(DESTDIR)/$(PREFIX)/bin/ + install -m 755 bit2fp $(DESTDIR)/$(PREFIX)/bin/ uninstall: - rm -f $(DESTDIR)/$(PREFIX)/bin/{fp2bit,bit2fp} - - -# ----- Dependencies ---------------------------------------------------------- - -MKDEP = \ - $(DEPEND) $< | \ - sed \ - -e 's|^$(basename $(notdir $<)).o:|$@:|' \ - -e '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \ - -e '$${g;p;}' \ - -e d >$(basename $@).d; \ - [ "$${PIPESTATUS[*]}" = "0 0" ] || \ - { rm -f $(basename $@).d; exit 1; } - -%.o: %.c - $(CC) $(CFLAGS) -o $@ -c $< - $(MKDEP) - --include $(OBJS:.o=.d) + @make -C libs uninstall + rm -f $(DESTDIR)/$(PREFIX)/bin/{fp2bit,bit2fp} diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..ff12bda --- /dev/null +++ b/Makefile.common @@ -0,0 +1,54 @@ +# +# Makefile - fpgatools +# Author: Wolfgang Spraul +# +# This is free and unencumbered software released into the public domain. +# For details see the UNLICENSE file at the root of the source tree. +# + +PREFIX ?= /usr/local + + +# -fno-omit-frame-pointer and -ggdb add almost nothing to execution +# time right now, so we can leave them in all the time. +CFLAGS_DBG = -fno-omit-frame-pointer -ggdb +CFLAGS += $(CFLAGS_DBG) + +CFLAGS += -Wall -Wshadow -Wmissing-prototypes -Wmissing-declarations \ + -Wno-format-zero-length -Ofast + +# ----- Verbosity control ----------------------------------------------------- + +CPP := $(CPP) # make sure changing CC won't affect CPP + +CC_normal := $(CC) +AR_normal := $(AR) rsc +DEPEND_normal := $(CPP) $(CFLAGS) -D__OPTIMIZE__ -MM -MG + +CC_quiet = @echo " CC " $@ && $(CC_normal) +AR_quiet = @echo " AR " $@ && $(AR_normal) +DEPEND_quiet = @$(DEPEND_normal) + +ifeq ($(V),1) + CC = $(CC_normal) + AR = $(AR_normal) + DEPEND = $(DEPEND_normal) +else + CC = $(CC_quiet) + AR = $(AR_quiet) + DEPEND = $(DEPEND_quiet) +endif + +# ----- Dependencies ---------------------------------------------------------- + +MKDEP = \ + $(DEPEND) $< | \ + sed \ + -e 's|^$(basename $(notdir $<)).o:|$@:|' \ + -e '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \ + -e '$${g;p;}' \ + -e d >$(basename $@).d; \ + [ "$${PIPESTATUS[*]}" = "0 0" ] || \ + { rm -f $(basename $@).d; exit 1; } + +-include $(OBJS:.o=.d) diff --git a/bit2fp.1 b/doc/bit2fp.1 similarity index 100% rename from bit2fp.1 rename to doc/bit2fp.1 diff --git a/fp2bit.1 b/doc/fp2bit.1 similarity index 100% rename from fp2bit.1 rename to doc/fp2bit.1 diff --git a/libs/Makefile b/libs/Makefile new file mode 100644 index 0000000..3153801 --- /dev/null +++ b/libs/Makefile @@ -0,0 +1,60 @@ +# +# Makefile - fpgatools +# Author: Wolfgang Spraul +# +# This is free and unencumbered software released into the public domain. +# For details see the UNLICENSE file at the root of the source tree. +# + + +LIBFPGA_BIT_OBJS = bit_frames.o bit_regs.o +LIBFPGA_MODEL_OBJS = model_main.o model_tiles.o model_devices.o \ + model_ports.o model_conns.o model_switches.o model_helper.o +LIBFPGA_FLOORPLAN_OBJS = floorplan.o +LIBFPGA_CONTROL_OBJS = control.o +LIBFPGA_CORES_OBJS = parts.o helper.o + +OBJS := $(LIBFPGA_CORES_OBJS) $(LIBFPGA_BIT_OBJS) $(LIBFPGA_MODEL_OBJS) \ + $(LIBFPGA_FLOORPLAN_OBJS) $(LIBFPGA_CONTROL_OBJS) + +DYNAMIC_LIBS = libfpga-model.so libfpga-bit.so libfpga-floorplan.so \ + libfpga-control.so libfpga-cores.so + +DYNAMIC_HEADS = bit.h control.h floorplan.h helper.h model.h parts.h + +.PHONY: all clean install uninstall FAKE + +all: libfpga-model.so libfpga-bit.so libfpga-floorplan.so \ + libfpga-control.so libfpga-cores.so + +include ../Makefile.common + +libfpga-cores.so: $(LIBFPGA_CORES_OBJS) + +libfpga-bit.so: $(LIBFPGA_BIT_OBJS) + +libfpga-model.so: $(LIBFPGA_MODEL_OBJS) + +libfpga-floorplan.so: $(LIBFPGA_FLOORPLAN_OBJS) + +libfpga-control.so: $(LIBFPGA_CONTROL_OBJS) + +%.so: + $(CC) -shared -Wl,-soname,$@ -o $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -fPIC -o $@ -c $< + $(MKDEP) + +clean: + rm -f *.o *.d *.so + +install: all + mkdir -p $(DESTDIR)/$(PREFIX)/lib/ + mkdir -p $(DESTDIR)/$(PREFIX)/include/ + install -m 644 $(DYNAMIC_LIBS) $(DESTDIR)/$(PREFIX)/lib/ + install -m 644 $(DYNAMIC_HEADS) $(DESTDIR)/$(PREFIX)/include/ + +uninstall: + for f in $(DYNAMIC_HEADS); do rm -f $(DESTDIR)/$(PREFIX)/include/$$f || exit 1; done + for f in $(DYNAMIC_LIBS); do rm -f $(DESTDIR)/$(PREFIX)/lib/$$f || exit 1; done diff --git a/bit.h b/libs/bit.h similarity index 100% rename from bit.h rename to libs/bit.h diff --git a/bit_frames.c b/libs/bit_frames.c similarity index 100% rename from bit_frames.c rename to libs/bit_frames.c diff --git a/bit_regs.c b/libs/bit_regs.c similarity index 100% rename from bit_regs.c rename to libs/bit_regs.c diff --git a/control.c b/libs/control.c similarity index 100% rename from control.c rename to libs/control.c diff --git a/control.h b/libs/control.h similarity index 100% rename from control.h rename to libs/control.h diff --git a/floorplan.c b/libs/floorplan.c similarity index 100% rename from floorplan.c rename to libs/floorplan.c diff --git a/floorplan.h b/libs/floorplan.h similarity index 100% rename from floorplan.h rename to libs/floorplan.h diff --git a/helper.c b/libs/helper.c similarity index 100% rename from helper.c rename to libs/helper.c diff --git a/helper.h b/libs/helper.h similarity index 100% rename from helper.h rename to libs/helper.h diff --git a/model.h b/libs/model.h similarity index 100% rename from model.h rename to libs/model.h diff --git a/model_conns.c b/libs/model_conns.c similarity index 100% rename from model_conns.c rename to libs/model_conns.c diff --git a/model_devices.c b/libs/model_devices.c similarity index 100% rename from model_devices.c rename to libs/model_devices.c diff --git a/model_helper.c b/libs/model_helper.c similarity index 100% rename from model_helper.c rename to libs/model_helper.c diff --git a/model_main.c b/libs/model_main.c similarity index 100% rename from model_main.c rename to libs/model_main.c diff --git a/model_ports.c b/libs/model_ports.c similarity index 100% rename from model_ports.c rename to libs/model_ports.c diff --git a/model_switches.c b/libs/model_switches.c similarity index 100% rename from model_switches.c rename to libs/model_switches.c diff --git a/model_tiles.c b/libs/model_tiles.c similarity index 100% rename from model_tiles.c rename to libs/model_tiles.c diff --git a/parts.c b/libs/parts.c similarity index 100% rename from parts.c rename to libs/parts.c diff --git a/parts.h b/libs/parts.h similarity index 100% rename from parts.h rename to libs/parts.h