summarylogtreecommitdiffstats
path: root/wsh-system-libs.patch
blob: 34fd9899d2bfd57da632900f93a78e32ffd84c84 (plain)
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
--- src/wsh/Makefile.orig	2025-06-22 21:35:34.000000000 +0300
+++ src/wsh/Makefile	2025-06-25 14:26:09.445625580 +0300
@@ -7,10 +7,12 @@
 # This file is licensed under MIT License.
 #
 
-OBJLIB := ./lua/src/liblua.a ./openlibm/libopenlibm.a ./librustdemangle/target/release/librust_demangle.a
+PKG_CFLAGS := $(shell pkg-config --cflags lua53)
+PKG_LIBS := $(shell pkg-config --libs lua53) -llinenoise
 
-CFLAGS := -rdynamic -W -Wall -Wextra -O0 -ggdb -g3 -Wno-unused-but-set-variable -Wno-unused-parameter -I./include -rdynamic -I../../include/ -I./luajit-2.0/src/ -Wl,-E -Wl,-z,now
-#OBJLIB := ./luajit-2.0/src/libluajit.a ./openlibm/libopenlibm.a 
+OBJLIB := $(PKG_LIBS) librustdemangle/target/release/librust_demangle.a
+
+#CFLAGS := -rdynamic -W -Wall -Wextra -O0 -ggdb -g3 -Wno-unused-but-set-variable -Wno-unused-parameter -I./include -rdynamic -I../../include/ -I./luajit-2.0/src/ -Wl,-E -Wl,-z,now
 
 unamem := $(shell uname -m)
 
@@ -24,20 +26,14 @@
 WLINK	=
 endif
 
+all: override CFLAGS += $(PKG_CFLAGS) -fpie -fPIC
 all::
 	cd librustdemangle && cargo build --release
-	cd openlibm && make CFLAGS="-fpie -fPIC"
-	cd lua && make linux CFLAGS="-fpie -fPIC"
-	$(CC) $(CFLAGS) wsh.c -o wsh.o -c -fpie -fPIC -ldl -lreadline
-	$(CC) $(CFLAGS) wshmain.c -o wshmain.o -c -fpie -fPIC -ldl -lreadline
-	$(CC) $(CFLAGS) helper.c -o helper.o -c -fpie -fPIC
-	$(CC) $(CFLAGS) linenoise/linenoise.c -o linenoise.o -c -fpie -fPIC
-	$(CC) $(CFLAGS) wsh.o helper.o linenoise.o -shared -fPIC -o libwitch.so
-	ar cr libwitch.a wsh.o helper.o linenoise.o
+	$(CC) $(CFLAGS) wsh.c -o wsh.o -c
+	$(CC) $(CFLAGS) wshmain.c -o wshmain.o -c
+	$(CC) $(CFLAGS) helper.c -o helper.o -c
 	$(CC) $(CFLAGS) elfloader64.c -o elfloader64.o -c
-	$(CC) $(CFLAGS) ../wld/wld.o elfloader64.o wsh.o helper.o linenoise.o wshmain.o -o wsh $(WLINK) -liberty $(OBJLIB) -ldl
-	$(CC) $(CFLAGS) ../wld/wld.o elfloader64.o wsh.o helper.o linenoise.o wshmain.o -o wsh-static-`uname -m` $(WLINK) -liberty $(OBJLIB) -static
-	$(CC) $(CFLAGS) ../wld/wld.o elfloader64.o wsh.o helper.o linenoise.o wshmain.o -o wsh-`uname -m` $(WLINK) -liberty $(OBJLIB) -ldl -Wl,-rpath=/tmp/wsh/`uname -m`/,-rpath=/tmp/wsh/,-rpath=.
+	$(CC) $(CFLAGS) ../wld/wld.o elfloader64.o wsh.o helper.o wshmain.o -o wsh $(WLINK) -liberty $(OBJLIB) -ldl
 	cp wsh libwsh.so
 	../wld/wld -l libwsh.so
 	cp wsh ../../bin/
@@ -60,7 +56,8 @@
 	mkdir -p $(DESTDIR)/usr/share/wcc/
 	cp -r ./scripts $(DESTDIR)/usr/share/wcc/
 	cp wsh $(DESTDIR)/usr/bin/wsh || :
-	cp libwsh.so $(DESTDIR)/lib/x86_64-linux-gnu/  || :
+	mkdir -p $(DESTDIR)/usr/lib/
+	cp libwsh.so $(DESTDIR)/usr/lib/  || :
 uninstall::
 	rm -rf $(DESTDIR)/usr/share/wcc/
 	rm -f $(DESTDIR)/usr/bin/wsh