-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (49 loc) · 1.26 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
55
56
57
58
59
60
61
62
63
64
CC := gcc
CFLAGS := -std=c11 -Wall -Wextra -pedantic
LIBS :=
TARGET := ./ifj22
BUILD_DIR := ./
RUN_FLAGS :=
RUN_FILE_PATH := test-scripts/test.php
ARCHIVE_NAME := xhucov00.tgz
# Adds optimizations or debug info
ifeq ($(release),1)
CFLAGS += -o3
else
CFLAGS += -g3
endif
# Makes the compilation crash on warnings
ifeq ($(strict),1)
CFLAGS += -Werror
endif
# Generating a list of object files that will need to be complied
OBJ = $(patsubst %.c,$(BUILD_DIR)%.o,$(wildcard *.c))
.PHONY: clean run all int intv pack
# Pople like the "all"
all: $(TARGET)
# Linking
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) && echo "OK" >/dev/stderr
# Building all the object files
$(BUILD_DIR)%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
# Build and run
run: $(TARGET)
cat $(RUN_FILE_PATH) | ./$< $(RUN_FLAGS)
# Run and interpret
int: $(TARGET)
cat $(RUN_FILE_PATH) | ./$< $(RUN_FLAGS) > prog.ifj && \
./ic22int prog.ifj
# Run and interpret in debug mode
intv: $(TARGET)
cat $(RUN_FILE_PATH) | ./$< $(RUN_FLAGS) > prog.ifj && \
./ic22int -v prog.ifj
# As good as new
clean:
rm -f $(BUILD_DIR)/*.o
rm $(TARGET) || true
rm $(ARCHIVE_NAME) || true
$(ARCHIVE_NAME): Makefile *.c *.h dokumentace.pdf rozdeleni rozsireni
tar --gzip -cf $@ $^
# Alias for making archives
pack: $(ARCHIVE_NAME)