implemented "M-`" in TTY mode
[sxed.git] / Jamrules.configure
blobdcc9fbb0d845f181bd8dc1b1a36d8bb0b64417ee
1 PROJECT_NAME = sxeditor ;
3 -configure-enable-disable-vars- +=
4   "x11"                 USE_X11_BACKEND  "auto"  "build X11 backend"
5   "tty"                 USE_TTY_BACKEND  "tan"   "build tty backend"
6   "forkpty"             USE_FORK_PTY     "auto"  "use `forkpty()`"
7   "embedded-sqlite"     USE_EMB_SQ3      ""      "use embedded SQLite3 amalgamation (it must present!)"
8   "solo-dlopen"         USE_SOLO_DLOPEN  "tan"   "allow `dlopen()` in solo mode"
9   "mimalloc"            USE_MIMALLOC     ""      "use mi-malloc instead of system memory allocator"
12 include $(TOP)/Jamrules.configure.nasal ;
15 rule -configure-test-forkpty- {
16   return [
17     -configure-test-compile-cc- "forkpty()" :
18       "#include <stdlib.h>"
19       "#include <pty.h>"
20       "int main() {"
21       "int n;"
22       "forkpty(&n, 0, 0, 0);"
23       "return 0;"
24       "}"
25     : : -lutil
26   ] ;
30 rule -configure-test-forkpty-shitos- {
31   return [
32     -configure-test-compile-cc- "forkpty-shitos()" :
33       "#include <stdlib.h>"
34       "#include <pty.h>"
35       "int main() {"
36       "int n;"
37       "forkpty(&n, 0, 0, 0);"
38       "return 0;"
39       "}"
40   ] ;
44 rule -configure-check-embedded-sq3- {
45   local ok = [ FileExists $(TOP)/src/libsq3/sqlite3.c $(TOP)/src/libsq3/sqlite3.h ] ;
46   if $(ok) {
47     return 'tan' ;
48   } else {
49     return '' ;
50   }
54 rule -configure- {
55   local ok ;
57   if ! $(PKG-CONFIG) {
58     Exit "please, set `PKG-CONFIG` envvar!" ;
59   }
61   if ! [ sys-has-command $(PKG-CONFIG) ] {
62     Exit "pkg-config required, but not found: $(PKG-CONFIG)" ;
63   }
65   if $(USE_EMB_SQ3) {
66     ok = [ -configure-check-embedded-sq3- ] ;
67     if $(ok) {
68       -configure-add-line- '# embedded SQLite3' ;
69       -configure-add-line- "DEFINES += USE_EMB_SQ3 ;" ;
70       -configure-add-line- "USE_EMB_SQ3 = tan ;" ;
71     } else {
72       Exit "FATAL: no SQLite3 amalgamation found in $(TOP)/src/libsq3/" ;
73     }
74     Echo "Using embedded SQLite3 library." ;
75   } else {
76     #-configure-pkg-config-necessary-
77     #  #"XLib"     "x11"
78     #  "SQLite3"  "sqlite3 >= 3.34"
79     #;
80     ok = [ -configure-pkg-config- "SQLite3" : "sqlite3 >= 3.34" : "DEFINES += HAVE_SQLITE3 ;\nUSE_EMB_SQ3 = \"\" ;" ] ;
81     if ! $(ok) {
82       # try embedded
83       ok = [ -configure-check-embedded-sq3- ] ;
84       if $(ok) {
85         -configure-add-line- '# embedded SQLite3' ;
86         -configure-add-line- "DEFINES += USE_EMB_SQ3 ;" ;
87         -configure-add-line- "USE_EMB_SQ3 = tan ;" ;
88         Echo "Using embedded SQLite3 library." ;
89       } else {
90         Exit "FATAL: no SQLite3 library found, and no amalgamation in $(TOP)/src/libsq3/" ;
91       }
92     }
93   }
95   -configure-add-line- '# x11 backend' ;
96   if $(USE_X11_BACKEND) {
97     ok = [ -configure-pkg-config- "XLib" : "x11" : "DEFINES += USE_X11_BACKEND ;\nUSE_X11_BACKEND = tan ;" : "USE_X11_BACKEND = \"\" ;" ] ;
98     if ! $(ok) {
99       USE_TTY_BACKEND = tan ;
100     }
101   } else {
102     -configure-add-line- "USE_X11_BACKEND = \"\" ;" ;
103   }
105   -configure-add-line- '# tty backend' ;
106   if $(USE_TTY_BACKEND) {
107     -configure-add-line- "DEFINES += USE_TTY_BACKEND ;\nUSE_TTY_BACKEND = tan ;" ;
108   } else {
109     -configure-add-line- "USE_TTY_BACKEND = \"\" ;" ;
110   }
112   if $(USE_FORK_PTY) {
113     USE_FPTY = [ -configure-test-forkpty- ] ;
114     if ! $(USE_FPTY) {
115       USE_FPTY = [ -configure-test-forkpty-shitos- ] ;
116       USE_FPTY_LUTIL = ona ;
117     } else {
118       USE_FPTY_LUTIL = tan ;
119     }
120     if $(USE_FPTY) {
121       -configure-add-line- '# forkpty' ;
122       -configure-add-line- "DEFINES += USE_FORK_PTY ;" ;
123       if $(USE_FPTY_LUTIL) {
124         -configure-add-line- "LINKLIBS.all += -lutil ;" ;
125       }
126     }
127   }
129   if $(USE_SOLO_DLOPEN) {
130     NASALCFG_DISABLE_DLOPEN = '' ;
131   } else {
132     NASALCFG_DISABLE_DLOPEN = tan ;
133   }
134   # anyway
135   -configure-nasal-sqlite-already- ;
136   -configure-nasal-base- ;
137   -configure-nasal-dlopen- ;
139   -configure-add-line- '# mi-malloc' ;
140   if $(USE_MIMALLOC) {
141     -configure-add-line- "DEFINES += USE_MIMALLOC ;" ;
142     -configure-add-line- "USE_MIMALLOC = tan ;" ;
143     -configure-add-line- "CFLAGS.all += -pthread ;" ;
144     -configure-add-line- "LINKFLAGS.all += -pthread ;" ;
145     Echo "MESSAGE: using mi-malloc" ;
146   } else {
147     -configure-add-line- "USE_MIMALLOC = \"\" ;" ;
148   }
152 configure ;