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