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 # Defaults which might be overridden or modified by values in the
18 # Config file. Most of them are same on most systems right now.
19 # If you need to override one of these, do it in Config.
26 # By default, don't make and use a library, just use the object files.
31 include ..
/..
/output
/prefix.def
33 CFLAGS
+= -g
-Wall
-Wundef
-Wsign-compare
-Wpointer-arith
-O3
35 CPPFLAGS
+= -I.
-DSBCL_PREFIX
=\"$(SBCL_PREFIX
)\"
37 # Give make access to the target Lisp features.
38 include genesis
/Makefile.features
40 # The Config file is the preferred place for tweaking options which
41 # are appropriate for particular setups (OS, ARCH, whatever). Make a
42 # Config-foo file for setup foo, then arrange for Config to be a
43 # symlink to Config-foo.
44 # Commonly used variables in Config are: ARCH_SRC, ASSEM_SRC, GC_SRC,
45 # OS_SRC, OS_LIBS, OS_CLEAN_FILES
48 # Disable PIE when possible
49 ifneq ($(shell $(CC
) -dumpspecs
2>/dev
/null | grep
-e
'[^f]no-pie'),)
53 __LDFLAGS__
+= -no-pie
55 ifneq ($(shell $(CC
) -dumpspecs
2>/dev
/null | grep
-e
'[^f]nopie'),)
62 COMMON_SRC
= alloc.c backtrace.c breakpoint.c coreparse.c dynbind.c \
63 funcall.c gc-common.c globals.c hopscotch.c interr.c interrupt.c\
64 largefile.c monitor.c murmur_hash.c os-common.c parse.c
print.c \
65 purify.c pthread-futex.c regnames.c run-program.c runtime.c \
66 safepoint.c save.c sc-offset.c search.c thread.c time.c \
67 validate.c var-io.c vars.c wrap.c
69 C_SRC
= $(COMMON_SRC
) ${ARCH_SRC} ${OS_SRC} ${GC_SRC}
71 SRCS
= $(C_SRC
) ${ASSEM_SRC}
73 OBJS
= $(C_SRC
:.c
=.o
) $(ASSEM_SRC
:.S
=.o
)
77 targets
: $(TARGET
) $(OBJTARGET
) sbcl.nm sbcl.mk
80 $(CC
) ${LINKFLAGS} -o
$@
$(USE_LIBSBCL
) $(LIBS
)
82 # ld -r -o sbcl.o works on Linux, but not on other platforms.
83 # On macOS, it fails to keep debug sections.
84 # On mingw64, it leads to an executable that cannot be executed.
86 $(LD
) $(__LDFLAGS__
) -r
-o
$@
$^
89 rm -f
$@
; ar rcs
$@
$^
91 libsbcl.so
: $(subst .o
,.pic.o
,$(filter-out ldso-stubs.o
,$(OBJS
)))
92 cc -shared
-o
$@
$^
-ldl
-lpthread
-lm
94 $(CC
) -DLISP_FEATURE_GCC_TLS
-fPIC
-c
$(CFLAGS
) $< -o
$@
95 %.pic.o
: %.S
# (-fPIC doesn't affect hand-written assembly source)
96 $(CC
) -DLISP_FEATURE_GCC_TLS
-DPOSITION_INDEPENDENT_ASM
-c
$(CFLAGS
) $< -o
$@
97 testmain
: testmain.c libsbcl.so
-ldl
100 ( echo
'CC=$(CC)' ; \
102 echo
'CFLAGS=$(CFLAGS)' ; \
103 echo
'ASFLAGS=$(ASFLAGS)' ; \
104 echo
'LINKFLAGS=$(LINKFLAGS)' ; \
105 echo
'LDFLAGS=$(LDFLAGS)' ; \
106 echo
'__LDFLAGS__=$(__LDFLAGS__)' ; \
107 echo
'LIBS=$(LIBS)' ; \
108 if
[ -n
'$(LISP_FEATURE_SB_LINKABLE_RUNTIME)' ] ; then \
109 echo
'LIBSBCL=$(LIBSBCL)' ; \
110 echo
'USE_LIBSBCL=$(USE_LIBSBCL)' ; \
115 $(NM
) $(TARGET
) |
$(GREP
) -v
" [FUw] " > ,$@
118 sbcl.h
: $(wildcard genesis
/*.h
)
119 echo
'#include "genesis/config.h"' >sbcl.h
120 echo
'#include "genesis/constants.h"' >>sbcl.h
122 # || true because we don't want the build to break if etags isn't there.
123 # ...but it's still nice to have it done by default.
124 HEADERS
=$(wildcard *.h genesis
/*.h
)
125 TAGS
tags: $(SRCS
) $(HEADERS
)
126 @etags
$(SRCS
) $(HEADERS
) || true
129 -rm -f
*.
[do
] $(TARGET
) sbcl.nm sbcl.h core
*.tmp
$(OS_CLEAN_FILES
)
132 @
$(CC
) $(DEPEND_FLAGS
) $(CPPFLAGS
) $< > $@.tmp
; \
133 sed
's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp
> $@
; \
137 @
$(CC
) $(DEPEND_FLAGS
) $(CPPFLAGS
) $< > $@.tmp
; \
138 sed
's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp
> $@
; \
141 # By including those files, we cause GNU make to automatically re-make
142 # all dependencies of the .c file if necessary.
143 ifneq ($(MAKECMDGOALS
),clean)
144 -include $(C_SRC
:.c
=.d
) $(ASSEM_SRC
:.S
=.d
)