-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (27 loc) · 681 Bytes
/
Makefile
File metadata and controls
37 lines (27 loc) · 681 Bytes
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
CC ?= gcc
SRC := src
OUT ?= ./miniscript
BUILD := build
HFILES := $(wildcard $(SRC)/*.h)
CFILES := $(wildcard $(SRC)/*.c)
OBJECTS := $(addprefix $(BUILD)/, $(notdir $(CFILES:.c=.o)))
CFLAGS := -std=c99 -I$(SRC) -Wall -Wextra -pedantic
LDLIBS := -lm
debug-flags ?= MS_DEBUG
ifndef release
OBJECTS := $(OBJECTS:.o=.debug.o)
CFLAGS += -g $(addprefix -D, $(debug-flags))
OUT := $(OUT)-debug
endif
.PHONY: clean all
all: $(BUILD) $(OUT)
$(BUILD):
mkdir -p $(BUILD)
$(OUT): $(HFILES) $(OBJECTS)
$(CC) -o $@ $(OBJECTS) $(LDLIBS)
$(BUILD)/%.o: $(SRC)/%.c
$(CC) -c $(CFLAGS) -o $@ $<
$(BUILD)/%.debug.o: $(SRC)/%.c
$(CC) -c $(CFLAGS) -o $@ $<
clean:
rm $(OUT) $(BUILD) -r