changeset 76:9643962908ab

make: switch to GNU make
author David Demelier <markand@malikania.fr>
date Thu, 16 Mar 2023 13:35:17 +0100
parents b12491ceabfd
children fe78b16c694d
files GNUmakefile Makefile pasterd-themes.5
diffstat 3 files changed, 148 insertions(+), 403 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GNUmakefile	Thu Mar 16 13:35:17 2023 +0100
@@ -0,0 +1,148 @@
+#
+# Makefile -- basic makefile for paster
+#
+# Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+-include config.mk
+
+# User options.
+CC ?=           cc
+CFLAGS ?=       -DNDEBUG -O3
+
+# Installation paths.
+PREFIX ?=       /usr/local
+BINDIR ?=       $(PREFIX)/bin
+SHAREDIR ?=     $(PREFIX)/share
+MANDIR ?=       $(PREFIX)/share/man
+VARDIR ?=       $(PREFIX)/var
+
+# External libraries
+KCGI_INCS :=    $(shell pkg-config --cflags kcgi)
+KCGI_LIBS :=    $(shell pkg-config --libs kcgi)
+
+JANSSON_INCS := $(shell pkg-config --cflags jansson)
+JANSSON_LIBS := $(shell pkg-config --libs jansson)
+
+# No user options below this line.
+
+VERSION :=              0.3.0
+
+LIBPASTER_SRCS :=       extern/libmustach/mustach-jansson.c
+LIBPASTER_SRCS +=       extern/libmustach/mustach-wrap.c
+LIBPASTER_SRCS +=       extern/libmustach/mustach.c
+LIBPASTER_SRCS +=       extern/libmustach/mustach.c
+LIBPASTER_SRCS +=       extern/libsqlite/sqlite3.c
+LIBPASTER_SRCS +=       config.c
+LIBPASTER_SRCS +=       database.c
+LIBPASTER_SRCS +=       http.c
+LIBPASTER_SRCS +=       log.c
+LIBPASTER_SRCS +=       page-download.c
+LIBPASTER_SRCS +=       page-fork.c
+LIBPASTER_SRCS +=       page-index.c
+LIBPASTER_SRCS +=       page-new.c
+LIBPASTER_SRCS +=       page-paste.c
+LIBPASTER_SRCS +=       page-search.c
+LIBPASTER_SRCS +=       page-static.c
+LIBPASTER_SRCS +=       page.c
+LIBPASTER_SRCS +=       paste.c
+LIBPASTER_SRCS +=       util.c
+LIBPASTER_OBJS :=       $(LIBPASTER_SRCS:.c=.o)
+LIBPASTER_DEPS :=       $(LIBPASTER_SRCS:.c=.d)
+LIBPASTER :=            libpaster.a
+
+LIBPASTER_HTML_SRCS :=  html/footer.html
+LIBPASTER_HTML_SRCS +=  html/header.html
+LIBPASTER_HTML_SRCS +=  html/index.html
+LIBPASTER_HTML_SRCS +=  html/new.html
+LIBPASTER_HTML_SRCS +=  html/paste.html
+LIBPASTER_HTML_SRCS +=  html/search.html
+LIBPASTER_HTML_SRCS +=  html/status.html
+LIBPASTER_HTML_OBJS :=  $(LIBPASTER_HTML_SRCS:.html=.h)
+
+TESTS_SRCS :=           tests/test-database.c
+TESTS_OBJS :=           $(TESTS_SRCS:.c=.o)
+TESTS :=                $(TESTS_SRCS:.c=)
+
+override CFLAGS +=      -DSQLITE_DEFAULT_FOREIGN_KEYS=1
+override CFLAGS +=      -DSQLITE_OMIT_DEPRECATED
+override CFLAGS +=      -DSQLITE_OMIT_LOAD_EXTENSION
+override CFLAGS +=      -DSQLITE_THREADSAFE=0
+override CFLAGS +=      -DSHAREDIR=\"$(SHAREDIR)\"
+override CFLAGS +=      -DVARDIR=\"$(VARDIR)\"
+override CFLAGS +=      -I.
+override CFLAGS +=      -Iextern
+override CFLAGS +=      -Iextern/libmustach
+override CFLAGS +=      -Iextern/libsqlite
+override CFLAGS +=      $(KCGI_INCS)
+override CFLAGS +=      $(JANSSON_INCS)
+
+override CPPFLAGS :=    -MMD
+
+SED :=                  sed -e "s|@SHAREDIR@|$(SHAREDIR)|" \
+                            -e "s|@VARDIR@|$(VARDIR)|"
+BCC :=                  extern/bcc/bcc
+
+all: pasterd paster
+
+-include $(LIBPASTER_DEPS)
+
+%.h: %.html
+	$(BCC) -cs0 $< html_${<F} > $@
+
+%: %.sh
+	$(SED) < $< > $@
+
+%.a:
+	$(AR) -rc $@ $^
+
+$(LIBPASTER_HTML_OBJS): extern/bcc/bcc
+$(LIBPASTER_SRCS): $(LIBPASTER_HTML_OBJS)
+$(LIBPASTER): $(LIBPASTER_OBJS)
+
+pasterd: private LDLIBS += $(KCGI_LIBS) $(JANSSON_LIBS)
+pasterd: $(LIBPASTER)
+
+clean:
+	rm -f extern/bcc/bcc
+	rm -f $(LIBPASTER) $(LIBPASTER_OBJS) $(LIBPASTER_DEPS) $(LIBPASTER_HTML_OBJS)
+	rm -f paster pasterd
+	rm -f test.db $(TESTS_OBJS)
+
+install-paster:
+	mkdir -p $(DESTDIR)$(BINDIR)
+	mkdir -p $(DESTDIR)$(MANDIR)/man1
+	cp paster $(DESTDIR)$(BINDIR)
+	chmod 755 $(DESTDIR)$(BINDIR)/paster
+	$(SED) < paster.1 > $(DESTDIR)$(MANDIR)/man1/paster.1
+
+install-pasterd:
+	mkdir -p $(DESTDIR)$(BINDIR)
+	mkdir -p $(DESTDIR)$(MANDIR)/man5
+	mkdir -p $(DESTDIR)$(MANDIR)/man8
+	cp pasterd $(DESTDIR)$(BINDIR)
+	mkdir -p $(DESTDIR)$(SHAREDIR)/paster
+	cp -R themes $(DESTDIR)$(SHAREDIR)/paster
+	$(SED) < pasterd.8 > $(DESTDIR)$(MANDIR)/man8/pasterd.8
+	$(SED) < pasterd-themes.5 > $(DESTDIR)$(MANDIR)/man5/pasterd-themes.5
+
+install: install-pasterd install-paster
+
+$(TESTS_OBJS): $(CORE_LIB)
+
+tests: $(TESTS)
+	for t in $(TESTS); do $$t; done
+
+.PHONY: all clean tests
--- a/Makefile	Wed Mar 15 20:15:00 2023 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-#
-# Makefile -- basic makefile for paster
-#
-# Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-
-.POSIX:
-
-# User options.
-CC=             cc
-CFLAGS=         -DNDEBUG -O3
-
-# Installation paths.
-PREFIX=         /usr/local
-BINDIR=         $(PREFIX)/bin
-SHAREDIR=       $(PREFIX)/share
-MANDIR=         $(PREFIX)/share/man
-VARDIR=         $(PREFIX)/var
-
--include config.mk
-
-VERSION=        0.3.0
-
-CORE_SRCS=      extern/libmustach/mustach-jansson.c     \
-                extern/libmustach/mustach-wrap.c        \
-                extern/libmustach/mustach.c             \
-                extern/libmustach/mustach.c             \
-                extern/libsqlite/sqlite3.c              \
-                config.c                                \
-                database.c                              \
-                http.c                                  \
-                log.c                                   \
-                page-download.c                         \
-                page-fork.c                             \
-                page-index.c                            \
-                page-new.c                              \
-                page-paste.c                            \
-                page-search.c                           \
-                page-static.c                           \
-                page.c                                  \
-                paste.c                                 \
-                util.c
-CORE_OBJS=      $(CORE_SRCS:.c=.o)
-CORE_DEPS=      $(CORE_SRCS:.c=.d)
-CORE_LIB=       libpaster.a
-
-HTML_SRCS=      html/footer.html                \
-                html/header.html                \
-                html/index.html                 \
-                html/new.html                   \
-                html/paste.html                 \
-                html/search.html                \
-                html/status.html
-HTML_OBJS=      $(HTML_SRCS:.html=.h)
-
-TESTS_SRCS=     tests/test-database.c
-TESTS_OBJS=     $(TESTS_SRCS:.c=.o)
-TESTS=          $(TESTS_SRCS:.c=)
-
-KCGI_INCS=      `pkg-config --cflags kcgi`
-KCGI_LIBS=      `pkg-config --libs kcgi`
-
-JANSSON_INCS=   `pkg-config --cflags jansson`
-JANSSON_LIBS=   `pkg-config --libs jansson`
-
-DEFS=           -DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
-                -DSQLITE_OMIT_DEPRECATED \
-                -DSQLITE_OMIT_LOAD_EXTENSION \
-                -DSQLITE_THREADSAFE=0 \
-                -DSHAREDIR=\"$(SHAREDIR)\" \
-                -DVARDIR=\"$(VARDIR)\"
-INCS=           -I. \
-                -Iextern \
-                -Iextern/libmustach \
-                -Iextern/libsqlite \
-                $(KCGI_INCS) \
-                $(JANSSON_INCS)
-LIBS=           $(KCGI_LIBS) \
-                $(JANSSON_LIBS)
-
-SED=            sed -e "s|@SHAREDIR@|$(SHAREDIR)|" \
-                    -e "s|@VARDIR@|$(VARDIR)|"
-BCC=            extern/bcc/bcc
-
-.SUFFIXES:
-.SUFFIXES: .c .o .h .sh .html
-
-all: pasterd paster
-
--include $(CORE_DEPS)
-
-.c.o:
-	$(CC) $(INCS) $(DEFS) $(CFLAGS) -MMD -c $< -o $@
-
-.c:
-	$(CC) $(INCS) $(DEFS) $(CFLAGS) $< -o $@ $(CORE_LIB) $(SQLITE_LIB) $(LIBS) $(LDFLAGS)
-
-.html.h:
-	$(BCC) -cs0 $< html_${<F} > $@
-
-.sh:
-	$(SED) < $< > $@
-
-$(HTML_OBJS): $(BCC)
-
-$(CORE_SRCS): $(HTML_OBJS)
-
-$(CORE_LIB): $(CORE_OBJS)
-	$(AR) -rc $@ $(CORE_OBJS)
-
-paster: paster.sh
-	cp paster.sh paster
-	chmod +x paster
-
-pasterd: $(CORE_LIB)
-
-clean:
-	rm -f $(CORE_LIB) $(CORE_OBJS)
-	rm -f paster pasterd
-	rm -f test.db $(TESTS_OBJS)
-
-install-paster:
-	mkdir -p $(DESTDIR)$(BINDIR)
-	mkdir -p $(DESTDIR)$(MANDIR)/man1
-	cp paster $(DESTDIR)$(BINDIR)
-	chmod 755 $(DESTDIR)$(BINDIR)/paster
-	$(SED) < paster.1 > $(DESTDIR)$(MANDIR)/man1/paster.1
-
-install-pasterd:
-	mkdir -p $(DESTDIR)$(BINDIR)
-	mkdir -p $(DESTDIR)$(MANDIR)/man5
-	mkdir -p $(DESTDIR)$(MANDIR)/man8
-	cp pasterd $(DESTDIR)$(BINDIR)
-	mkdir -p $(DESTDIR)$(SHAREDIR)/paster
-	cp -R themes $(DESTDIR)$(SHAREDIR)/paster
-	$(SED) < pasterd.8 > $(DESTDIR)$(MANDIR)/man8/pasterd.8
-	$(SED) < pasterd-themes.5 > $(DESTDIR)$(MANDIR)/man5/pasterd-themes.5
-
-install: install-pasterd install-paster
-
-$(TESTS_OBJS): $(CORE_LIB)
-
-tests: $(TESTS)
-	for t in $(TESTS); do $$t; done
-
-.PHONY: all clean tests
--- a/pasterd-themes.5	Wed Mar 15 20:15:00 2023 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-.\"
-.\" Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
-.\"
-.\" Permission to use, copy, modify, and/or distribute this software for any
-.\" purpose with or without fee is hereby granted, provided that the above
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd 25 November, 2020
-.Dt PASTERD-THEMES 5
-.Os
-.\" NAME
-.Sh NAME
-.Nm pasterd-themes
-.Nd themes for pasterd
-.\" DESCRIPTION
-.Sh DESCRIPTION
-This manual page describes the file hierarchy and syntax required to create a
-new theme for
-.Nm pasterd .
-.Pp
-A theme consists of fragments and pages. A fragment is a piece of HTML code that
-may be repeated while a page is usually the HTML code that is inside the
-.Dq <body></body>
-HTML tag.
-.\" THEME STRUCTURE
-.Sh THEME STRUCTURE
-The easiest way to create a new theme is to copy the predefined
-.Pa minimal
-theme and adapt the files to the desired style. See it in
-@SHAREDIR@/paster/themes/minimal.
-.Pp
-The following files must be provided into a directory:
-.Bd -literal -offset indent
-theme/fragments/duration.html
-theme/fragments/language.html
-theme/fragments/footer.html
-theme/fragments/header.html
-theme/fragments/paste.html
-theme/pages/400.html
-theme/pages/404.html
-theme/pages/500.html
-theme/pages/paste.html
-theme/pages/index.html
-theme/pages/new.html
-theme/pages/search.html
-.Ed
-.Pp
-A special
-.Pa static
-directory into the theme can be used to provide non templates data such as
-images, Javascript and CSS files. They are not processed and provided as-is.
-.Pp
-See below for a description per file.
-.\" KEYWORDS
-.Sh KEYWORDS
-Templates files may contain keywords that are replaced during processing using
-the syntax
-.Dq @@variable@@ .
-.Pp
-The following keywords are supported:
-.Bl -tag -width 10n
-.It Va author
-The paste author.
-.It Va date
-Date as a string.
-.It Va duration
-Duration expressed as a string. May be
-.Dq hour ,
-.Dq day ,
-.Dq week ,
-.Dq month .
-.It Va durations
-Fragment repeated for every duration supported using
-.Pa fragments/duration.html
-template.
-.It Va language
-The paste language type.
-.It Va languages
-Fragment repeated for every language supported using
-.Pa fragments/language.html
-template.
-.It Va expiration
-The time left for the paste expressed as minutes, hours or days depending on the
-time left.
-.It Va id
-Unique paste indentifier.
-.It Va pastes
-Fragment repeated for every paste using
-.Pa fragments/paste.html
-template.
-.It Va public
-String set to
-.Dq Yes
-if public or
-.Dq \&No
-otherwise.
-.It Va title
-When used within header fragment, page's title otherwise paste's title.
-.El
-.\" PAGES AND FRAGMENTS
-.Sh PAGES AND FRAGMENTS
-.\" fragments/duration.html
-.Ss fragments/duration.html
-A fragment that should generate a
-.Dq <select>
-option for the given duration.
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va duration
-.El
-.\" fragments/footer.html
-.Ss fragments/footer.html
-Fragment applied at the end of a page.
-.\" fragments/header.html
-.Ss fragments/header.html
-Fragment applied at the beginning of a page.
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va title
-.El
-.\" fragments/language.html
-.Ss fragments/language.html
-A fragment that should generate a
-.Dq <select>
-option for the given language.
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va language
-.El
-.\" fragments/paste.html
-.Ss fragments/paste.html
-Repeated fragment in the
-.Pa pages/index.html
-page.
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va id
-.It
-.Va title
-.It
-.Va author
-.It
-.Va date
-.It
-.Va expiration
-.It
-.Va language
-.El
-.Ss pages/400.html
-.Ss pages/404.html
-.Ss pages/500.html
-Those pages are used to indicate an error that are generated from
-.Nm pasterd .
-.\" pages/index.html
-.Ss pages/index.html
-This page is the landing of the
-.Nm pasterd
-program. It should provide a list of last recents paste.
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va pastes
-.El
-.\" pages/paste.html
-.Ss pages/paste.html
-Details of a paste.
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va author
-.It
-.Va code
-.It
-.Va date
-.It
-.Va expiration
-.It
-.Va id
-.It
-.Va public
-.It
-.Va title
-.El
-.\" pages/new.html
-.Ss pages/new.html
-Create a form for sending a new paste. The form should submit a POST request to
-the same page with the following field data:
-.Pp
-.Bl -tag -width 10n
-.It Va author
-Paste author.
-.It Va code
-The code content.
-.It Va duration
-Paste duration (should use
-.Dq durations
-keyword).
-.It Va language
-The code language (should use
-.Dq languages
-keyword).
-.It Va title
-Paste title.
-.El
-.Pp
-Supported keywords:
-.Bl -bullet -compact
-.It
-.Va durations
-.It
-.Va languages
-.El
-.\" pages/search.html
-.Ss pages/search.html
-Create a form for searching pastes. The form should submit a POST request to
-the same page with the following field data:
-.Bl -tag
-.It Va author
-Author of paste.
-.It Va language
-Paste language.
-.It Va title
-Title to search
-.El
-.\" SEE ALSO
-.Sh SEE ALSO
-.Xr pasterd 8