# Makefile # Version 2.0 # $Id$ SHELL = /bin/bash # 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 DOSUNIX ?= dos2unix --keepdate -q GENERATED_CONFIGS_BASE = $(shell ./create_cfg.awk \ outfile=/dev/null report=name gen_configs.list) GENERATED_CONFIGS = $(patsubst %, cf_%, $(GENERATED_CONFIGS_BASE)) USER_CONFIGS = $(basename $(filter-out cf_%.cfg, \ $(notdir $(wildcard $(CONFIG_DIR)/*.cfg)))) CONFIGURATIONS = $(USER_CONFIGS) $(GENERATED_CONFIGS) 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 .) .PHONY: help help: @echo @echo usage: @echo make upload/VERSION.sqlldr - build sqlldr file for upload to wingDB @echo @echo @echo @echo 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 # ------------------------------------------------------------ # Rules to create configurations according to standard naming # ------------------------------------------------------------ $(patsubst %,configurations/%.cfg, $(GENERATED_CONFIGS)): \ create_cfg.awk gen_configs.list ./create_cfg.awk report=input gen_configs.list # ---------------------------------------------------- # # ---------------------------------------------------- include .depend .depend: \ $(shell find src -name '*.tcs' -and -not -name '*.labels.tcs' )\ $(shell find configurations -name '*.cfg') \ gen_configs.list create_cfg.awk \ Makefile @echo "Recreating .depend" @rm -f $@ @echo "# Dependencies of tcs files" >> $@ @for i in $(basename $(shell find src -name '*.tcs')); do \ echo -n $(BUILD_DIR)/$$i.dat: >> $@; \ $(DOSUNIX) $$i.tcs; \ awk '/^include/ {printf " " $$2}' < $$i.tcs >> $@; \ echo >> $@; \ done; @echo "# Required scripts" >> $@ @for i in $(USER_CONFIGS); do \ cat $(CONFIG_DIR)/$$i.cfg | \ awk '{printf "SCRIPTS += %s\n", $$1}' >> $@ ; \ done; @./create_cfg.awk outfile=/dev/stdout gen_configs.list | \ awk '{printf "SCRIPTS += %s\n", $$1}' >> $@ ; @echo "# Dependencies of configurations" >> $@ @for i in $(USER_CONFIGS); 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; @for i in $(GENERATED_CONFIGS_BASE); do \ echo "compat: $(BUILD_DIR)/$(CONFIG_DIR)/cf_$$i.dat" >> $@; \ echo -n "$(BUILD_DIR)/$(CONFIG_DIR)/cf_$$i.dat: " >> $@; \ echo $$i | ./create_cfg.awk -F_ outfile=/dev/stdout \ | awk '{printf " $(BUILD_DIR)/src/%s.dat", $$1}' >> $@ ; \ echo >> $@ ; \ printf "\tmkdir -p $(BUILD_DIR)/$(CONFIG_DIR)\n" >> $@; \ printf "\tcat $$^ > $(BUILD_DIR)/$(CONFIG_DIR)/cf_$$i.dat\n" >> $@ ; \ done; .PHONY: build upload .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 %-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 %-30s %5d %s\n", "$*",NR,$$1}' < $< >> $@ #$(BUILD_DIR)/$(CONFIG_DIR)/cf_%.ldr: $(CONFIG_DIR)/cf_%.cfg # echo "CONFIG \"cf_$*\"" > $@ # awk '{printf " scr %-30s %5d %s\n", "cf_$*",NR,$$1}' < $< >> $@ .PRECIOUS: upload/%.sqlldr upload_%: upload/%.sqlldr $(SQLLDR) alice/alice123@pvss01/wing control=$< upload/%.data: $(SCRIPT_LDR_FILES) $(sort $(CONFIG_LDR_FILES)) echo -n "VERSION \"$*\" [" > $@ svn info | awk '/^URL:/ {printf $$2}' >> $@ echo -n "|" >> $@ svnversion . | awk '{printf $$0}' >> $@ echo "]" >> $@ cat $^ >> $@ # Insert scripts upload/%.sqlldr: upload/%.data cat upload/sqlldr.header $< > $@ .PHONY: check show check: show show: @echo @echo "Configurations: " @echo @for i in $(sort $(CONFIGURATIONS)); do \ echo " $$i"; \ done; @echo @echo "LdrScripts:" @echo @for i in $(sort $(SCRIPTS)); do \ if [ -f src/$$i.tcs ] ; then \ echo -n "tcs "; \ elif [ -f src/$$i.asm ] ; then \ echo -n "asm "; \ elif [ -f src/$$i.DAT ] ; then \ echo -n "dat "; \ else \ echo -n "MISSING "; \ fi; \ echo "$$i"; \ done; .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