-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile
53 lines (39 loc) · 1.32 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
.PHONY: all clean re
NAME=razermacos
LIB_TARGET_NAME=lib$(NAME).so
SRC=src
LIB=lib
OBJ=obj
INCLUDE=include
LIB_SOURCES=$(wildcard $(SRC)/$(LIB)/*.c)
LIB_OBJECTS=$(patsubst $(SRC)/$(LIB)/%.c, $(OBJ)/%.o, $(LIB_SOURCES))
CLI_SOURCES=$(wildcard $(SRC)/*.c)
CLI_OBJECTS=$(patsubst $(SRC)//%.c, $(OBJ)/%.o, $(CLI_SOURCES))
GREEN=\033[0;32m
BLUE=\033[0;34m
RED=\033[0;31m
CC=gcc
# Flags and Header
ARCHFLAGS=-arch arm64 -arch x86_64
OSFLAGS=-mmacosx-version-min=10.5
CFLAGS=-Wall -Wextra -framework CoreFoundation -framework IOKit
all: sample_cli
clean:
@rm -f $(LIB_OBJECTS) $(LIB_TARGET_NAME)
@printf "$(BLUE) ✗ Deletion of object files\n";
@printf "$(RED) ✗ Deletion of $(LIB_TARGET_NAME)\n";
@printf "$(RED) ✗ Deletion of sample_cli\n";
# Remake
re: clean all
sample_cli: $(LIB_TARGET_NAME) $(CLI_OBJECTS)
@$(CC) $(ARCHFLAGS) $(OSFLAGS) $(CFLAGS) -L. -I$(SRC)/$(INCLUDE) -o sample_cli $(SRC)/sample_cli.c -l$(NAME)
@printf "$(GREEN) ✓ Building sample_cli\n"
$(LIB_TARGET_NAME): $(LIB_OBJECTS)
@$(CC) $(ARCHFLAGS) $(OSFLAGS) $(CFLAGS) -fPIC -o $@ $^ -shared
@printf "$(GREEN) ✓ Building $(LIB_TARGET_NAME)\n"
$(OBJ)/%.o: $(SRC)/$(LIB)/%.c | $(OBJ)
@$(CC) $(ARCHFLAGS) $(OSFLAGS) -I$(SRC)/$(INCLUDE) -c $< -o $@
@printf "$(GREEN) ✓ Building $@\n"
$(OBJ):
@mkdir -p $@
@printf "$(GREEN) ✓ Creating $(OBJ) dir\n"