qbe

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Makefile (2488B)


      1 .POSIX:
      2 .SUFFIXES: .o .c
      3 
      4 PREFIX = /usr/local
      5 BINDIR = $(PREFIX)/bin
      6 
      7 COMMOBJ  = main.o util.o parse.o abi.o cfg.o mem.o ssa.o alias.o load.o \
      8            copy.o fold.o simpl.o live.o spill.o rega.o emit.o
      9 AMD64OBJ = amd64/targ.o amd64/sysv.o amd64/isel.o amd64/emit.o
     10 ARM64OBJ = arm64/targ.o arm64/abi.o arm64/isel.o arm64/emit.o
     11 RV64OBJ  = rv64/targ.o rv64/abi.o rv64/isel.o rv64/emit.o
     12 OBJ      = $(COMMOBJ) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)
     13 
     14 SRCALL   = $(OBJ:.o=.c)
     15 
     16 CC       = cc
     17 CFLAGS   = -std=c99 -g -Wall -Wextra -Wpedantic
     18 
     19 qbe: $(OBJ)
     20 	$(CC) $(LDFLAGS) $(OBJ) -o $@
     21 
     22 .c.o:
     23 	$(CC) $(CFLAGS) -c $< -o $@
     24 
     25 $(OBJ): all.h ops.h
     26 $(AMD64OBJ): amd64/all.h
     27 $(ARM64OBJ): arm64/all.h
     28 $(RV64OBJ): rv64/all.h
     29 main.o: config.h
     30 
     31 config.h:
     32 	@case `uname` in                               \
     33 	*Darwin*)                                      \
     34 		case `uname -m` in                     \
     35 		*arm64*)                               \
     36 			echo "#define Deftgt T_arm64_apple";\
     37 			;;                             \
     38 		*)                                     \
     39 			echo "#define Deftgt T_amd64_apple";\
     40 			;;                             \
     41 		esac                                   \
     42 		;;                                     \
     43 	*)                                             \
     44 		case `uname -m` in                     \
     45 		*aarch64*|*arm64*)                     \
     46 			echo "#define Deftgt T_arm64"; \
     47 			;;                             \
     48 		*riscv64*)                             \
     49 			echo "#define Deftgt T_rv64";  \
     50 			;;                             \
     51 		*)                                     \
     52 			echo "#define Deftgt T_amd64_sysv";\
     53 			;;                             \
     54 		esac                                   \
     55 		;;                                     \
     56 	esac > $@
     57 
     58 install: qbe
     59 	mkdir -p "$(DESTDIR)$(BINDIR)"
     60 	install -m755 qbe "$(DESTDIR)$(BINDIR)/qbe"
     61 
     62 uninstall:
     63 	rm -f "$(DESTDIR)$(BINDIR)/qbe"
     64 
     65 clean:
     66 	rm -f *.o */*.o qbe
     67 
     68 clean-gen: clean
     69 	rm -f config.h
     70 
     71 check: qbe
     72 	tools/test.sh all
     73 
     74 check-arm64: qbe
     75 	TARGET=arm64 tools/test.sh all
     76 
     77 check-rv64: qbe
     78 	TARGET=rv64 tools/test.sh all
     79 
     80 src:
     81 	@echo $(SRCALL)
     82 
     83 80:
     84 	@for F in $(SRCALL);                       \
     85 	do                                         \
     86 		awk "{                             \
     87 			gsub(/\\t/, \"        \"); \
     88 			if (length(\$$0) > $@)     \
     89 				printf(\"$$F:%d: %s\\n\", NR, \$$0); \
     90 		}" < $$F;                          \
     91 	done
     92 
     93 wc:
     94 	@wc -l $(SRCALL)
     95 
     96 .PHONY: clean clean-gen check check-arm64 check-rv64 src 80 wc install uninstall