-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (107 loc) · 2.79 KB
/
Makefile
File metadata and controls
127 lines (107 loc) · 2.79 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
CC = cc
CFLAGS = -I./src/quickjs -Wall -O2 -DCONFIG_VERSION=\"2020-11-08\" -D_GNU_SOURCE -DJSSH_VERSION=\"0.6.1\" -DJSVIM_VERSION=\"0.3.0\"
LDFLAGS = -lm -ldl -lreadline -lncurses -lssh -lgit2
# core sources
SRC = src/main.c \
src/utils.c \
src/func.c \
src/sys.c \
src/env.c \
src/quickjs/quickjs.c \
src/quickjs/quickjs-libc.c \
src/quickjs/cutils.c \
src/quickjs/libregexp.c \
src/quickjs/libunicode.c \
src/quickjs/dtoa.c
# optional modules
MODULES ?=
NEED_SETCAP =
# network module
ifneq ($(findstring network,$(MODULES)),)
SRC += lib/network/module.c \
lib/network/net_utils.c
CFLAGS += -DENABLE_NETWORK
NEED_SETCAP = yes
endif
# compiler module
ifneq ($(findstring compiler,$(MODULES)),)
SRC += lib/compiler/module.c \
lib/compiler/cmp_utils.c
CFLAGS += -DENABLE_COMPILER
endif
# fs module
ifneq ($(findstring fs,$(MODULES)),)
SRC += lib/fs/module.c \
lib/fs/fs_utils.c
CFLAGS += -DENABLE_FS
endif
# git module
ifneq ($(findstring git,$(MODULES)),)
SRC += lib/git/module.c \
lib/git/git_utils.c
CFLAGS += -DENABLE_GIT
endif
# apps module (jsvim)
ifneq ($(findstring apps,$(MODULES)),)
SRC += lib/apps/module.c \
lib/apps/app_utils.c
APPS_ENABLED = yes
CFLAGS += -DENABLE_APPS
endif
# enable all modules
ifeq ($(MODULES),all)
SRC += lib/network/module.c \
lib/network/net_utils.c \
lib/compiler/module.c \
lib/compiler/cmp_utils.c \
lib/fs/module.c \
lib/fs/fs_utils.c \
lib/git/module.c \
lib/git/git_utils.c \
lib/apps/module.c \
lib/apps/app_utils.c
CFLAGS += -DENABLE_NETWORK -DENABLE_COMPILER -DENABLE_FS -DENABLE_GIT -DENABLE_APPS
APPS_ENABLED = yes
NEED_SETCAP = yes
endif
OBJ = $(SRC:.c=.o)
# Default build target
ifeq ($(APPS_ENABLED),yes)
all: bin/jssh bin/jsvim
else
all: bin/jssh
endif
# Build main jssh executable
bin/jssh: $(OBJ)
@mkdir -p bin
$(CC) -o $@ $(OBJ) $(LDFLAGS)
ifeq ($(NEED_SETCAP),yes)
@echo "Setting cap_net_raw on $@"
@sudo setcap cap_net_raw=ep $@
endif
# Build standalone jsvim only when apps module is enabled
JSVIM_SRC = lib/apps/JSVIM/main.c \
lib/apps/JSVIM/editor.c \
lib/apps/JSVIM/buffer.c \
lib/apps/JSVIM/render.c \
lib/apps/JSVIM/highlight.c \
lib/apps/JSVIM/lsp.c \
lib/apps/JSVIM/language.c \
lib/apps/JSVIM/util.c \
lib/apps/JSVIM/semantic.c \
lib/apps/JSVIM/cJSON.c
ifeq ($(APPS_ENABLED),yes)
bin/jsvim: $(JSVIM_SRC)
@mkdir -p bin
$(CC) $(CFLAGS) -I./lib/apps/JSVIM $(JSVIM_SRC) -lncursesw -o bin/jsvim
endif
# Installation
ifeq ($(APPS_ENABLED),yes)
install: bin/jsvim
sudo install -m 755 bin/jsvim /usr/local/bin/jsvim
else
install:
@echo "No apps enabled. Nothing to install."
endif
clean:
rm -f $(OBJ)