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