# How to compile:
# make -fMkfiles/Makefile.dj
-CFLAGS=-DHAVE_CONFIG_H -IMkfiles/dj -O2 -I. -Ifrontends/yasm
-CC=gcc
+CFLAGS=-DHAVE_CONFIG_H -IMkfiles/dj -O -I.
+CC?=gcc
+BUILDCC?=$(CC)
all: yasm
$(MODULES_OBJS)
genmacro: modules/preprocs/nasm/genmacro.c
- $(CC) -o genmacro modules/preprocs/nasm/genmacro.c
+ $(BUILDCC) -o $@ $<
nasm-macros.c: modules/preprocs/nasm/standard.mac genmacro
- ./genmacro modules/preprocs/nasm/standard.mac
+ ./genmacro $<
modules/preprocs/nasm/nasm-pp.c: nasm-macros.c
genmodule: libyasm/genmodule.c
- $(CC) -o genmodule libyasm/genmodule.c
+ $(BUILDCC) -o $@ $<
module.c: libyasm/module.in genmodule
- ./genmodule libyasm/module.in $(YASM_MODULES)
+ ./genmodule $< $(YASM_MODULES)
+
+x86id.c: modules/arch/x86/x86id.re re2c
+ ./re2c -s -o $@ $<
+
+lc3bid.c: modules/arch/lc3b/lc3bid.re re2c
+ ./re2c -s -o $@ $<
+
+gas-token.c: modules/parsers/gas/gas-token.re re2c
+ ./re2c -b -o $@ $<
+
+nasm-token.c: modules/parsers/nasm/nasm-token.re re2c
+ ./re2c -b -o $@ $<
+
+RE2C_SRCS= \
+ tools/re2c/main.c \
+ tools/re2c/code.c \
+ tools/re2c/dfa.c \
+ re2c-parser.c \
+ tools/re2c/actions.c \
+ tools/re2c/scanner.c \
+ tools/re2c/mbo_getopt.c \
+ tools/re2c/substr.c \
+ tools/re2c/translate.c
+
+re2c: $(RE2C_SRCS)
+ $(BUILDCC) -I. -o re2c $(RE2C_SRCS)
yasm: $(YASM_OBJS)
$(CC) -o yasm $(YASM_OBJS)
# CFLAGS appropriately, along with writing a config.h for the platform and
# placing it in a libyasm subdirectory.
-CFLAGS=-DHAVE_CONFIG_H -IMkfiles -I. -Ifrontends/yasm
-CC=gcc
+CFLAGS=-DHAVE_CONFIG_H -IMkfiles -I.
+CC?=gcc
+BUILDCC?=$(CC)
all: yasm
$(MODULES_OBJS)
genmacro: modules/preprocs/nasm/genmacro.c
- $(CC) -o genmacro modules/preprocs/nasm/genmacro.c
+ $(BUILDCC) -o $@ $<
nasm-macros.c: modules/preprocs/nasm/standard.mac genmacro
- ./genmacro modules/preprocs/nasm/standard.mac
+ ./genmacro $<
modules/preprocs/nasm/nasm-pp.c: nasm-macros.c
genmodule: libyasm/genmodule.c
- $(CC) -o genmodule libyasm/genmodule.c
+ $(BUILDCC) -o $@ $<
module.c: libyasm/module.in genmodule
- ./genmodule libyasm/module.in $(YASM_MODULES)
+ ./genmodule $< $(YASM_MODULES)
+
+x86id.c: modules/arch/x86/x86id.re re2c
+ ./re2c -s -o $@ $<
+
+lc3bid.c: modules/arch/lc3b/lc3bid.re re2c
+ ./re2c -s -o $@ $<
+
+gas-token.c: modules/parsers/gas/gas-token.re re2c
+ ./re2c -b -o $@ $<
+
+nasm-token.c: modules/parsers/nasm/nasm-token.re re2c
+ ./re2c -b -o $@ $<
+
+RE2C_SRCS= \
+ tools/re2c/main.c \
+ tools/re2c/code.c \
+ tools/re2c/dfa.c \
+ re2c-parser.c \
+ tools/re2c/actions.c \
+ tools/re2c/scanner.c \
+ tools/re2c/mbo_getopt.c \
+ tools/re2c/substr.c \
+ tools/re2c/translate.c
+
+re2c: $(RE2C_SRCS)
+ $(BUILDCC) -I. -o re2c $(RE2C_SRCS)
yasm: $(YASM_OBJS)
$(CC) -o yasm $(YASM_OBJS)