f89e16012ddf0071ebea0d9ee39ab6343a3ac272
[mes.git] / make / mescc-guile.make
1 ifneq ($(GUILE),)
2 CROSS:=guile-
3 C_FILES:=libc/libc-mes.c $(C_FILES)
4 #C_FILES:=libc/mini-libc-mes.c $(C_FILES)
5 O_FILES:=$(C_FILES:%.c=$(OUT)/%.$(CROSS)o)
6
7 ifneq ($(DEBUG),)
8 $(info TARGET=$(TARGET))
9 $(info C_FILES=$(C_FILES))
10 $(info O_FILES=$(O_FILES))
11 endif
12
13 CLEAN+=$(O_FILES) $(OUT)/$(TARGET)
14
15 CLEAN+=$(OUT)/$(TARGET)
16
17 INCLUDES+=libc/include libc $(OUT)/$(DIR)
18 MESCC.scm:=guile/mescc.scm
19 MESLD.scm:=guile/mescc.scm
20
21 $(OUT)/$(TARGET): ld:=MESLD.scm
22 $(OUT)/$(TARGET): LD:=$(MESLD.scm)
23 $(OUT)/$(TARGET): CC:=$(MESCC.scm)
24 $(OUT)/$(TARGET): CFLAGS:=
25 $(OUT)/$(TARGET): LDFLAGS:=
26 $(OUT)/$(TARGET): O_FILES:=$(O_FILES)
27 $(OUT)/$(TARGET): $(O_FILES)
28         @echo "  $(ld)  $(notdir $(O_FILES)) -> $(notdir $@)"
29         $(QUIET)$(LINK.c) $(O_FILES) $(LOADLIBES) $(LDLIBS) -o $@
30
31 define mescc.scm-c-compile
32 $(OUT)/$(1:.c=.$(CROSS)o): CROSS:=$(CROSS)
33 $(OUT)/$(1:.c=.$(CROSS)o): cc:=MESCC.scm
34 $(OUT)/$(1:.c=.$(CROSS)o): CC:=$(MESCC.scm)
35 $(OUT)/$(1:.c=.$(CROSS)o): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
36 $(OUT)/$(1:.c=.$(CROSS)o): COMPILE.c:=$(MESCC.scm) -c $(CPPFLAGS)
37 $(OUT)/$(1:.c=.$(CROSS)o): $(MAKEFILE_LIST)
38 $(OUT)/$(1:.c=.$(CROSS)o): $(INSTALL_GO_FILES)
39 $(OUT)/$(1:.c=.$(CROSS)o): $(1)
40         @echo "  $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
41         @mkdir -p $$(dir $$@)
42         $$(QUIET)$$(COMPILE.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
43 endef
44
45 define mescc.scm-c-preprocess
46 $(OUT)/$(1:.c=.$(CROSS)E): CROSS:=$(CROSS)
47 $(OUT)/$(1:.c=.$(CROSS)E): cc:=MESCC.scm
48 $(OUT)/$(1:.c=.$(CROSS)E): CC:=$(MESCC.scm)
49 $(OUT)/$(1:.c=.$(CROSS)E): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
50 $(OUT)/$(1:.c=.$(CROSS)E): PREPROCESS.c:=$(MESCC.scm) -E $(CPPFLAGS)
51 $(OUT)/$(1:.c=.$(CROSS)E): $(MAKEFILE_LIST)
52 $(OUT)/$(1:.c=.$(CROSS)E): $(INSTALL_GO_FILES)
53 $(OUT)/$(1:.c=.$(CROSS)E): $(1)
54         @echo "  $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
55         @mkdir -p $$(dir $$@)
56         $$(QUIET)$$(PREPROCESS.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
57 endef
58
59 define mescc.scm-c-compile-E
60 $(1:.$(CROSS)E=.$(CROSS)o): CROSS:=$(CROSS)
61 $(1:.$(CROSS)E=.$(CROSS)o): cc:=MESCC.scm
62 $(1:.$(CROSS)E=.$(CROSS)o): CC:=$(MESCC.scm)
63 $(1:.$(CROSS)E=.$(CROSS)o): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
64 $(1:.$(CROSS)E=.$(CROSS)o): COMPILE.c:=$(MESCC.scm) -c $(CPPFLAGS)
65 $(1:.$(CROSS)E=.$(CROSS)o): $(MAKEFILE_LIST)
66 $(1:.$(CROSS)E=.$(CROSS)o): $(INSTALL_GO_FILES)
67 $(1:.$(CROSS)E=.$(CROSS)o): $(1)
68         @echo "  $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
69         @mkdir -p $$(dir $$@)
70         $$(QUIET)$$(COMPILE.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
71 endef
72
73 ifeq ($(MLIBC.scm),)
74 MLIBC.scm:=DONE
75 else
76 C_FILES:=$(filter-out libc/libc-mes.c,$(C_FILES))
77 C_FILES:=$(filter-out libc/mini-libc-mes.c,$(C_FILES))
78 endif
79
80 ifneq ($(MESC_DIRECT),)
81 $(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-compile,$(c-file),$(DEFINES),$(INCLUDES))))
82 else
83 $(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-preprocess,$(c-file),$(DEFINES),$(INCLUDES))))
84 $(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-compile-E,$(c-file:%.c=$(OUT)/%.$(CROSS)E),$(DEFINES),$(INCLUDES))))
85 endif
86
87 endif
88 include make/reset.make