Remove "-HEADER-" from SYMBOL and VALUE-CELL widetag names
[sbcl.git] / src / runtime / GNUmakefile
blob9ea571730dbf0d5a1f043b6ae6a246731bb00ae8
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
4 # more information.
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
14 all: targets tags
15 TARGET=sbcl
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.
20 LINKFLAGS = -g
21 NM = nm -gp
22 DEPEND_FLAGS = -MM
23 GREP = grep
24 LD = ld
26 # By default, don't make and use a library, just use the object files.
27 LIBSBCL = $(OBJS)
28 USE_LIBSBCL = $(OBJS)
29 __LDFLAGS__ =
31 include ../../output/prefix.def
33 CFLAGS = -g -Wall -Wsign-compare -O3
34 ASFLAGS = $(CFLAGS)
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
46 include Config
48 # Disable PIE when possible
49 ifneq ($(shell $(CC) -dumpspecs 2>/dev/null | grep -e '[^f]no-pie'),)
50 CFLAGS += -fno-pie
51 LINKFLAGS += -no-pie
52 LDFLAGS += -no-pie
53 __LDFLAGS__ += -no-pie
54 endif
55 ifneq ($(shell $(CC) -dumpspecs 2>/dev/null | grep -e '[^f]nopie'),)
56 CFLAGS += -fno-pie
57 LINKFLAGS += -nopie
58 LDFLAGS += -nopie
59 __LDFLAGS__ += -nopie
60 endif
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)
75 LIBS = ${OS_LIBS} -lm
77 targets: $(TARGET) $(OBJTARGET) sbcl.nm sbcl.mk
79 $(TARGET): $(LIBSBCL)
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.
85 sbcl.o: $(OBJS)
86 $(LD) $(__LDFLAGS__) -r -o $@ $^
88 libsbcl.a: $(OBJS)
89 rm -f $@ ; ar rcs $@ $^
91 sbcl.mk:
92 ( echo 'CC=$(CC)' ; \
93 echo 'LD=$(LD)' ; \
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)' ; \
103 fi ; \
104 : ) > $@
106 sbcl.nm: $(TARGET)
107 $(NM) $(TARGET) | $(GREP) -v " [FUw] " > ,$@
108 mv -f ,$@ $@
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.
116 TAGS tags: $(SRCS)
117 etags $(SRCS) || true
119 clean:
120 -rm -f *.[do] $(TARGET) sbcl.nm sbcl.h core *.tmp $(OS_CLEAN_FILES)
122 %.d: %.c sbcl.h
123 @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
124 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
125 rm -f $@.tmp
127 %.d: %.S sbcl.h
128 @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
129 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
130 rm -f $@.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)
136 endif