forked from PKD667/c-equal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
49 lines (34 loc) · 893 Bytes
/
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
#The target binary
BINARY = bin/cc
#The target library
LIB_DIR = lib
# The directories containing source files
SRC_DIR = src
# The directories containing headers files
INC_DIR = include
# The directory for object files
OBJ_DIR = obj
# The C compiler to use
CC = gcc
# The C flags to use
CFLAGS = -I$(INC_DIR)
LOCAL_LIBS = $(wildcard $(LIB_DIR)/*/*.a)
LIBS = $(LOCAL_LIBS)
# The source files
SOURCES = $(wildcard $(SRC_DIR)/*.c)
# The object files
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
# The default target
all: libs $(BINARY)
libs:
for i in $(LOCAL_LIBS); do make -C $$(dirname $$i) all; done
# Link the objects into the binary
$(BINARY): $(OBJECTS) $(LIBRARY)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(BINARY) $(OBJECTS) $(LIBS)
# Build the object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
# Clean up
clean:
rm -f $(OBJ_DIR)/*.o
rm -f $(BINARY)