-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
51 lines (38 loc) · 1.27 KB
/
makefile
File metadata and controls
51 lines (38 loc) · 1.27 KB
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
NAME := NodeModuleCleaner
SOURCE_DIR := src
BINARY_DIR := bin
OBJECT_DIR := obj
EXE := $(BINARY_DIR)/$(NAME)
CC := gcc
CFLAGS := -std=c89 # Conform to the ISO 1989 C standard
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g # Enable debugging
endif
ifeq ($(BUILD_MODE),RELEASE)
CFLAGS += -Wall # Enable most warning messages
CFLAGS += -Wextra # Print extra (possibly unwanted) warnings
CFLAGS += -pedantic # Evaluates more warnings
CFLAGS += -Werror # Everything is an error
endif
# Files
SOURCES := $(wildcard $(SOURCE_DIR)/*.c) $(wildcard $(SOURCE_DIR)/**/*.c)
HEADERS := $(wildcard $(SOURCE_DIR)/*.h) $(wildcard $(SOURCE_DIR)/**/*.h)
OBJECTS := $(addprefix $(OBJECT_DIR)/, $(subst $(SOURCE_DIR)/, , $(SOURCES:%.c=%.o)))
# Targets ---------------------------------------------------------------------
default: all
all: clean $(EXE)
build: $(EXE)
# Remove all of the build files
clean:
@ rm -rf $(BINARY_DIR)
@ rm -rf $(OBJECT_DIR)
# Link the interpreter.
$(EXE): $(OBJECTS)
@ echo "*" $(CC) -o $@ $(OBJECTS) $(CFLAGS)
@ mkdir -p "./$(BINARY_DIR)"
@ $(CC) -o $@ $(OBJECTS) $(CFLAGS)
# Compile object files.
$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.c $(HEADERS)
@ echo "*" $(CC) -c -o $@ $< $(CFLAGS)
@ mkdir -p $(addprefix ./, $(dir $(OBJECTS)))
@ $(CC) -c -o $@ $< $(CFLAGS)