# Makefile # Version 2.0 # $Id$ # Directories CONFIG_DIR = configurations SRC_DIR = src BUILD_DIR ?= $(shell pwd) # Programs used SQLLDR ?= /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlldr TCC = tcc CONFIGURATIONS = $(basename $(notdir $(wildcard $(CONFIG_DIR)/*.cfg))) CONFIG_CFG_FILES = $(patsubst %,$(CONFIG_DIR)/%.cfg,$(CONFIGURATIONS)) CONFIG_LDR_FILES = $(patsubst %,$(BUILD_DIR)/$(CONFIG_DIR)/%.ldr,$(CONFIGURATIONS)) # Variable SCRIPTS will be set by included .depend file SCRIPT_DAT_FILES = $(patsubst %,$(BUILD_DIR)/$(SRC_DIR)/%.dat,$(SCRIPTS)) SCRIPT_LDR_FILES = $(patsubst %,$(BUILD_DIR)/$(SRC_DIR)/%.ldr,$(SCRIPTS)) #VERSION ?= $(shell svnversion .) all: build compat: $(patsubst %.cfg, $(BUILD_DIR)/%.dat, $(CONFIG_FILES)) # ---------------------------------------------------------------- # Instructions to compile .asm code for the TRAP CPUs # # First, the code for each CPU is generated separately in a # .cpuX.code file, then these files are merged into one .dat file # that can be used to program the # ---------------------------------------------------------------- # Define what should be kept aftter building .dat file .PRECIOUS: $(BUILD_DIR)/%.cpu0.code $(BUILD_DIR)/%.cpu1.code $(BUILD_DIR)/%.cpu2.code $(BUILD_DIR)/%.cpu3.code $(BUILD_DIR)/%.dat: $(BUILD_DIR)/%.cpu0.code \ $(BUILD_DIR)/%.cpu1.code \ $(BUILD_DIR)/%.cpu2.code \ $(BUILD_DIR)/%.cpu3.code codem -i0 $(BUILD_DIR)/$*.cpu0.code \ -i1 $(BUILD_DIR)/$*.cpu1.code \ -i2 $(BUILD_DIR)/$*.cpu2.code \ -i3 $(BUILD_DIR)/$*.cpu3.code \ -o $@ -3 -s127 $(BUILD_DIR)/%.v.dat: $(BUILD_DIR)/%.cpu0.code \ $(BUILD_DIR)/%.cpu1.code \ $(BUILD_DIR)/%.cpu2.code \ $(BUILD_DIR)/%.cpu3.code codem -i0 $(BUILD_DIR)/$*.cpu0.code \ -i1 $(BUILD_DIR)/$*.cpu1.code \ -i2 $(BUILD_DIR)/$*.cpu2.code \ -i3 $(BUILD_DIR)/$*.cpu3.code \ -r -o $@ -3 -s127 $(BUILD_DIR)/%.cpu0.code %.cpu0.labels.tcs: %.asm mkdir -p $(dir $@) asm_mimd -i $< -od $(BUILD_DIR)/$*.cpu0.code \ -ol $(BUILD_DIR)/$*.cpu0.log -dcpu0 \ -oa $*.cpu0.labels.tcs -oh \ $(BUILD_DIR)/$*.imem0.hex -Ve @grep -i 'warning\|error' $(BUILD_DIR)/$*.cpu0.log $(BUILD_DIR)/%.cpu1.code %.cpu1.labels.tcs: %.asm mkdir -p $(dir $@) asm_mimd -i $< -od $(BUILD_DIR)/$*.cpu1.code -ol \ $(BUILD_DIR)/$*.cpu1.log -dcpu1 \ -oa $*.cpu1.labels.tcs -oh \ $(BUILD_DIR)/$*.imem1.hex -Ve @grep -i 'warning\|error' $(BUILD_DIR)/$*.cpu1.log $(BUILD_DIR)/%.cpu2.code %.cpu2.labels.tcs: %.asm mkdir -p $(dir $@) asm_mimd -i $< -od $(BUILD_DIR)/$*.cpu2.code -ol \ $(BUILD_DIR)/$*.cpu2.log -dcpu2 \ -oa $*.cpu2.labels.tcs -oh \ $(BUILD_DIR)/$*.imem2.hex -Ve @grep -i 'warning\|error' $(BUILD_DIR)/$*.cpu2.log $(BUILD_DIR)/%.cpu3.code %.cpu3.labels.tcs: %.asm mkdir -p $(dir $@) asm_mimd -i $< -od $(BUILD_DIR)/$*.cpu3.code -ol \ $(BUILD_DIR)/$*.cpu3.log -dcpu3 \ -oa $*.cpu3.labels.tcs -oh \ $(BUILD_DIR)/$*.imem3.hex -Ve @grep -i 'warning\|error' $(BUILD_DIR)/$*.cpu3.log src/common/pattern_generator.asm: src/common/fitred.asm cat $< \ | sed -e 's/^.*#def testmode_r/#def testmode_r/' \ > $@ src/common/pattern_generator_psrg.asm: src/common/fitred.asm cat $< \ | sed -e 's/^.*#def testmode_r/#def testmode_r/' \ | sed -e 's/^.*#def psrg_r/#def psrg_r/' \ > $@ # ---------------------------------------------------- # # ---------------------------------------------------- include .depend .depend: $(shell find $(SRCDIR) -name '*.tcs' -and -not -name '*.labels.tcs' )\ $(shell find configurations -name '*.cfg') \ Makefile @echo "Recreating .depend" @rm -f $@ @echo "# Dependencies of tcs files" >> $@ @for i in $(basename $(shell find $(SRCDIR) -name '*.tcs')); do \ echo -n $(BUILD_DIR)/$$i.dat: >> $@; \ awk '/^include/ {printf " " $$2}' < $$i.tcs >> $@; \ echo >> $@; \ done; @echo "# Required scripts" >> $@ @for i in $(CONFIGURATIONS); do \ cat $(CONFIG_DIR)/$$i.cfg | \ awk '{printf "SCRIPTS += %s\n", $$1}' >> $@ ; \ done; @echo "# Dependencies of configurations" >> $@ @for i in $(CONFIGURATIONS); do \ echo "compat: $(BUILD_DIR)/$(CONFIG_DIR)/$$i.dat" >> $@; \ echo -n "$(BUILD_DIR)/$(CONFIG_DIR)/$$i.dat: " >> $@; \ cat $(CONFIG_DIR)/$$i.cfg \ | awk '{printf " $(BUILD_DIR)/src/%s.dat", $$1}' >> $@ ; \ echo >> $@ ; \ printf "\tmkdir -p $(BUILD_DIR)/$(CONFIG_DIR)\n" >> $@; \ printf "\tcat $$^ > $(BUILD_DIR)/$(CONFIG_DIR)/$$i.dat\n" >> $@ ; \ done; .PHONY: build upload #upload-config-% upload-script-% #upload: $(patsubst $(CONFIG_DIR)/%.cfg,config-%,$(wildcard $(CONFIG_DIR)/*.cfg)) #build: $(patsubst %,$(CONFIG_DIR)/%.cfg,$(CONFIGURATIONS)) $(SCRIPTS) .PRECIOUS: %.dat $(BUILD_DIR)/%.dat: %.tcs mkdir -p $(dir $@) $(TCC) $< > $@ $(BUILD_DIR)/%.dat: %.DAT mkdir -p $(dir $@) cp $< $@ $(BUILD_DIR)/$(SRC_DIR)/%.ldr: $(BUILD_DIR)/$(SRC_DIR)/%.dat echo "SCRIPT \"$*\"" > $@ # awk '{printf " cmd %5d %3d %6d %10d %10d\n", NR,$$1,$$2,$$3,$$4}' < $< >> $@ awk '{printf " cmd %-30s %5d %3d %6d %10d %10d\n", "$*",NR,$$1,$$2,$$3,$$4}' < $< >> $@ $(BUILD_DIR)/$(CONFIG_DIR)/%.ldr: $(CONFIG_DIR)/%.cfg echo "CONFIG \"$*\"" > $@ # awk '{printf " scr %5d %s\n", NR,$$1}' < $< >> $@ awk '{printf " scr %-30s %5d %s\n", "$*",NR,$$1}' < $< >> $@ upload_%: $(SQLLDR) alice/alice123@pvss01/wing control=upload/$*.sqlldr upload/%.data: $(SCRIPT_LDR_FILES) $(CONFIG_LDR_FILES) echo -n "VERSION \"$*\" [" > $@ svn info | awk '/^URL:/ {printf $$2}' >> $@ echo -n "|" >> $@ svnversion . | awk '{printf $$0}' >> $@ echo "]" >> $@ # for i in $(CONFIGURATIONS); do \ # echo "CONFIG \"$$i\"" >> $@; \ # done cat $^ >> $@ # Insert scripts upload/%.sqlldr: upload/%.data cat upload/sqlldr.header $< > $@ foo: @echo "Configurations: " $(CONFIGURATIONS) @echo "LdrScripts:" $(SCRIPT_LDR_FILES) .PHONY : clean clean : rm -f .depend find src/ -name '*.cpu?.labels.tcs' -exec rm -f '{}' ';' find $(BUILD_DIR)/src/ -name '*.cpu?.code' -exec rm -f '{}' ';' find $(BUILD_DIR)/src/ -name '*.cpu?.log' -exec rm -f '{}' ';' find $(BUILD_DIR)/src/ -name '*.imem?.hex' -exec rm -f '{}' ';' find $(BUILD_DIR)/src/ -name '*.dat' -exec rm -f '{}' ';' find $(CONFIG_DIR) -name '*.dat' -exec rm -f '{}' ';' cd tools && make clean cd tools/power && make clean tools/% : make -C tools # EOF