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
-Wsign-compare
-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 interr.c interrupt.c \
64 largefile.c monitor.c os-common.c parse.c
print.c purify.c \
65 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
$@
$^
94 echo
'CFLAGS=$(CFLAGS)' ; \
95 echo
'ASFLAGS=$(ASFLAGS)' ; \
96 echo
'LINKFLAGS=$(LINKFLAGS)' ; \
97 echo
'LDFLAGS=$(LDFLAGS)' ; \
98 echo
'__LDFLAGS__=$(__LDFLAGS__)' ; \
99 echo
'LIBS=$(LIBS)' ; \
100 if
[ -n
'$(LISP_FEATURE_SB_LINKABLE_RUNTIME)' ] ; then \
101 echo
'LIBSBCL=$(LIBSBCL)' ; \
102 echo
'USE_LIBSBCL=$(USE_LIBSBCL)' ; \
107 $(NM
) $(TARGET
) |
$(GREP
) -v
" [FUw] " > ,$@
110 sbcl.h
: $(wildcard genesis
/*.h
)
111 echo
'#include "genesis/config.h"' >sbcl.h
112 echo
'#include "genesis/constants.h"' >>sbcl.h
114 # || true because we don't want the build to break if etags isn't there.
115 # ...but it's still nice to have it done by default.
117 etags
$(SRCS
) || true
120 -rm -f
*.
[do
] $(TARGET
) sbcl.nm sbcl.h core
*.tmp
$(OS_CLEAN_FILES
)
123 @
$(CC
) $(DEPEND_FLAGS
) $(CPPFLAGS
) $< > $@.tmp
; \
124 sed
's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp
> $@
; \
128 @
$(CC
) $(DEPEND_FLAGS
) $(CPPFLAGS
) $< > $@.tmp
; \
129 sed
's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp
> $@
; \
132 # By including those files, we cause GNU make to automatically re-make
133 # all dependencies of the .c file if necessary.
134 ifneq ($(MAKECMDGOALS
),clean)
135 -include $(C_SRC
:.c
=.d
) $(ASSEM_SRC
:.S
=.d
)