summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-14 06:41:28 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-14 06:41:28 -0800
commit3fdd7328a2f901db16305827ad664abc7736cd83 (patch)
tree5b2316e1598e0ad8ab435bce4d01e134119c3557 /Makefile
parenta8c95c296c3996869862b47590c69e54373907b2 (diff)
downloadtxr-3fdd7328a2f901db16305827ad664abc7736cd83.tar.gz
txr-3fdd7328a2f901db16305827ad664abc7736cd83.tar.bz2
txr-3fdd7328a2f901db16305827ad664abc7736cd83.zip
build: support linker flags/libs separation.
Our build system lumps all linker options together. The correct way is that linker flags are separated info flags and libs. Also, we respond to the LDFLAGS variable but ignore LDLIBS which is incorrect. Other issues are fixed. All that is fixed here. * Makefile (TXR_CFLAGS): Interpolate $(CFLAGS) last, so that options coming from CFLAGS can override previous options. (TXR_LDFLAGS): Interpolate $(LDFLAGS) last; same reason. (TXR_LDLIBS): New variable. (LINK_PROG): Put $(TXR_LDFLAGS) with the options, before the -o, and put $(TXR_LDLIBS) at the end. * configure (conf_ldlibs, platform_ldlibs): New variables. (usage text): Document platform-ldlibs and adjust documentation of platform-ldflags. (gen_config_make): Generate PLATFORM_LDLIBS and CONF_LDLIBS now needed by Makefile. (mainline): Adjusts various recipes to use conf_ldlibs instead of conf_ldflags, or in some cases both. In the case of libffi where we use pkg-config, we use the special pgk-config options to separately extract the flags and libs. We use EXTRA_LDLIBS instead of EXTRA_LDFLAGS in some conftest invocations, as necessary.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 5 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 35f95b5c..1c67c488 100644
--- a/Makefile
+++ b/Makefile
@@ -29,13 +29,12 @@
-include config.make
VERBOSE :=
-TXR_CFLAGS := $(CFLAGS)
-TXR_CFLAGS += -iquote . $(if $(top_srcdir), -iquote $(top_srcdir)) \
+TXR_CFLAGS := -iquote . $(if $(top_srcdir), -iquote $(top_srcdir)) \
$(LANG_FLAGS) $(DIAG_FLAGS) \
- $(DBG_FLAGS) $(PLATFORM_CFLAGS) $(EXTRA_FLAGS)
+ $(DBG_FLAGS) $(PLATFORM_CFLAGS) $(EXTRA_FLAGS) $(CFLAGS)
TXR_CFLAGS := $(filter-out $(REMOVE_FLAGS),$(TXR_CFLAGS))
-TXR_LDFLAGS := $(LDFLAGS)
-TXR_LDFLAGS += -lm $(CONF_LDFLAGS) $(PLATFORM_LDFLAGS) $(EXTRA_LDFLAGS)
+TXR_LDFLAGS := $(CONF_LDFLAGS) $(PLATFORM_LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS)
+TXR_LDLIBS := -lm $(CONF_LDLIBS) $(PLAFORM_LDLIBS) $(EXTRA_LDLIBS) $(LDLIBS)
ifneq ($(subst g++,@,$(notdir $(TXR_CC))),$(notdir $(TXR_CC)))
TXR_CFLAGS := $(filter-out -Wmissing-prototypes -Wstrict-prototypes,$(TXR_CFLAGS))
@@ -139,7 +138,7 @@ endef
define LINK_PROG
$(call ABBREVN,LINK)
-$(call SH,$(TXR_CC) $(1) $(TXR_CFLAGS) -o $@ $^ $(TXR_LDFLAGS))
+$(call SH,$(TXR_CC) $(1) $(TXR_CFLAGS) $(TXR_LDFLAGS) -o $@ $^ $(TXR_LDLIBS))
endef
define WINDRES