Commit Diff


commit - 44b5f33be4167e1a0e293c21158bbf235acb1a21
commit + 21b1dfdbf54e96ff9cb8cb9a05f38ac2d344dbaa
blob - e98573f497036f70b66151989ff74c9f39f17381
blob + 9b7a091b5a5df89cdc16fa38c586c0d2045e65db
--- Makefile
+++ Makefile
@@ -31,10 +31,27 @@ SRCS+=trunk.c who.c more.c stringlist.c utils.c sqlite
 SRCS+=nopt.c pflow.c wg.c nameserver.c ndp.c umb.c utf8.c cmdargs.c ctlargs.c
 SRCS+=helpcommands.c makeargv.c hashtable.c mantab.c
 CLEANFILES+=compile.c mantab.c
-LDADD=-lutil -ledit -ltermcap -lsqlite3 -L/usr/local/lib #-static
 
+LDADD=-lutil -ledit -ltermcap
+
+.if make(static)
+NSH_SQLITE_LIBS!=/usr/bin/pkg-config --libs --static sqlite3
+.else
+NSH_SQLITE_LIBS!=/usr/bin/pkg-config --libs sqlite3
+.endif
+LDADD+=${NSH_SQLITE_LIBS}
+
+.if make(static)
+LDADD+=-static
+.endif
+
 MAN=nsh.8
 
+# convenience target for producing statically linked binaries
+static: $(PROG)
+	${MAKE} -C ${.CURDIR}/bgpnsh static
+	${MAKE} -C ${.CURDIR}/nshdoas static
+
 compile.c: compile.sh *.c *.h
 	sh ${.CURDIR}/compile.sh
 
blob - 6e7273179f846fde7523da1e0fa009764616a0b2
blob + 662bc181d8fe6f8a77dee8fe73426c375af673f4
--- bgpnsh/Makefile
+++ bgpnsh/Makefile
@@ -24,6 +24,12 @@ SRCS=bgpnsh.c compile.c bgpcommands.c complete.c genge
 CLEANFILES+=compile.c
 LDADD=-lutil -ledit -ltermcap
 
+.if make(static)
+LDADD+=-static
+.endif
+
+static: all
+
 MAN=bgpnsh.8
 
 compile.c: compile.sh
blob - 7ec35dab7c90c3d22ee57353679b372615f987e8
blob + 7047d44af36c86e3b294d69be4b5516e0269c553
--- nshdoas/Makefile
+++ nshdoas/Makefile
@@ -22,6 +22,10 @@ CPPFLAGS+=-I${.CURDIR}/.. -I ${.CURDIR}
 SRCS=parse.y nshdoas.c env.c
 LDADD=-lutil
 
+.if make(static)
+LDADD+=-static
+.endif
+
 BINOWN= root
 BINMODE=4555
 
@@ -29,4 +33,6 @@ YFLAGS=
 
 NOMAN=yes
 
+static: all
+
 .include <bsd.prog.mk>