-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
54 lines (43 loc) · 1.87 KB
/
Makefile
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
CC=clang
CFLAGS=-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable -g
SRC_DIR=src
BUILD_DIR=build
SRC_FILES=$(wildcard $(SRC_DIR)/**/*.c $(SRC_DIR)/*.c)
OBJ_FILES=$(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC_FILES))
HDR_DIR=include
HDR_FILES=$(wildcard $(HDR_DIR)/**/*.h $(HDR_DIR)/*.h)
all: $(BUILD_DIR)/main
@echo "(DONE) $@"
@cp $(BUILD_DIR)/main coolc
$(BUILD_DIR)/main: $(OBJ_FILES) | $(BUILD_DIR)
@echo "(LINK) $@"
@$(CC) $(CFLAGS) -o $@ $^
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(HDR_FILES) | $(BUILD_DIR)
@echo "(COMP) $@"
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -I$(HDR_DIR) -c -o $@ $<
$(BUILD_DIR):
@echo "(INIT)"
@mkdir -p $@
clean:
@echo "(CLEAN)"
@rm -rf $(BUILD_DIR)
@rm -f coolc
examples: all
./coolc examples/hello.cl -o build/hello
./coolc examples/rule110.cl --module prelude --module data -o build/rule110
./coolc examples/gol.cl --module prelude -o build/gol
./coolc examples/raylib.cl --module raylib -o build/raylib
./coolc examples/movement.cl --module raylib -o build/movement
./coolc examples/snake.cl --module raylib --module random -o build/snake
./coolc examples/sockets.cl --module prelude -o build/sockets
./coolc examples/threading.cl --module threading -o build/threading
./coolc examples/coin/server.cl examples/coin/message.cl --module net --module threading --module data --module random -o build/coin-server
./coolc examples/coin/client.cl examples/coin/message.cl --module net --module threading --module raylib -o build/coin-client
compiler: all
./coolc examples/compiler/lexer.cl examples/compiler/compiler.cl --module mallocator --module prelude --module data -o build/cool-lexer
./coolc examples/compiler/parser.cl examples/compiler/compiler.cl --module mallocator --module prelude --module data -o build/cool-parser
dist: clean all
rm -rf coolc.tar.gz
tar -czf coolc.tar.gz coolc lib
.PHONY: all clean examples game dist