view Makefile @ 241:d0e9dbe9afbe

Add new heuristic for resolving instruction sizes. Add new heuristic for resolving instruction sizes. This applies to the the decision between extended and base page addressing by calculating the range of possible addresses (if reasonably knowable) and deciding on whether to force extended addressing based on that. (If the whole range is outside the direct page, extended addressing is required.)
author William Astle <lost@l-w.ca>
date Sun, 23 Sep 2012 13:06:43 -0600
parents d4cf2e139e4a
children b97460509c3d
line wrap: on
line source

# define anything system specific here
#
# set these variables if needed
# PROGSUFFIX: suffix added to binaries
# BUILDTPREFIX: prefix added to build utilities (cc, etc.) for xcompile
# can also set them when invoking "make"
#PROGSUFFIX := .exe
#BUILDTPREFIX=i586-mingw32msvc-

# C compiler
CC := $(BUILDTPREFIX)cc

# ar
AR := $(BUILDTPREFIX)ar

# ranlib
RANLIB := $(BUILDTPREFIX)ranlib

CPPFLAGS += -I lwlib -DPACKAGE_STRING='"lwtools 4.7"'
LDFLAGS += -L$(PWD)/lwlib -llw

CFLAGS ?= -g -Wall

MAIN_TARGETS := lwasm/lwasm$(PROGSUFFIX) \
	lwlink/lwlink$(PROGSUFFIX) \
	lwar/lwar$(PROGSUFFIX) \
	lwlink/lwobjdump$(PROGSUFFIX)

.PHONY: all
all: $(MAIN_TARGETS)

lwar_srcs := add.c extract.c list.c lwar.c main.c remove.c replace.c
lwar_srcs := $(addprefix lwar/,$(lwar_srcs))

lwlib_srcs := lw_alloc.c lw_realloc.c lw_free.c lw_error.c lw_expr.c \
	lw_stack.c lw_string.c lw_stringlist.c lw_cmdline.c
lwlib_srcs := $(addprefix lwlib/,$(lwlib_srcs))

lwlink_srcs := main.c lwlink.c readfiles.c expr.c script.c link.c output.c map.c
lwobjdump_srcs := objdump.c
lwlink_srcs := $(addprefix lwlink/,$(lwlink_srcs))
lwobjdump_srcs := $(addprefix lwlink/,$(lwobjdump_srcs))

lwcc_srcs :=  lwcc.c
lwcc_srcs := $(addprefix lwcc/,$(lwcc_srcs))
lwcpp_srcs := lwcpp.c
lwcpp_srcs := $(addprefix lwcc/cpp/,$(lwcpp_srcs))

lwasm_srcs :=  debug.c input.c insn_bitbit.c insn_gen.c insn_indexed.c \
	insn_inh.c insn_logicmem.c insn_rel.c insn_rlist.c insn_rtor.c insn_tfm.c \
	instab.c list.c lwasm.c macro.c main.c os9.c output.c pass1.c pass2.c \
	pass3.c pass4.c pass5.c pass6.c pass7.c pragma.c pseudo.c section.c \
	struct.c symbol.c unicorns.c
lwasm_srcs := $(addprefix lwasm/,$(lwasm_srcs))

lwasm_objs := $(lwasm_srcs:.c=.o)
lwlink_objs := $(lwlink_srcs:.c=.o)
lwar_objs := $(lwar_srcs:.c=.o)
lwlib_objs := $(lwlib_srcs:.c=.o)
lwobjdump_objs := $(lwobjdump_srcs:.c=.o)
lwcc_objs := $(lwcc_srcs:.c=.o)
lwcpp_objs := $(lwcpp_srcs:.c=.o)

lwasm_deps := $(lwasm_srcs:.c=.d)
lwlink_deps := $(lwlink_srcs:.c=.d)
lwar_deps := $(lwar_srcs:.c=.d)
lwlib_deps := $(lwlib_srcs:.c=.d)
lwobjdump_deps := $(lwobjdump_srcs:.c=.d)
lwcc_deps := $(lwcc_srcs:.c=.d)
lwcpp_deps := $(lwcpp_srcs:.c=.d)

