0.9.3.63:
[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
13
14 all: sbcl sbcl.nm
15
16 # Defaults which might be overridden or modified by values in the
17 # Config file. Most of them are same on most systems right now.
18 # If you need to override one of these, do it in Config.
19 LD = ld
20 LINKFLAGS = -g
21 NM = nm -gp
22 DEPEND_FLAGS = -MM
23 GREP = grep
24
25 CFLAGS = -g -Wall -O3
26 ASFLAGS = $(CFLAGS)
27 CPPFLAGS = -I.
28
29 # The Config file is the preferred place for tweaking options which
30 # are appropriate for particular setups (OS, ARCH, whatever). Make a
31 # Config-foo file for setup foo, then arrange for Config to be a
32 # symlink to Config-foo.
33 # Commonly used variables in Config are: ARCH_SRC, ASSEM_SRC, GC_SRC,
34 # OS_SRC, OS_LIBS, OS_OBJS, OS_CLEAN_FILES
35 include Config
36
37
38 COMMON_SRC = alloc.c backtrace.c breakpoint.c coreparse.c \
39         dynbind.c gc-common.c globals.c interr.c interrupt.c \
40         monitor.c os-common.c parse.c print.c purify.c \
41         regnames.c run-program.c runtime.c save.c search.c \
42         thread.c time.c util.c validate.c vars.c wrap.c
43
44 C_SRC = $(COMMON_SRC) ${ARCH_SRC} ${OS_SRC} ${GC_SRC}
45
46 SRCS = $(C_SRC) ${ASSEM_SRC}
47
48 OBJS = $(C_SRC:.c=.o) $(ASSEM_SRC:.S=.o) ${OS_OBJS}
49
50 LIBS = ${OS_LIBS} -lm
51
52 sbcl: $(OBJS)
53         $(CC) ${LINKFLAGS} -o $@ $^ $(LIBS)
54
55 sbcl.nm: sbcl
56         $(NM) sbcl | $(GREP) -v " F \| U " > ,$@
57         mv -f ,$@ $@
58
59 sbcl.h: $(wildcard genesis/*.h)
60         echo '#include "genesis/config.h"' >sbcl.h
61         echo '#include "genesis/constants.h"' >>sbcl.h
62
63 TAGS tags: $(SRCS)
64         etags $(SRCS)
65
66 clean:
67         -rm -f *.[do] sbcl sbcl.nm sbcl.h core *.tmp $(OS_CLEAN_FILES)
68         # the depend file is obsolete
69         -rm -f depend
70
71 # depend target for backward compatibility
72 .PHONY: depend
73 depend:
74
75 %.d: %.c sbcl.h
76         @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
77         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
78         rm -f $@.tmp
79
80 %.d: %.S sbcl.h
81         @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
82         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
83         rm -f $@.tmp
84
85 # By including those files, we cause GNU make to automatically re-make
86 # all dependencies of the .c file if necessary.
87 ifneq ($(MAKECMDGOALS),clean)
88 -include $(C_SRC:.c=.d) $(ASSEM_SRC:.S=.d)
89 endif