30th November 2008, 03:52 pm
# A Makefile to compile NXC code using NBC
# Copyright (C) 2008 Gary French
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
INCLUDEDIR =../include
NBC=/usr/local/bin/nbc
NBC_FLAGS=-I=$(INCLUDEDIR)
#optional compiler optimizations
# NBC_FLAGS=-I=$(INCLUDEDIR) -Z1
# NBC_FLAGS=-I=$(INCLUDEDIR) -Z2
#this can also be explicitly set
# NXC_FILES := TheProgram.nxc
NXC_FILES := $(shell ls -1 -t -F *.nxc 2>/dev/null | grep '\.nxc')
RXE_FILES := $(NXC_FILES:.nxc=.rxe)
BYTECODE_FILES := $(NXC_FILES:.nxc=.bytecode)
LISTING_FILES := $(NXC_FILES:.nxc=.listing)
SYMTABLE_FILES := $(NXC_FILES:.nxc=.symtable)
#the targets can be called individually, or called from the "all" target
#all: compile bytecode listing symtable
all: compile
compile: $(RXE_FILES)
%.rxe: $(NXC_FILES)
@echo "compiling $<"
$(NBC) $(NBC_FLAGS) -O=$@ $<
@echo
bytecode: $(BYTECODE_FILES)
%.bytecode: $(NXC_FILES)
@echo "generating bytecode for $<"
$(NBC) $(NBC_FLAGS) -b -nbc=$@ $<
@echo
listing: $(LISTING_FILES)
%.listing: $(NXC_FILES)
@echo "generating code listing for $<"
$(NBC) $(NBC_FLAGS) -b -L=$@ $<
@echo
symtable: $(SYMTABLE_FILES)
%.symtable: $(NXC_FILES)
@echo "generating symbol table for $<"
$(NBC) $(NBC_FLAGS) -b -Y=$@ $<
@echo
clean:
@echo "cleaning up..."
-rm $(RXE_FILES)
-rm $(BYTECODE_FILES)
-rm $(LISTING_FILES)
-rm $(SYMTABLE_FILES)
@echo
.PHONY: clean bytecode listing symtable