Revision 66d8e606a8d996ded60bc81d5edf319142a5fad9 authored by Ron Burkey on 04 October 2021, 11:49:55 UTC, committed by Ron Burkey on 04 October 2021, 11:49:55 UTC
2 parent s dfc2190 + 42c2282
Raw File
Makefile.inc
# Copyright:	Public domain.
# Filename: 	Makefile.inc
# Purpose:  	Makefile include for all flights.
# Contact:  	Ron Burkey <info@sandroid.org>.
# Website:  	http://www.ibiblio.org/apollo
# Mod history:	2016-10-04 JL   Created.
#               2016-10-04 JL   Added format target.
#		2016-10-05 JL	Re-enable HTML output.
#		2016-10-11 RSB	The executable and html are now built separately,
#				rather than in one step, since they actually 
#				need different command-line switches in yaYUL
#				for optimum prettiness.
#		2016-10-21 RSB	Hadn't been accounting for the fact that 
#				oct2bin need different args for --block1.
#		2016-11-07 RSB	The 2016-10-11 change must have broken building
#				the HTML for Validation.agc, which in turn
#				broke the ability to build the installer
#				for VirtualAGC.
#		2016-11-11 RSB	Added the (optional) EXTRA_TARGETS.

# Notes: 
#
#  1. `BASENAME` must be set in the calling Makefile to the flight name.
#
#  2. Define `NO_BINSOURCE in those missions that do not have a binsource image.
#
#  3. For normal missions, a binsource is used to generate a known-good bin 
#     image, and the output of yaYUL is compared against it to check for 
#     correctness. 
#
#  4. For `Validation`, or for missions where we do not have a known-good 
#     image, the bin file generated by yaYUL is used as is. 
# 
#  5. To get yaYUL to generate HTML output, define `GEN_HTML`.

# Used by the install target, whatever that's for.
ifndef PREFIX
PREFIX=/usr/local
endif

# I removed YAYUL_ARGS, since it was basically used only one place,
# and each of the uses of yaYUL below uses different arguments.

# Enable/disable HTML generation.
GEN_HTML=yes

TARGETS=$(BASENAME).bin $(BASENAME).lst $(BASENAME).symtab
ifeq "$(BASENAME)" "Validation"
TARGETS+=$(BASENAME).txt
TOPLEVEL=Validation
else
TOPLEVEL=MAIN
endif
ifeq "$(GEN_HTML)" "yes"
TARGETS+=$(TOPLEVEL).agc.html
endif

SOURCE:=$(wildcard *.agc)

default: $(TARGETS) $(EXTRA_TARGETS)

ifdef NO_BINSOURCE
$(BASENAME).bin: $(TOPLEVEL).agc.bin
ifneq ($(BASENAME),TRIVIUM)
	mv -f $< $@
endif
else
$(BASENAME).bin: $(BASENAME).binsource
	../Tools/oct2bin $(OCT2BIN_ARGS) <$(BASENAME).binsource
	mv oct2bin.bin $@
endif

$(BASENAME).txt: $(BASENAME).bin
	../Tools/webb2burkey-rope $(BASENAME).bin $(BASENAME).txt

# Assemble the actual source files.
$(TOPLEVEL).agc.bin $(TOPLEVEL).agc.lst: $(SOURCE)
ifeq ($(BASENAME),TRIVIUM)
	@echo TRIVIUM contains intentional errors and will not be assembled.
else
	../yaYUL/yaYUL --unpound-page $(EXTRA_YAYUL_ARGS) $(TOPLEVEL).agc >$(TOPLEVEL).agc.lst
endif

# Generate HTML.
$(TOPLEVEL).agc.html: $(SOURCE)
ifeq ($(BASENAME),TRIVIUM)
	@echo The following assembly should contain 3 intentional errors.
	-../yaYUL/yaYUL --html $(EXTRA_YAYUL_ARGS) $(TOPLEVEL).agc >/dev/null
else
	../yaYUL/yaYUL --html $(EXTRA_YAYUL_ARGS) $(TOPLEVEL).agc >/dev/null
endif

# Compare rope images, and rename output files.
$(BASENAME).lst: $(TOPLEVEL).agc.bin $(TOPLEVEL).agc.lst $(BASENAME).bin
ifndef NO_BINSOURCE
	diff -s $(TOPLEVEL).agc.bin $(BASENAME).bin
endif
ifneq ($(BASENAME),TRIVIUM)
	mv $(TOPLEVEL).agc.lst $(BASENAME).lst
endif

$(BASENAME).symtab: $(BASENAME).lst
ifneq ($(BASENAME),TRIVIUM)
	mv $(TOPLEVEL).agc.symtab $(BASENAME).symtab
endif

corediff.txt: $(BASENAME).bin $(TOPLEVEL).agc.bin $(TOPLEVEL).agc.lst
ifdef NO_BINSOURCE
	@echo "No corediff for Validation!"
else
	python ../Tools/ropediff.py -p -c -a -o $@ $(BASENAME).bin $(TOPLEVEL).agc.bin
endif

clean:
	-rm -f *.lst *~ $(TOPLEVEL).agc.bin $(BASENAME).bin \
		*.symtab oct2bin.bin* *.html $(EXTRA_TARGETS)

# Recipe for reformatting an AGC source file.
%.agc.out: %.agc 
	../yaYUL/yaYUL --unpound-page $(EXTRA_YAYUL_ARGS) --format $< >$@
ifeq "$(REFORMAT)" "yes"
	mv -f $@ $<
endif

# Reformat all AGC source files.
format: $(SOURCE:.agc=.agc.out)

install: default
	cp $(BASENAME).bin ${PREFIX}/bin/
	chmod ugo+r ${PREFIX}/bin/$(BASENAME).bin
back to top