-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (34 loc) · 1004 Bytes
/
Makefile
File metadata and controls
47 lines (34 loc) · 1004 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
CC=g++
CPPFLAGS=-g -O2 -Wall -Wextra -Isrc -rdynamic -Iinclude/ -fPIC
LDFLAGS=
SRC_DIR=src
RUN_DIR=run
LIBD_DIR=lib
RUND_DIR=bin
NAME=vm
VPATH=src
LIB_SOURCES=$(wildcard $(SRC_DIR)/**/*.cpp $(SRC_DIR)/*.cpp)
LIB_OBJECTS=$(patsubst %.cpp,%.o,$(LIB_SOURCES))
RUN_SOURCES=$(wildcard $(RUN_DIR)/**/*.cpp $(RUN_DIR)/*.cpp)
RUN_OBJECTS=$(patsubst %.cpp,%.o,$(RUN_SOURCES))
TARGET_EX=$(RUND_DIR)/$(NAME)
TARGET_A=$(LIBD_DIR)/lib$(NAME).a
TARGET_SO=$(LIBD_DIR)/lib$(NAME).so
all: exec lib
exec: $(TARGET_EX)
lib: $(TARGET_SO) $(TARGET_A)
main.o: main.cpp
$(TARGET_EX): $(LIB_OBJECTS) $(RUN_OBJECTS) run_dir
$(CC) -o $@ $(LDFLAGS) $(CPPFLAGS) $(LIB_OBJECTS) $(RUN_OBJECTS)
$(TARGET_A): $(LIB_OBJECTS) lib_dir
ar rcs $@ $(LIB_OBJECTS)
$(TARGET_SO): LDFLAGS += -shared
$(TARGET_SO): $(LIB_OBJECTS) lib_dir
$(CC) -o $@ $(LDFLAGS) $(CPPFLAGS) $(LIB_OBJECTS)
lib_dir:
@mkdir -p $(LIBD_DIR)
run_dir:
@mkdir -p $(RUND_DIR)
.PHONY:
clean:
@$(RM) -r $(LIBD_DIR) $(RUND_DIR) $(LIB_OBJECTS) $(RUN_OBJECTS)