hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

Makefile (3588B)


      1 .POSIX:
      2 
      3 all:
      4 
      5 include config.mk
      6 include makefiles/$(PLATFORM).$(ARCH).mk
      7 
      8 all: $(BINOUT)/hare $(BINOUT)/haredoc docs
      9 
     10 HARE_DEFINES = \
     11 	-D PLATFORM:str='"$(PLATFORM)"' \
     12 	-D ARCH:str='"$(ARCH)"' \
     13 	-D VERSION:str="\"$(VERSION)\"" \
     14 	-D HAREPATH:str='"$(HAREPATH)"' \
     15 	-D AARCH64_AS:str='"$(AARCH64_AS)"' \
     16 	-D AARCH64_CC:str='"$(AARCH64_CC)"' \
     17 	-D AARCH64_LD:str='"$(AARCH64_LD)"' \
     18 	-D RISCV64_AS:str='"$(RISCV64_AS)"' \
     19 	-D RISCV64_CC:str='"$(RISCV64_CC)"' \
     20 	-D RISCV64_LD:str='"$(RISCV64_LD)"' \
     21 	-D X86_64_AS:str='"$(X86_64_AS)"' \
     22 	-D X86_64_CC:str='"$(X86_64_CC)"' \
     23 	-D X86_64_LD:str='"$(X86_64_LD)"'
     24 
     25 .SUFFIXES:
     26 .SUFFIXES: .ha .ssa .td .s .o .scd
     27 .ssa.td:
     28 	@cmp -s '$@' '$@.tmp' 2>/dev/null || cp '$@.tmp' '$@'
     29 
     30 .ssa.s:
     31 	@printf 'QBE\t%s\n' '$@'
     32 	@$(QBE) $(QBEFLAGS) -o '$@' '$<'
     33 
     34 .s.o:
     35 	@printf 'AS\t%s\n' '$@'
     36 	@$(AS) $(ASFLAGS) -o '$@' '$<'
     37 
     38 .scd:
     39 	@printf 'SCDOC\t%s\n' '$@'
     40 	@$(SCDOC) < '$<' > '$@'
     41 
     42 $(BINOUT)/hare: $(OBJS)
     43 	@mkdir -p -- "$(BINOUT)"
     44 	@printf 'LD\t%s\n' "$@"
     45 	@$(LD) $(LDLINKFLAGS) -T $(RTSCRIPT) -o $@ $(OBJS)
     46 
     47 HARE_BUILD_ENV = HAREPATH=. HAREC="$(HAREC)" QBE="$(QBE)" AS="$(AS)" \
     48 	LD="$(LD)" HAREFLAGS="$(HAREFLAGS)" HARECFLAGS="$(HARECFLAGS)" \
     49 	QBEFLAGS="$(QBEFLAGS)" ASFLAGS="$(ASFLAGS)" LDLINKFLAGS="$(LDLINKFLAGS)"
     50 
     51 $(BINOUT)/harec2: $(BINOUT)/hare
     52 	@printf 'HARE\t%s\n' "$@"
     53 	@env $(HARE_BUILD_ENV) \
     54 		$(BINOUT)/hare build $(HARE_DEFINES) -o $(BINOUT)/harec2 cmd/harec
     55 
     56 $(BINOUT)/haredoc: $(BINOUT)/hare
     57 	@mkdir -p $(BINOUT)
     58 	@printf 'HARE\t%s\n' "$@"
     59 	@env $(HARE_BUILD_ENV) \
     60 		$(BINOUT)/hare build $(HARE_DEFINES) -o $(BINOUT)/haredoc ./cmd/haredoc
     61 
     62 docs/html: $(BINOUT)/haredoc
     63 	mkdir -p docs/html
     64 	$(BINOUT)/haredoc -Fhtml > docs/html/index.html
     65 	for d in $$(scripts/moddirs); do \
     66 		find $$d -type d | sed -E '/(\+|-)/d'; \
     67 	done \
     68 	| while read path; do \
     69 		mod=$$(echo $$path | sed -E 's@/@::@g'); \
     70 		echo $$mod; \
     71 		mkdir -p docs/html/$$path; \
     72 		$(BINOUT)/haredoc -Fhtml $$mod > docs/html/$$path/index.html; \
     73 	done
     74 
     75 docs: \
     76 	docs/hare.1 \
     77 	docs/hare-build.1 \
     78 	docs/hare-cache.1 \
     79 	docs/hare-deps.1 \
     80 	docs/haredoc.1 \
     81 	docs/hare-run.1 \
     82 	docs/hare-test.1 \
     83 	docs/haredoc.5 \
     84 	docs/hare-module.5
     85 
     86 MAN1 = hare hare-build hare-cache hare-deps haredoc hare-run hare-test
     87 MAN5 = haredoc hare-module
     88 
     89 bootstrap:
     90 	@BINOUT=$(BINOUT) ./scripts/genbootstrap
     91 
     92 clean:
     93 	rm -rf -- '$(HARECACHE)' '$(BINOUT)' docs/*.1 docs/*.5 docs/html
     94 
     95 check: $(BINOUT)/hare
     96 	@env HAREPATH=. HAREC='$(HAREC)' QBE='$(QBE)' AS='$(AS)' LD='$(LD)' \
     97 		HAREFLAGS='$(HAREFLAGS)' HARECFLAGS='$(HARECFLAGS)' \
     98 		QBEFLAGS='$(QBEFLAGS)' ASFLAGS='$(ASFLAGS)' \
     99 		LDLINKFLAGS='$(LDLINKFLAGS)' '$(BINOUT)/hare' test
    100 
    101 install: install-cmd install-mods
    102 
    103 install-cmd:
    104 	mkdir -p -- \
    105 		'$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1' \
    106 		'$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man5'
    107 	install -m755 '$(BINOUT)/hare' '$(DESTDIR)$(BINDIR)/hare'
    108 	install -m755 '$(BINOUT)/haredoc' '$(DESTDIR)$(BINDIR)/haredoc'
    109 	for i in $(MAN1); do install -m644 docs/$$i.1 '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done
    110 	for i in $(MAN5); do install -m644 docs/$$i.5 '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done
    111 
    112 install-mods:
    113 	rm -rf -- '$(DESTDIR)$(STDLIB)'
    114 	mkdir -p -- '$(DESTDIR)$(STDLIB)'
    115 	cp -R -- $$(scripts/moddirs) '$(DESTDIR)$(STDLIB)'
    116 
    117 uninstall:
    118 	rm -- '$(DESTDIR)$(BINDIR)/hare'
    119 	rm -- '$(DESTDIR)$(BINDIR)/haredoc'
    120 	for i in $(MAN1); do rm -- '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done
    121 	for i in $(MAN5); do rm -- '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done
    122 	rm -r -- '$(DESTDIR)$(STDLIB)'
    123 
    124 .PHONY: all $(BINOUT)/harec2 $(BINOUT)/haredoc bootstrap clean check docs \
    125 	docs/html install start uninstall