.PHONY: lwlink lwasm lwar lwobjdump lwcc lwcpp
lwlink: lwlink/lwlink$(PROGSUFFIX)
lwasm: lwasm/lwasm$(PROGSUFFIX)
lwar: lwar/lwar$(PROGSUFFIX)
lwobjdump: lwlink/lwobjdump$(PROGSUFFIX)
lwcc: lwcc/lwcc$(PROGSUFFIX)
lwcpp: lwcc/lwcpp$(PROGSUFFIX)

.PHONY: lwbasic
lwbasic: lwbasic/lwbasic$(PROGSUFFIX)

lwasm/lwasm$(PROGSUFFIX): $(lwasm_objs) lwlib
	@echo Linking $@
	@$(CC) -o $@ $(lwasm_objs) $(LDFLAGS)

lwlink/lwlink$(PROGSUFFIX): $(lwlink_objs) lwlib
	@echo Linking $@
	@$(CC) -o $@ $(lwlink_objs) $(LDFLAGS)

lwlink/lwobjdump$(PROGSUFFIX): $(lwobjdump_objs) lwlib
	@echo Linking $@
	@$(CC) -o $@ $(lwobjdump_objs) $(LDFLAGS)

lwar/lwar$(PROGSUFFIX): $(lwar_objs) lwlib
	@echo Linking $@
	@$(CC) -o $@ $(lwar_objs) $(LDFLAGS)

lwcc/lwcc$(PROGSUFFIX): $(lwcc_objs) lwlib
	@echo Linking $@
	@$(CC) -o $@ $(lwcc_objs) $(LDFLAGS)

lwcc/lwcpp$(PROGSUFFIX): $(lwcpp_objs) lwlib
	@echo Linking $@
	@$(CC) -o $@ $(lwcpp_objs) $(LDFLAGS)


#.PHONY: lwlib
.INTERMEDIATE: lwlib
lwlib: lwlib/liblw.a

lwlib/liblw.a: $(lwlib_objs)
	@echo Linking $@
	@$(AR) rc $@ $(lwlib_objs)
	@$(RANLIB) $@

alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) $(lwcc_deps)

-include $(alldeps)

extra_clean := $(extra_clean) *~ */*~

%.o: %.c
	@echo "Building dependencies for $@"
	@$(CC) -MM $(CPPFLAGS) -o $*.d $<
	@mv -f $*.d $*.d.tmp
	@sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d
	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
	@rm -f $*.d.tmp
	@echo Building $@
	@$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
	

.PHONY: clean
clean: $(cleantargs)
	@echo "Cleaning up"
	@rm -f lwlib/liblw.a lwasm/lwasm$(PROGSUFFIX) lwlink/lwlink$(PROGSUFFIX) lwlink/lwobjdump$(PROGSUFFIX) lwar/lwar$(PROGSUFFIX) lwcc/lwcc$(PROGSUFFIX)
	@rm -f $(lwasm_objs) $(lwlink_objs) $(lwar_objs) $(lwlib_objs) $(lwobjdump_objs) $(lwcc_objs) $(lwcpp_objs)
	@rm -f $(extra_clean)
	@rm -f */*.exe

.PHONY: realclean
realclean: clean $(realcleantargs)
	@echo "Cleaning up even more"
	@rm -f $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) $(lwobjdump_deps) $(lwcc_deps) $(lwcpp_deps)
	@rm -f docs/manual/*.html docs/manual/*.pdf

print-%:
	@echo $* = $($*)

.PHONY: install
install:
	cp $(MAIN_TARGETS) /usr/local/bin/

.PHONY: test
test: all test/runtests
	@test/runtests

.PHONY: manual
manual: manual-html manual-htmlm manual-pdf

.PHONY: manual-html
manual-html: docs/manual/manual.html

.PHONY: manual-htmlm
manual-htmlm: docs/manual/index.html

.PHONY: manual-pdf
manual-pdf: docs/manual/manual.pdf

docs/manual/manual.html: docs/manual.docbook.sgml
	docbook2html -o docs -u docs/manual.docbook.sgml && mv docs/manual.docbook.html docs/manual/manual.html

docs/manual/index.html: docs/manual.docbook.sgml
	docbook2html -o docs/manual docsmanual.docbook.sgml

docs/manual/manual.pdf: docs/manual.docbook.sgml
	docbook2pdf -o docs -u docsmanual.docbook.sgml && mv docs/manual.docbook.pdf docs/manual/manual.pdf && rm -f docs/manual.docbook.html