cosmopolitan/tool/calc/calc.mk
Justine Tunney 9f68d6eee9 Fix link order in cosmopolitan.a
It turned out that the linker was doing the wrong with the amalgamation
library concerning weak stubs. A regression test has been added and new
binaries have been uploaded to https://justine.lol/cosmopolitan/

Ideally this should be fixed by building a tool that turns multiple .a
files into a single .a file with deduplication. As a workaround for now
the cosmopolitan.a build is restructured to not include LIBC_STUBS which
meant technical debt needed to be paid off where non-stub interfaces
were moved to LIBC_INTRIN and LIBC_NEXGEN32E.

Thank @PerfectProductions in #31 for the report!
2021-01-16 12:05:41 -08:00

79 lines
1.8 KiB
Makefile

#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
PKGS += TOOL_CALC
TOOL_CALC = $(TOOL_LIB_A_DEPS) $(TOOL_LIB_A)
TOOL_CALC_A = o/$(MODE)/tool/calc/calc.a
TOOL_CALC_FILES := $(wildcard tool/calc/*)
TOOL_CALC_COMS = $(TOOL_CALC_OBJS:%.o=%.com)
TOOL_CALC_SRCS = $(filter %.c,$(TOOL_CALC_FILES))
TOOL_CALC_HDRS = $(filter %.h,$(TOOL_CALC_FILES))
TOOL_CALC_OBJS = \
$(TOOL_CALC_SRCS:%.c=o/$(MODE)/%.o)
TOOL_CALC_COMS = \
$(TOOL_CALC_SRCS:%.c=o/$(MODE)/%.com)
TOOL_CALC_BINS = \
$(TOOL_CALC_COMS) \
$(TOOL_CALC_COMS:%=%.dbg)
TOOL_CALC_CHECKS = \
$(TOOL_CALC_HDRS:%=o/$(MODE)/%.ok)
TOOL_CALC_DIRECTDEPS = \
LIBC_BITS \
LIBC_CALLS \
LIBC_FMT \
LIBC_INTRIN \
LIBC_LOG \
LIBC_MEM \
LIBC_NEXGEN32E \
LIBC_RAND \
LIBC_RUNTIME \
LIBC_STDIO \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_TINYMATH \
LIBC_X \
THIRD_PARTY_COMPILER_RT \
THIRD_PARTY_GDTOA
TOOL_CALC_DEPS := \
$(call uniq,$(foreach x,$(TOOL_CALC_DIRECTDEPS),$($(x))))
$(TOOL_CALC_A): \
tool/calc/ \
$(TOOL_CALC_A).pkg \
$(TOOL_CALC_OBJS)
$(TOOL_CALC_A).pkg: \
$(TOOL_CALC_OBJS) \
$(foreach x,$(TOOL_CALC_DIRECTDEPS),$($(x)_A).pkg)
o/tool/calc/calc.h.inc: o/tool/calc/calc.c.inc
o/tool/calc/calc.c.inc: \
tool/calc/calc.y \
$(THIRD_PARTY_LEMON)
@$(LEMON) -l -d$(@D) $<
o/$(MODE)/tool/calc/%.com.dbg: \
$(TOOL_CALC_DEPS) \
$(TOOL_CALC_A) \
o/$(MODE)/tool/calc/%.o \
$(TOOL_CALC_A).pkg \
$(CRT) \
$(APE)
@$(APELINK)
tool/calc/calc.c: \
o/tool/calc/calc.c.inc \
o/tool/calc/calc.h.inc
.PHONY: o/$(MODE)/tool/calc
o/$(MODE)/tool/calc: \
$(TOOL_CALC_BINS) \
$(TOOL_CALC_CHECKS)