ccb3bb4e65f4f358d217d7a6cd17893034dbec7c
[sbcl.git] / src / runtime / GNUmakefile
1 # -*- makefile -*- for the C-level run-time support for SBCL
2
3 # This software is part of the SBCL system. See the README file for
4 # more information.
5 #
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.
11
12 .PHONY: all clean TAGS tags targets
13
14 all: targets tags
15 TARGET=sbcl
16
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 LD = ld
21 LINKFLAGS = -g
22 NM = nm -gp
23 DEPEND_FLAGS = -MM
24 GREP = grep
25
26 include ../../output/prefix.def
27
28 CFLAGS = -g -Wall -Wsign-compare -O3
29 ASFLAGS = $(CFLAGS)
30 CPPFLAGS = -I. -DSBCL_PREFIX=\"$(SBCL_PREFIX)\"
31
32 # Give make access to the target Lisp features.
33 include genesis/Makefile.features
34
35 # The Config file is the preferred place for tweaking options which
36 # are appropriate for particular setups (OS, ARCH, whatever). Make a
37 # Config-foo file for setup foo, then arrange for Config to be a
38 # symlink to Config-foo.
39 # Commonly used variables in Config are: ARCH_SRC, ASSEM_SRC, GC_SRC,
40 # OS_SRC, OS_LIBS, OS_OBJS, OS_CLEAN_FILES
41 include Config
42
43 COMMON_SRC = alloc.c backtrace.c breakpoint.c coreparse.c \
44         dynbind.c funcall.c gc-common.c globals.c interr.c interrupt.c \
45         largefile.c monitor.c os-common.c parse.c print.c purify.c \
46         pthread-futex.c \
47         regnames.c run-program.c runtime.c save.c search.c \
48         thread.c time.c util.c validate.c vars.c wrap.c 
49
50 C_SRC = $(COMMON_SRC) ${ARCH_SRC} ${OS_SRC} ${GC_SRC}
51
52 SRCS = $(C_SRC) ${ASSEM_SRC}
53
54 OBJS = $(C_SRC:.c=.o) $(ASSEM_SRC:.S=.o) ${OS_OBJS}
55
56 LIBS = ${OS_LIBS} -lm
57
58 targets: $(TARGET) sbcl.nm
59
60 $(TARGET): $(OBJS)
61         $(CC) ${LINKFLAGS} -o $@ $^ $(LIBS)
62
63 sbcl.nm: $(TARGET)
64         $(NM) $(TARGET) | $(GREP) -v " [FUw] " > ,$@
65         mv -f ,$@ $@
66
67 sbcl.h: $(wildcard genesis/*.h)
68         echo '#include "genesis/config.h"' >sbcl.h
69         echo '#include "genesis/constants.h"' >>sbcl.h
70
71 # || true because we don't want the build to break if etags isn't there.
72 # ...but it's still nice to have it done by default.
73 TAGS tags: $(SRCS)
74         etags $(SRCS) || true
75
76 clean:
77         -rm -f *.[do] $(TARGET) sbcl.nm sbcl.h core *.tmp $(OS_CLEAN_FILES)
78
79 %.d: %.c sbcl.h
80         @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
81         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
82         rm -f $@.tmp
83
84 %.d: %.S sbcl.h
85         @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
86         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
87         rm -f $@.tmp
88
89 # By including those files, we cause GNU make to automatically re-make
90 # all dependencies of the .c file if necessary.
91 ifneq ($(MAKECMDGOALS),clean)
92 -include $(C_SRC:.c=.d) $(ASSEM_SRC:.S=.d)
93 endif