Skip to content

Commit

Permalink
Honour LDFLAGS to Make
Browse files Browse the repository at this point in the history
Tools can now be statically linked with "make LDFLAGS=-static tool".
  • Loading branch information
frno7 committed Apr 21, 2022
1 parent 471a8cf commit 0707601
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Define V=1 for more verbose compile.
# Define S=1 for sanitation checks.
# Define LDFLAGS=-static for statically linked tools.

CFLAGS += -Wall -Iinclude

Expand All @@ -12,6 +13,8 @@ TOOL_CFLAGS += -fsanitize=address -fsanitize=leak -fsanitize=undefined \
-fsanitize-address-use-after-scope -fstack-check
endif

TOOL_LDFLAGS += $(TOOL_CFLAGS) $(LDFLAGS)

MODULE_LD := script/iop.ld
# FIXME: -O0 -> -O2
IOP_CFLAGS += -O0 -march=r3000 -EL -msoft-float -fomit-frame-pointer \
Expand Down Expand Up @@ -57,13 +60,13 @@ $(SYMTAB_C_SYM): $(MODULE_H_ALL)
$(QUIET_GEN)$(IOPMOD_SYMC) -o $@ $(MODULE_H_ALL)

$(IOPMOD_INFO): $(IOPMOD_INFO).o $(TOOL_LIB) $(SYMTAB_C_OBJ)
$(QUIET_LINK)$(CC) $(TOOL_CFLAGS) -o $@ $^
$(QUIET_LINK)$(CC) $(TOOL_LDFLAGS) -o $@ $^

$(IOPMOD_LINK): $(IOPMOD_LINK).o $(TOOL_LIB)
$(QUIET_LINK)$(CC) $(TOOL_CFLAGS) -o $@ $^
$(QUIET_LINK)$(CC) $(TOOL_LDFLAGS) -o $@ $^

$(IOPMOD_SYMC): $(IOPMOD_SYMC).o $(TOOL_LIB)
$(QUIET_LINK)$(CC) $(TOOL_CFLAGS) -o $@ $^
$(QUIET_LINK)$(CC) $(TOOL_LDFLAGS) -o $@ $^

$(TOOL_LIB): $(TOOL_C_OBJ)
$(QUIET_AR)$(AR) rc $@ $^
Expand Down

0 comments on commit 0707601

Please sign in to comment.