-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (49 loc) · 1.12 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
54
55
56
57
58
59
60
61
62
ifeq ($(OS),Windows_NT)
_OS := windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
_OS := linux
endif
ifeq ($(UNAME_S),Darwin)
_OS := macos
endif
endif
CC := gcc
CFLAGS := -Wall -Wextra -g -O0
BIN := bin
SRC := src
INCLUDE := include/pcre2
LIB := lib/libpcre2/$(_OS)
LIBRARIES := -lpcre2-8
ifeq ($(_OS),windows)
EXECUTABLE := ino2cpp.exe
SOURCEDIRS := $(SRC)
INCLUDEDIRS := $(INCLUDE)
LIBDIRS := $(LIB)
else
EXECUTABLE := ino2cpp
SOURCEDIRS := $(shell find $(SRC) -type d)
INCLUDEDIRS := $(shell find $(INCLUDE) -type d)
LIBDIRS := $(shell find $(LIB) -type d)
endif
CINCLUDES := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%))
CLIBS := $(patsubst %,-L%, $(LIBDIRS:%/=%))
SOURCES := $(wildcard $(patsubst %,%/*.c, $(SOURCEDIRS)))
OBJECTS := $(SOURCES:.c=.o)
all: $(BIN)/$(EXECUTABLE)
test:
@echo $(OS)
@echo $(CINCLUDES)
@echo $(OBJECTS)
@echo $(SOURCES)
.PHONY: clean
clean:
-$(RM) $(BIN)/$(EXECUTABLE)
-$(RM) $(OBJECTS)
run: all
./$(BIN)/$(EXECUTABLE)
$(OBJECTS): $(SOURCES)
$(CC) -c $(CFLAGS) $(CINCLUDES) $^ -o $@
$(BIN)/$(EXECUTABLE): $(OBJECTS)
$(CC) $(CFLAGS) $(CLIBS) $^ -o $@ $(LIBRARIES)