forked from zziolko/c-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
31 lines (23 loc) · 643 Bytes
/
Makefile
File metadata and controls
31 lines (23 loc) · 643 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
SRC_DIR=.
INC_DIR=.
OBJ_DIR=obj
BIN_DIR=bin
CC=gcc
CFLAGS=-I . -I $(INC_DIR) -std=c99
LIBS=-lm
# find all source files:
SRC:=$(shell find * -maxdepth 0 -iname '*.c' )
# substitute .c with .o in source files:
_OBJ=$(patsubst %.c,%.o,$(SRC))
# substitute .o with $(OBJ_DIR)/.o in object files:
OBJ=$(patsubst %,$(OBJ_DIR)/%,$(_OBJ))
# for each $(OBJ_DIR)/xyz.o, get $(BIN_DIR)/xyz.run
BIN=$(patsubst $(OBJ_DIR)/%.o,$(BIN_DIR)/%.run,$(OBJ))
all: $(BIN)
$(BIN_DIR)/%.run: $(OBJ_DIR)/%.o
$(CC) $^ -o $@ $(LIBS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/*.h
$(CC) -c -o $@ $< $(CFLAGS)
clean:
rm -f $(BIN_DIR)/*.run
rm -f $(OBJ_DIR)/*.o