blob: d7a1fdfd70e479dcb4d5c2dee5d9197c179d3e03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# A basic Makefile that KaRaMeL copies in the output directory; this is not
# guaranteed to work and will only work well for very simple projects. This
# Makefile uses:
# - the custom C files passed to your krml invocation
# - the custom C flags passed to your krml invocation
# - the -o option passed to your krml invocation
include Makefile.include
ifeq (,$(KRML_HOME))
$(error please define KRML_HOME to point to the root of your KaRaMeL git checkout)
endif
CFLAGS += -I. -I $(KRML_HOME)/include -I $(KRML_HOME)/krmllib/dist/minimal
CFLAGS += -Wall -Wextra -Werror -std=c11 -Wno-unused-variable \
-Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-unused-function \
-Wno-unused-parameter -Wno-infinite-recursion \
-g -fwrapv -D_BSD_SOURCE -D_DEFAULT_SOURCE
ifeq ($(OS),Windows_NT)
CFLAGS += -D__USE_MINGW_ANSI_STDIO
else
CFLAGS += -fPIC
endif
CFLAGS += $(USER_CFLAGS)
SOURCES += $(ALL_C_FILES) $(USER_C_FILES)
ifneq (,$(BLACKLIST))
SOURCES := $(filter-out $(BLACKLIST),$(SOURCES))
endif
OBJS += $(patsubst %.c,%.o,$(SOURCES))
all: $(USER_TARGET)
$(USER_TARGET): $(OBJS)
AR ?= ar
%.a:
$(AR) cr $@ $^
%.exe:
$(CC) $(CFLAGS) -o $@ $^ $(KRML_HOME)/krmllib/dist/generic/libkrmllib.a
%.so:
$(CC) $(CFLAGS) -shared -o $@ $^
%.d: %.c
@set -e; rm -f $@; \
$(CC) -MM -MG $(CFLAGS) $< > $@.$$$$; \
sed 's,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
include $(patsubst %.c,%.d,$(SOURCES))
clean:
rm -rf *.o *.d $(USER_TARGET)
|