mirror of
git://c9x.me/qbe.git
synced 2026-04-05 09:59:47 +00:00
POSIX specification stays:
string1 = [string2]
...
Macro expansions in string1 of macro definition lines shall
be evaluated when read. Macro expansions in string2 of macro
definition lines shall be performed when the macro identified
by string1 is expanded in a rule or command.
It means that recursive macro expansion is not guaranteed to work in
a portable Make. Also, as make is a declarative language makes more
sense to declare your targets as a primary concern instead of
derivating them from a informational macro like SRC that is only
used in a rule command.
88 lines
2.2 KiB
Makefile
88 lines
2.2 KiB
Makefile
.POSIX:
|
|
.SUFFIXES: .o .c
|
|
|
|
PREFIX = /usr/local
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
COMMOBJ = main.o util.o parse.o cfg.o mem.o ssa.o alias.o load.o copy.o \
|
|
fold.o live.o spill.o rega.o gas.o
|
|
AMD64OBJ = amd64/targ.o amd64/sysv.o amd64/isel.o amd64/emit.o
|
|
ARM64OBJ = arm64/targ.o arm64/abi.o arm64/isel.o arm64/emit.o
|
|
RV64OBJ = rv64/targ.o rv64/abi.o rv64/isel.o rv64/emit.o
|
|
OBJ = $(COMMOBJ) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)
|
|
|
|
SRCALL = $(OBJ:.o=.c)
|
|
|
|
CFLAGS = $(CPPFLAGS) -Wall -Wextra -std=c99 -g -Wpedantic
|
|
|
|
qbe: $(OBJ)
|
|
$(CC) $(LDFLAGS) $(OBJ) -o $@
|
|
|
|
.c.o:
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(OBJ): all.h ops.h
|
|
$(AMD64OBJ): amd64/all.h
|
|
$(ARM64OBJ): arm64/all.h
|
|
$(RV64OBJ): rv64/all.h
|
|
main.o: config.h
|
|
|
|
config.h:
|
|
@case `uname` in \
|
|
*Darwin*) \
|
|
echo "#define Defasm Gasmacho"; \
|
|
echo "#define Deftgt T_amd64_sysv"; \
|
|
;; \
|
|
*) \
|
|
echo "#define Defasm Gaself"; \
|
|
case `uname -m` in \
|
|
*aarch64*) \
|
|
echo "#define Deftgt T_arm64"; \
|
|
;; \
|
|
*riscv64*) \
|
|
echo "#define Deftgt T_rv64"; \
|
|
;; \
|
|
*) \
|
|
echo "#define Deftgt T_amd64_sysv";\
|
|
;; \
|
|
esac \
|
|
;; \
|
|
esac > $@
|
|
|
|
install: qbe
|
|
mkdir -p "$(DESTDIR)$(BINDIR)"
|
|
install -m755 qbe "$(DESTDIR)$(BINDIR)/qbe"
|
|
|
|
uninstall:
|
|
rm -f "$(DESTDIR)$(BINDIR)/qbe"
|
|
|
|
clean:
|
|
rm -f *.o */*.o qbe
|
|
|
|
clean-gen: clean
|
|
rm -f config.h
|
|
|
|
check: qbe
|
|
tools/test.sh all
|
|
|
|
check-arm64: qbe
|
|
TARGET=arm64 tools/test.sh all
|
|
|
|
check-rv64: qbe
|
|
TARGET=rv64 tools/test.sh all
|
|
|
|
src:
|
|
@echo $(SRCALL)
|
|
|
|
80:
|
|
@for F in $(SRCALL); \
|
|
do \
|
|
awk "{ \
|
|
gsub(/\\t/, \" \"); \
|
|
if (length(\$$0) > $@) \
|
|
printf(\"$$F:%d: %s\\n\", NR, \$$0); \
|
|
}" < $$F; \
|
|
done
|
|
|
|
.PHONY: clean clean-gen check check-arm64 src 80 install uninstall
|