diff --git a/Makefile b/Makefile index 7cc70560..e6d224a2 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,13 @@ CFLAGS += -Wall -Wextra CFILES = $(wildcard *.c) +VPATH += src +INCLUDES += src + BUILD_NAME := $(shell git describe --long --always) DEFINES += BUILD_NAME='$(BUILD_NAME)' -CPPFLAGS += $(patsubst %,-D%,$(DEFINES)) +CPPFLAGS += $(patsubst %,-D%,$(DEFINES)) \ + $(patsubst %,-I%,$(INCLUDES)) all: tas tsim tas: parser.o lexer.o diff --git a/asm.c b/src/asm.c similarity index 100% rename from asm.c rename to src/asm.c diff --git a/asm.h b/src/asm.h similarity index 100% rename from asm.h rename to src/asm.h diff --git a/common.h b/src/common.h similarity index 100% rename from common.h rename to src/common.h diff --git a/lexer.l b/src/lexer.l similarity index 100% rename from lexer.l rename to src/lexer.l diff --git a/ops.h b/src/ops.h similarity index 100% rename from ops.h rename to src/ops.h diff --git a/parser.y b/src/parser.y similarity index 100% rename from parser.y rename to src/parser.y diff --git a/parser_global.h b/src/parser_global.h similarity index 100% rename from parser_global.h rename to src/parser_global.h diff --git a/tas.c b/src/tas.c similarity index 94% rename from tas.c rename to src/tas.c index 8b281569..d067e328 100644 --- a/tas.c +++ b/src/tas.c @@ -13,26 +13,6 @@ int print_disassembly(FILE *out, struct instruction *i); -static int binary_in(FILE *in, struct instruction *i) -{ - return fread(&i->u.word, 4, 1, in) == 1; -} - -static int text_in(FILE *in, struct instruction *i) -{ - return fscanf(in, "%x", &i->u.word) == 1; -} - -static int binary_out(FILE *stream, struct instruction *i) -{ - return fwrite(&i->u.word, sizeof i->u.word, 1, stream) == 1; -} - -static int text_out(FILE *stream, struct instruction *i) -{ - return fprintf(stream, "0x%08x\n", i->u.word) > 0; -} - static const char shortopts[] = "df:o:p::hV"; static const struct option longopts[] = { diff --git a/tsim.c b/src/tsim.c similarity index 100% rename from tsim.c rename to src/tsim.c