Remove x86-64-win32-assem.S
[sbcl.git] / src / runtime / GNUmakefile
blobbf06fed7ead676ccd7784fe5677a598591e5d44a
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 -Wundef -Wsign-compare -Wpointer-arith -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 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)
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 libsbcl.so: $(subst .o,.pic.o,$(filter-out ldso-stubs.o,$(OBJS)))
92 cc -shared -o $@ $^ -ldl -lpthread -lm
93 %.pic.o: %.c
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
99 sbcl.mk:
100 ( echo 'CC=$(CC)' ; \
101 echo 'LD=$(LD)' ; \
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)' ; \
111 fi ; \
112 : ) > $@
114 sbcl.nm: $(TARGET)
115 $(NM) $(TARGET) | $(GREP) -v " [FUw] " > ,$@
116 mv -f ,$@ $@
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
128 clean:
129 -rm -f *.[do] $(TARGET) sbcl.nm sbcl.h core *.tmp $(OS_CLEAN_FILES)
131 %.d: %.c sbcl.h
132 @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
133 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
134 rm -f $@.tmp
136 %.d: %.S sbcl.h
137 @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
138 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
139 rm -f $@.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)
145 endif