1 # -*- makefile -*- for the C-level run-time support for SBCL
3 # This software is part of the SBCL system. See the README file for
6 # This software is derived from the CMU CL system, which was
7 # written at Carnegie Mellon University and released into the
8 # public domain. The software is in the public domain and is
9 # provided with absolutely no warranty. See the COPYING and CREDITS
10 # files for more information.
12 .PHONY
: all clean TAGS
tags targets
17 # Allow using paxctl(8) or similar programs to adjust PaX permissions
18 # of src/runtime/sbcl during the build.
21 # Defaults which might be overridden or modified by values in the
22 # Config file. Most of them are same on most systems right now.
23 # If you need to override one of these, do it in Config.
29 # By default, don't make and use a library, just use the object files.
34 include ..
/..
/output
/prefix.def
36 CFLAGS
+= -g
-Wall
-Wundef
-Wsign-compare
-Wpointer-arith
-O3
40 # Give make access to the target Lisp features.
41 include genesis
/Makefile.features
43 # The Config file is the preferred place for tweaking options which
44 # are appropriate for particular setups (OS, ARCH, whatever). Make a
45 # Config-foo file for setup foo, then arrange for Config to be a
46 # symlink to Config-foo.
47 # Commonly used variables in Config are: ARCH_SRC, ASSEM_SRC, GC_SRC,
52 # Disable PIE by default.
53 # We mostly do not care any more where the C code is located, and would
54 # prefer that C toolchain default be used, however, the limited address
55 # space in 32-bit architectures make it tricky to permit the .text segment
56 # to be placed arbitrarily if there is any risk of not being able to
57 # allocate the lisp readonly and static spaces on account of collision.
58 ifeq ($(DISABLE_PIE
),yes
)
59 ifneq ($(shell $(CC
) -dumpspecs
2>/dev
/null | grep
-e
'[^f]no-pie'),)
63 __LDFLAGS__
+= -no-pie
65 ifneq ($(shell $(CC
) -dumpspecs
2>/dev
/null | grep
-e
'[^f]nopie'),)
73 COMMON_SRC
= alloc.c arena.c backtrace.c breakpoint.c coalesce.c \
74 coreparse.c dynbind.c funcall.c gc-common.c globals.c \
75 hopscotch.c interr.c interrupt.c largefile.c main.c \
76 math.c monitor.c murmur_hash.c os-common.c parse.c \
77 perfecthash.c
print.c \
78 regnames.c runtime.c safepoint.c save.c \
79 sc-offset.c search.c stringspace.c thread.c time.c \
80 validate.c var-io.c vars.c wrap.c
82 ifndef LISP_FEATURE_WIN32
83 COMMON_SRC
+= run-program.c sprof.c
86 C_SRC
= $(COMMON_SRC
) ${ARCH_SRC} ${OS_SRC} ${GC_SRC}
88 SRCS
= $(C_SRC
) ${ASSEM_SRC}
90 OBJS
= $(C_SRC
:.c
=.o
) $(ASSEM_SRC
:.S
=.o
) ..
/..
/tlsf-bsd
/tlsf
/tlsf.o
92 LIBS
= ${OS_LIBS} $(LDLIBS
) -lm
94 ifdef LISP_FEATURE_SB_SAFEPOINT
100 targets
: $(TARGET
) $(OBJTARGET
) $(LDB_TARGET
) sbcl.mk
102 LDB_OBJS
= $(filter-out main.o interr.o runtime.o monitor.o thread.o safepoint.o
,$(OBJS
))
104 $(CC
) -g
$(CPPFLAGS
) $(CFLAGS
) -DSTANDALONE_LDB
-c
-o standalone-monitor.o monitor.c
105 $(CC
) -g
$(CPPFLAGS
) $(CFLAGS
) -DSTANDALONE_LDB
-c
-o standalone-interr.o interr.c
106 $(CC
) -g
$(CPPFLAGS
) $(CFLAGS
) -DSTANDALONE_LDB
-c
-o standalone-thread.o thread.c
107 $(CC
) $(LINKFLAGS
) -o ldb standalone-monitor.o standalone-interr.o standalone-thread.o \
110 $(TARGET
): $(LIBSBCL
)
111 $(CC
) ${LINKFLAGS} -o
$@
$(USE_LIBSBCL
) $(LIBS
)
114 # tests/heap-reloc/fake-mman.c assumes #+linux, so this recipe
115 # only works on linux.
116 heap-reloc-test
: ..
/..
/tests
/heap-reloc
/fake-mman.c
$(OBJS
)
117 $(CC
) ${LINKFLAGS} -o
$@ ..
/..
/tests
/heap-reloc
/fake-mman.c
$(filter-out linux-mman.o
,$(OBJS
)) $(LIBS
)
119 # Enable compiling gencgc with even more assertions and/or
120 # data collection, with COMPILING_TESTS. Not really used yet.
121 gc-unit-tests.o
: CFLAGS
=-g
-DCOMPILING_TESTS
122 unit-tests
: gc-unit-tests.o libsbcl.a
123 $(CC
) -g
-no-pie
-o
$@
$^
-ldl
-lpthread
-lm
125 # ld -r -o sbcl.o works on Linux, but not on other platforms.
126 # On macOS, it fails to keep debug sections.
127 # On mingw64, it leads to an executable that cannot be executed.
129 $(LD
) $(__LDFLAGS__
) -r
-o
$@
$^
132 rm -f
$@
; ar rcs
$@
$^
134 PIC_OBJS
= $(subst .o
,.pic.o
,$(OBJS
))
135 libsbcl.so
: $(PIC_OBJS
)
136 $(CC
) -shared
-o
$@
$^
$(LIBS
) $(SOFLAGS
)
137 # for this to work, you must have with-gcc-tls in your build features already.
138 # can't define it here because then it conflicts if you have it in both places.
140 $(CC
) -fPIC
-c
$(CPPFLAGS
) $(filter-out -fno-pie
,$(CFLAGS
)) $< -o
$@
141 %.pic.o
: %.S
# (-fPIC doesn't affect hand-written assembly source)
142 $(CC
) -c
$(CPPFLAGS
) $(CFLAGS
) $< -o
$@
144 SHRINKWRAP_DEPS
= ..
/..
/output
/sbcl.core ..
/..
/tools-for-build
/elftool.lisp
145 shrinkwrap-sbcl.s shrinkwrap-sbcl-core.o
: $(SHRINKWRAP_DEPS
)
146 ..
/..
/run-sbcl.sh
--script ..
/..
/tools-for-build
/elftool.lisp split \
147 --dynamic-space-size
256 ..
/..
/output
/sbcl.core shrinkwrap-sbcl.s
148 pie-shrinkwrap-sbcl.s pie-shrinkwrap-sbcl-core.o
: $(SHRINKWRAP_DEPS
)
149 ..
/..
/run-sbcl.sh
--script ..
/..
/tools-for-build
/elftool.lisp split
--pie \
150 ..
/..
/output
/sbcl.core pie-shrinkwrap-sbcl.s
151 # "Commas ... cannot appear in the text of an argument as written"
152 # There can not be any space after the comma on the next line,
153 # or else it becomes part of the expansion of $(comma)
155 shrinkwrap-sbcl
: shrinkwrap-sbcl.s shrinkwrap-sbcl-core.o
$(LIBSBCL
)
156 $(CC
) -no-pie
$(filter-out -Wl
$(comma
)--export-dynamic
, $(LINKFLAGS
)) \
157 $(CFLAGS
) -o
$@
$^
$(filter-out -ldl
, $(LIBS
))
158 pie-shrinkwrap-sbcl
: pie-shrinkwrap-sbcl.s pie-shrinkwrap-sbcl-core.o
$(PIC_OBJS
)
159 $(CC
) -pie
-o
$@
$^
$(LIBS
)
160 semiwrap-sbcl
: shrinkwrap-sbcl.s
$(LIBSBCL
)
161 $(CC
) $(LINKFLAGS
) $(CFLAGS
) -o
$@
$^
$(LIBS
)
164 ( echo
'CC=$(CC)' ; \
166 echo
'CFLAGS=$(CFLAGS)' ; \
167 echo
'ASFLAGS=$(ASFLAGS)' ; \
168 echo
'LINKFLAGS=$(LINKFLAGS)' ; \
169 echo
'LDFLAGS=$(LDFLAGS)' ; \
170 echo
'__LDFLAGS__=$(__LDFLAGS__)' ; \
171 echo
'LIBS=$(LIBS)' ; \
172 if
[ -n
'$(LISP_FEATURE_SB_LINKABLE_RUNTIME)' ] ; then \
173 echo
'LIBSBCL=$(LIBSBCL)' ; \
174 echo
'USE_LIBSBCL=$(USE_LIBSBCL)' ; \
178 # || true because we don't want the build to break if etags isn't there.
179 # ...but it's still nice to have it done by default.
180 HEADERS
=$(wildcard *.h genesis
/*.h
)
181 INC
=$(wildcard *.inc
)
182 TAGS
tags: $(SRCS
) $(HEADERS
) $(INC
)
183 @etags
--language
=c
$(SRCS
) $(HEADERS
) $(INC
) || true
186 -rm -f
*.
[do
] ..
/..
/tlsf-bsd
/tlsf
/tlsf.o
$(TARGET
) *.tmp libsbcl.a \
187 ldb unit-tests libsbcl.a shrinkwrap-sbcl
* sbcl.mk core
190 @
$(CC
) $(DEPEND_FLAGS
) $(CPPFLAGS
) $< > $@.tmp
; \
191 sed
's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp
> $@
; \
195 @
$(CC
) $(DEPEND_FLAGS
) $(CPPFLAGS
) $< > $@.tmp
; \
196 sed
's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp
> $@
; \
199 # By including those files, we cause GNU make to automatically re-make
200 # all dependencies of the .c file if necessary.
201 ifneq ($(MAKECMDGOALS
),clean)
202 -include $(C_SRC
:.c
=.d
) $(ASSEM_SRC
:.S
=.d
)