From 86949ae500d0778b7f5809ac3c4acc63d0f72bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Wed, 24 Nov 2021 12:05:22 +0100 Subject: [PATCH 1/2] Makefile.config: remove unneeded case distinction for Darwin Both cases do the same thing presently. --- Makefile.config | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Makefile.config b/Makefile.config index f141d400..93fd383d 100644 --- a/Makefile.config +++ b/Makefile.config @@ -32,13 +32,8 @@ CFLAGS += $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-neg BASE_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -I$(PREFIX)/include # Used by Cyclone to compile programs, no need for PIC there BASE_PROG_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -Wall -I$(PREFIX)/include -ifeq ($(OS),Darwin) -COMP_CFLAGS ?= $(BASE_CFLAGS) -L$(PREFIX)/lib -COMP_PROG_CFLAGS ?= $(BASE_PROG_CFLAGS) -else -COMP_CFLAGS ?= $(BASE_CFLAGS) -L$(PREFIX)/lib +COMP_CFLAGS ?= $(BASE_CFLAGS) -L$(PREFIX)/lib COMP_PROG_CFLAGS ?= $(BASE_PROG_CFLAGS) -endif # Use these lines instead for debugging or profiling #CFLAGS = -g -Wall From 9954cde738d148e412f4df64429ffb83b382ee71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Wed, 24 Nov 2021 15:32:17 +0100 Subject: [PATCH 2/2] Allow prepending include/library search path through -COPT/-CLNK This commit separates include/library search directory options from "normal" compiler/linker options and places options passed via the `-COPT`/`-CLNK` command-line flags in-between. This allows overwriting the default search paths, since contrary to all other options, the search paths must be prepend for an -I/-L option to take precedence over an existing one. This should (hopefully) make it entirely unnecessary to ever build Cyclone twice in order to have all changes in the current source tree take effect. Fixes #476 --- Makefile.config | 18 ++++++++++-------- cyclone.scm | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Makefile.config b/Makefile.config index 93fd383d..a39e0872 100644 --- a/Makefile.config +++ b/Makefile.config @@ -31,9 +31,11 @@ endif CFLAGS += $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -Iinclude BASE_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -I$(PREFIX)/include # Used by Cyclone to compile programs, no need for PIC there -BASE_PROG_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -Wall -I$(PREFIX)/include -COMP_CFLAGS ?= $(BASE_CFLAGS) -L$(PREFIX)/lib -COMP_PROG_CFLAGS ?= $(BASE_PROG_CFLAGS) +BASE_PROG_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -Wall +COMP_CFLAGS ?= $(BASE_CFLAGS) +COMP_LIBDIRS ?= -L$(PREFIX)/lib +COMP_INCDIRS ?= -I$(PREFIX)/include +COMP_PROG_CFLAGS ?= $(BASE_PROG_CFLAGS) # Use these lines instead for debugging or profiling #CFLAGS = -g -Wall @@ -57,15 +59,15 @@ endif # concurrencykit was installed via Ports, it won't be picked up without explicitly looking # for it here ifeq ($(OS),FreeBSD) -LDFLAGS += -L/usr/local/lib -CFLAGS += -I/usr/local/include +COMP_LIBDIRS += -L/usr/local/lib +COMP_INCDIRS += -I/usr/local/include endif # Commands "baked into" cyclone for invoking the C compiler -CC_PROG ?= "$(CC) ~src-file~ $(COMP_PROG_CFLAGS) -c -o ~exec-file~.o" -CC_EXEC ?= "$(CC) ~exec-file~.o ~obj-files~ $(LIBS) $(COMP_CFLAGS) -o ~exec-file~" -CC_LIB ?= "$(CC) ~src-file~ $(COMP_CFLAGS) -c -o ~exec-file~.o" +CC_PROG ?= "$(CC) ~src-file~ $(COMP_PROG_CFLAGS) ~cc-extra~ $(COMP_INCDIRS) -c -o ~exec-file~.o" +CC_EXEC ?= "$(CC) ~exec-file~.o ~obj-files~ $(LIBS) $(COMP_CFLAGS) ~ld-extra~ $(COMP_LIBDIRS) -o ~exec-file~" +CC_LIB ?= "$(CC) ~src-file~ $(COMP_CFLAGS) ~cc-extra~ $(COMP_LIBDIRS) -c -o ~exec-file~.o" CC_SO ?= "$(CC) -shared $(LDFLAGS) -o ~exec-file~.so ~exec-file~.o" AR ?= ar diff --git a/cyclone.scm b/cyclone.scm index 5e6d2c2a..d66e6104 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -882,27 +882,27 @@ (string-append (string-replace-all (string-replace-all - ;(Cyc-compilation-environment 'cc-prog) - (get-comp-env 'cc-prog cc-prog) - "~src-file~" src-file) + (string-replace-all + ;(Cyc-compilation-environment 'cc-prog) + (get-comp-env 'cc-prog cc-prog) + "~src-file~" src-file) + "~cc-extra~" cc-opts) "~exec-file~" exec-file) " " - cc-opts - " " cc-opts*)) (comp-objs-cmd (string-append (string-replace-all (string-replace-all (string-replace-all - ;(Cyc-compilation-environment 'cc-exec) - (get-comp-env 'cc-exec cc-exec) - "~exec-file~" exec-file) + (string-replace-all + ;(Cyc-compilation-environment 'cc-exec) + (get-comp-env 'cc-exec cc-exec) + "~exec-file~" exec-file) + "~ld-extra~" cc-prog-linker-opts) "~obj-files~" objs-str) "~exec-file~" exec-file) " " - cc-prog-linker-opts - " " c-linker-options ))) ;(write `(DEBUG all imports ,lib-deps objs ,objs-str)) @@ -922,12 +922,12 @@ (string-append (string-replace-all (string-replace-all - (get-comp-env 'cc-lib cc-lib) - "~src-file~" src-file) + (string-replace-all + (get-comp-env 'cc-lib cc-lib) + "~src-file~" src-file) + "~cc-extra~" cc-opts) "~exec-file~" exec-file) " " - cc-opts - " " cc-opts*)) (comp-so-cmd (string-append