~mcf/qbe

6cd5f7028647a88935ec1f7776a08b51eb0fb1c8 — illiliti 2 years ago 740bf86
Makefile: POSIXify

Makefile now compatible with gmake, bmake, smake and pdpmake.
7 files changed, 33 insertions(+), 43 deletions(-)

M .gitignore
M Makefile
M README
M minic/mcc
M tools/abifuzz.sh
M tools/cra.sh
M tools/test.sh
M .gitignore => .gitignore +2 -1
@@ 1,4 1,5 @@
obj
*.o
qbe
config.h
.comfile
*.out

M Makefile => Makefile +22 -31
@@ 1,8 1,8 @@
BIN = qbe
.POSIX:
.SUFFIXES: .o .c

V = @
OBJDIR = obj
PREFIX ?= /usr/local
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin

SRC      = main.c util.c parse.c cfg.c mem.c ssa.c alias.c load.c copy.c \
           fold.c live.c spill.c rega.c gas.c


@@ 11,33 11,24 @@ ARM64SRC = arm64/targ.c arm64/abi.c arm64/isel.c arm64/emit.c
RV64SRC  = rv64/targ.c rv64/abi.c rv64/isel.c rv64/emit.c
SRCALL   = $(SRC) $(AMD64SRC) $(ARM64SRC) $(RV64SRC)

AMD64OBJ = $(AMD64SRC:%.c=$(OBJDIR)/%.o)
ARM64OBJ = $(ARM64SRC:%.c=$(OBJDIR)/%.o)
RV64OBJ  = $(RV64SRC:%.c=$(OBJDIR)/%.o)
OBJ      = $(SRC:%.c=$(OBJDIR)/%.o) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)
AMD64OBJ = $(AMD64SRC:.c=.o)
ARM64OBJ = $(ARM64SRC:.c=.o)
RV64OBJ  = $(RV64SRC:.c=.o)
OBJ      = $(SRC:.c=.o) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)

CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
CFLAGS = $(CPPFLAGS) -Wall -Wextra -std=c99 -g -Wpedantic

$(OBJDIR)/$(BIN): $(OBJ) $(OBJDIR)/timestamp
	@test -z "$(V)" || echo "ld $@"
	$(V)$(CC) $(LDFLAGS) $(OBJ) -o $@
qbe: $(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) -o $@

$(OBJDIR)/%.o: %.c $(OBJDIR)/timestamp
	@test -z "$(V)" || echo "cc $<"
	$(V)$(CC) $(CFLAGS) -c $< -o $@

$(OBJDIR)/timestamp:
	@mkdir -p $(OBJDIR)
	@mkdir -p $(OBJDIR)/amd64
	@mkdir -p $(OBJDIR)/arm64
	@mkdir -p $(OBJDIR)/rv64
	@touch $@
.c.o:
	$(CC) $(CFLAGS) -c $< -o $@

$(OBJ): all.h ops.h
$(AMD64OBJ): amd64/all.h
$(ARM64OBJ): arm64/all.h
$(RV64OBJ): rv64/all.h
$(OBJDIR)/main.o: config.h
main.o: config.h

config.h:
	@case `uname` in                               \


@@ 61,26 52,26 @@ config.h:
		;;                                     \
	esac > $@

install: $(OBJDIR)/$(BIN)
	mkdir -p "$(DESTDIR)/$(PREFIX)/bin/"
	cp $< "$(DESTDIR)/$(PREFIX)/bin/"
install: qbe
	mkdir -p "$(DESTDIR)/$(BINDIR)"
	cp qbe "$(DESTDIR)/$(BINDIR)/qbe"

uninstall:
	rm -f "$(DESTDIR)/$(PREFIX)/bin/$(BIN)"
	rm -f "$(DESTDIR)/$(BINDIR)/qbe"

clean:
	rm -fr $(OBJDIR)
	rm -f *.o */*.o qbe

clean-gen: clean
	rm -f config.h

check: $(OBJDIR)/$(BIN)
check: qbe
	tools/test.sh all

check-arm64: $(OBJDIR)/$(BIN)
check-arm64: qbe
	TARGET=arm64 tools/test.sh all

check-rv64: $(OBJDIR)/$(BIN)
check-rv64: qbe
	TARGET=rv64 tools/test.sh all

src:

M README => README +4 -6
@@ 12,9 12,7 @@ The LICENSE file applies to all files distributed.

- Compilation and Installation

Invoke GNU make in this directory to create the executable
file obj/qbe.  On some systems (BSD) you might have to use
'gmake' instead of 'make'.  Install using 'make install',
the standard DESTDIR and PREFIX environment variables are
supported.  Alternatively, you may simply copy the obj/qbe
binary manually.
Invoke make in this directory to create the executable
file qbe.  Install using 'make install', the standard
DESTDIR and PREFIX environment variables are supported.
Alternatively, you may simply copy the qbe binary manually.

M minic/mcc => minic/mcc +1 -1
@@ 1,7 1,7 @@
#!/bin/sh

DIR=`cd $(dirname $0); pwd`
QBE=$DIR/../obj/qbe
QBE=$DIR/../qbe

usage()
{

M tools/abifuzz.sh => tools/abifuzz.sh +1 -1
@@ 2,7 2,7 @@

OCAMLC=${OCAMLC:-/usr/bin/ocamlc}
DIR=`cd $(dirname "$0"); pwd`
QBE=$DIR/../obj/qbe
QBE=$DIR/../qbe

failure() {
	echo "Failure at stage:" $1 >&2

M tools/cra.sh => tools/cra.sh +1 -1
@@ 1,7 1,7 @@
#!/bin/sh

DIR=`cd $(dirname "$0"); pwd`
QBE=$DIR/../obj/qbe
QBE=$DIR/../qbe
BUGF=/tmp/bug.id
FIND=$1
FIND=${FIND:-afl-find}

M tools/test.sh => tools/test.sh +2 -2
@@ 1,8 1,8 @@
#!/bin/sh

dir=`cd $(dirname "$0"); pwd`
bin=$dir/../obj/qbe
binref=$dir/../obj/qbe.ref
bin=$dir/../qbe
binref=$dir/../qbe.ref

tmp=/tmp/qbe.zzzz