commit 1bd6d201020f67160872c28534edff532b5198b9
parent 0bd553a078cc8ec1d197fd7af96b07b1921049e2
Author: Quentin Rameau <quinq@fifth.space>
Date: Mon, 23 Nov 2015 22:12:00 +0100
ext: first commit for surf lib
Diffstat:
3 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/Makefile b/Makefile
@@ -6,30 +6,49 @@ include config.mk
SRC = surf.c
OBJ = $(SRC:.c=.o)
+LIBSRC = libsurf-webext.c
+LIBOBJ = $(LIBSRC:.c=.lo)
-all: options surf
+all: options libsurf-webext.la surf
options:
@echo surf build options:
- @echo "CFLAGS = $(SURF_CFLAGS)"
- @echo "LDFLAGS = $(SURF_LDFLAGS)"
- @echo "CC = $(CC)"
+ @echo "CFLAGS = $(SURFCFLAGS)"
+ @echo "LDFLAGS = $(SURFLDFLAGS)"
+ @echo "CC = $(CC)"
+ @echo "LIBCFLAGS = $(LIBCFLAGS)"
+ @echo "LIBLDFLAGS = $(LIBLDFLAGS)"
+ @echo "LIBTOOL = $(LIBTOOL)"
.c.o:
@echo CC -c $<
- @$(CC) $(SURF_CFLAGS) -c $<
+ @$(CC) $(SURFCFLAGS) -c $<
+
+.c.lo:
+ @echo libtool compile $<
+ @$(LIBTOOL) --mode compile --tag CC $(CC) $(LIBCFLAGS) -c $<
$(OBJ): config.h config.mk
+$(LIBOBJ): config.mk
config.h:
@echo creating $@ from config.def.h
@cp config.def.h $@
+libsurf-webext.la: $(LIBOBJ)
+ @echo libtool link $@
+ @$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \
+ $(LIBOBJ) -rpath $(DESTDIR)$(LIBPREFIX)
+
surf: $(OBJ)
@echo CC -o $@
- @$(CC) $(SURF_CFLAGS) -o $@ $(OBJ) $(SURF_LDFLAGS)
+ @$(CC) $(SURFCFLAGS) -o $@ $(OBJ) $(SURFLDFLAGS)
+
+clean-lib:
+ @echo cleaning library
+ @rm -rf libsurf-webext.la .libs $(LIBOBJ) $(LIBOBJ:.lo=.o)
-clean:
+clean: clean-lib
@echo cleaning
@rm -f surf $(OBJ)
@@ -42,12 +61,18 @@ dist: distclean
@mkdir -p surf-$(VERSION)
@cp -R LICENSE Makefile config.mk config.def.h README \
surf-open.sh arg.h TODO.md surf.png \
- surf.1 $(SRC) surf-$(VERSION)
+ surf.1 $(SRC) $(LIBSRC) surf-$(VERSION)
@tar -cf surf-$(VERSION).tar surf-$(VERSION)
@gzip surf-$(VERSION).tar
@rm -rf surf-$(VERSION)
-install: all
+install-lib: libsurf-webext.la
+ @echo installing library file to $(DESTDIR)$(LIBPREFIX)
+ @mkdir -p $(DESTDIR)$(LIBPREFIX)
+ @$(LIBTOOL) --mode install install -c libsurf-webext.la \
+ $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la
+
+install: all install-lib
@echo installing executable file to $(DESTDIR)$(PREFIX)/bin
@mkdir -p $(DESTDIR)$(PREFIX)/bin
@cp -f surf $(DESTDIR)$(PREFIX)/bin
@@ -57,10 +82,17 @@ install: all
@sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1
@chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1
-uninstall:
+uninstall-lib:
+ @echo removing library file from $(DESTDIR)$(LIBPREFIX)
+ @$(LIBTOOL) --mode uninstall rm -f \
+ $(DESTDIR)$(LIBPREFIX)/libsurf-webext.la
+ @- rm -df $(DESTDIR)$(LIBPREFIX)
+
+uninstall: uninstall-lib
@echo removing executable file from $(DESTDIR)$(PREFIX)/bin
@rm -f $(DESTDIR)$(PREFIX)/bin/surf
@echo removing manual page from $(DESTDIR)$(MANPREFIX)/man1
@rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1
-.PHONY: all options clean dist install uninstall
+.SUFFIXES: .la .lo .o .c
+.PHONY: all options clean-dist clean dist install-lib install uninstall-lib uninstall
diff --git a/config.mk b/config.mk
@@ -13,16 +13,21 @@ X11LIB = /usr/X11R6/lib
GTKINC = `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0`
GTKLIB = `pkg-config --libs gtk+-3.0 gcr-3 webkit2gtk-4.0`
+WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0`
+WEBEXTLIB = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0`
# includes and libs
INCS = -I$(X11INC) $(GTKINC)
LIBS = -L$(X11LIB) -lX11 $(GTKLIB) -lgthread-2.0
# flags
-CPPFLAGS = -DVERSION=\"${VERSION}\" -DWEBEXTDIR=\"${LIBPREFIX}\" \
+CPPFLAGS = -DVERSION=\"$(VERSION)\" -DWEBEXTDIR=\"$(LIBPREFIX)\" \
-D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE
-SURF_CFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
-SURF_LDFLAGS = $(LIBS) $(LDFLAGS)
+SURFCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
+SURFLDFLAGS = $(LIBS) $(LDFLAGS)
+LIBCPPFLAGS = -DWEBEXTDIR=\"$(LIBPREFIX)\"
+LIBCFLAGS = $(WEBEXTINC) $(LIBCPPFLAGS) $(CFLAGS)
+LIBLDFLAGS = $(WEBEXTLIB) $(LDFLAGS)
# Solaris
#CFLAGS = -fast $(INCS) -DVERSION=\"$(VERSION)\"
@@ -30,3 +35,4 @@ SURF_LDFLAGS = $(LIBS) $(LDFLAGS)
# compiler and linker
#CC = c99
+LIBTOOL = libtool --quiet
diff --git a/libsurf-webext.c b/libsurf-webext.c
@@ -0,0 +1,7 @@
+#include <webkit2/webkit-web-extension.h>
+
+G_MODULE_EXPORT void
+webkit_web_extension_initialize(WebKitWebExtension *e)
+{
+ return;
+}