aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2012-12-19 15:01:45 +0100
committerBertrand Jacquin <beber@meleeweb.net>2013-11-27 22:18:34 +0100
commit2dfd5c93ca8df0c1c6e7d6b1e297aad0d033018d (patch)
tree1338ee37e0d3ecfc7ce872827f2690aef226b892
parentdoc update, mod_ruid2 is using Linux capabilities (diff)
downloadmod_ruid2-2dfd5c93ca8df0c1c6e7d6b1e297aad0d033018d.tar.gz
MINOR: Add a proper Makefile to build project.
Inspired from mod_virtualvalue Also, don't make reference to any version in code or elsewhere, this now come from git describe and CFLAGS definition Build the project (one of) : $ make $ make shared $ make all CC mod_ruid2.o CC mod_ruid2.so Build with verbose output : $ make V=1 cc -c -DMODULE_NAME='"mod_ruid2"' -DMODULE_VERSION='"v0.9.8-6-g20ec6cc-dev"' -fPIC -I/usr/include/apache2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apr-1 -W -Wall -o mod_ruid2.o mod_ruid2.c ld -shared -o mod_ruid2.so mod_ruid2.o -lapr-1 -luuid -lrt -lcrypt -lpthread -ldl -lcap Build with specific CFLAGS and CC : $ make CC=i586-pc-linux-gnu-gcc CFLAGS='-march=geode -Os -mmmx -m3dnow -I/data/cross/alix3-i586/firmware/usr/include' In this case default one (-fPIC is alway applied). Strip library : $ make strip STRIP mod_ruid2.so Build a tar for public release : $ make dist TAR mod_ruid2-v0.9.8-6-g20ec6cc-dev.tar XZ mod_ruid2-v0.9.8-6-g20ec6cc-dev.txz
-rw-r--r--.gitignore13
-rw-r--r--Makefile134
-rw-r--r--mod_ruid2.c8
3 files changed, 144 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 6e04ee5..9257bbc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,10 @@
-.libs/
-*.la
-*.lo
+# Compilation results
*.o
-*.slo
+*.so
+
+# Dist results
+*.tar
+*.txz
+
+# Hacking results
+*.patch
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..98413a6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,134 @@
+#!/usr/bin/make -f <
+#
+# Copyright (C) 2013 Bertrand Jacquin <beber@meleeweb.net>
+
+NAME = mod_ruid2
+VERSION = $(shell git describe --tags --dirty=-dev 2> /dev/null)
+
+SRC = \
+ mod_ruid2.c
+
+DOC_FILES = \
+ README \
+ ruid2.conf
+
+EXTRA_FILES = \
+ LICENSE \
+ Makefile
+
+PKG_CONFIG ?= pkg-config
+
+APR_CFLAGS = \
+ $(shell $(PKG_CONFIG) --cflags apr-1)
+
+APR_LDFLAGS = \
+ $(shell $(PKG_CONFIG) --libs apr-1)
+
+HTTPD_CFLAGS = \
+ -I/usr/include/apache2
+
+CAP_LDFLAGS = \
+ -lcap
+
+CFLAGS ?= \
+ -W -Wall
+
+SPEC_CFLAGS = \
+ -DMODULE_NAME='"$(NAME)"' \
+ -DMODULE_VERSION='"$(VERSION)"' \
+ -fPIC \
+ $(HTTPD_CFLAGS) \
+ $(APR_CFLAGS) \
+ $(CAP_CFLAGS)
+
+SPEC_LDFLAGS = \
+ $(HTTPD_LDFLAGS) \
+ $(APR_LDFLAGS) \
+ $(CAP_LDFLAGS)
+
+ifdef DEBUG
+SPEC_CFLAGS +=\
+ -DDEBUG \
+ -g -ggdb
+endif # DEBUG
+
+CC ?= cc
+
+STRIP ?= strip
+STRIP_FLAGS ?= --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.build-id
+
+INSTALL ?= install
+
+RM ?= rm -f
+
+TAR = tar
+XZ = xz
+
+DESTDIR ?=
+PREFIX ?= /usr/local
+MODDIR ?= $(PREFIX)/lib/apache2/modules
+DOCDIR ?= $(PREFIX)/share/doc/$(NAME)
+
+ifeq ($(V),)
+ Q = @
+
+ quiet_cmd = @printf " %-6s %s\n" "$(1)" "$(2)";
+endif # $(V)
+
+all: shared
+
+shared: $(NAME).so
+dist: $(NAME)-$(VERSION).txz
+
+# Build rules
+%.o: %.c
+ $(call quiet_cmd,CC,$@)
+ $(Q)$(CC) -c $(SPEC_CFLAGS) $(CFLAGS) -o $@ $<
+
+$(NAME).so: $(SRC:c=o)
+ $(call quiet_cmd,CC,$@)
+ $(Q)$(CC) -shared -o $@ $^ $(SPEC_LDFLAGS) $(LDFLAGS)
+
+strip: $(NAME).so
+ $(call quiet_cmd,STRIP,$<)
+ $(Q)$(STRIP) $(STRIP_FLAGS) $<
+
+# Archiving rules
+$(NAME)-$(VERSION).tar: $(SRC) $(EXTRA_FILES) $(DOC_FILES)
+ $(call quiet_cmd,TAR,$@)
+ $(Q)$(TAR) cf $@ \
+ --transform "s,^,$(NAME)-$(VERSION)/," \
+ --force-local --numeric-owner \
+ $^
+
+%.txz: %.tar
+ $(call quiet_cmd,XZ,$@)
+ $(Q)$(XZ) -c > $@ < $<
+
+# Install rules
+install: \
+ $(DESTDIR)$(MODDIR)/$(NAME).so \
+ $(addprefix $(DESTDIR)$(DOCDIR)/,$(DOC_FILES))
+
+$(DESTDIR)$(MODDIR)/$(NAME).so: $(NAME).so
+ $(call quiet_cmd,INSTALL,$@)
+ $(Q)$(INSTALL) -D -m 444 $< $@
+
+$(DESTDIR)$(DOCDIR)/%: %
+ $(call quiet_cmd,INSTALL,$@)
+ $(Q)$(INSTALL) -D -m 444 $< $@
+
+# Cleanup rules
+clean:
+ $(call quiet_cmd,RM,$(SRC:c=o))
+ $(Q)$(RM) $(SRC:c=o)
+ $(call quiet_cmd,RM,$(NAME).so)
+ $(Q)$(RM) $(NAME).so
+
+distclean: clean
+ $(call quiet_cmd,RM,$(NAME)-$(VERSION).tar)
+ $(Q)$(RM) $(NAME)-$(VERSION).tar
+ $(call quiet_cmd,RM,$(NAME)-$(VERSION).txz)
+ $(Q)$(RM) $(NAME)-$(VERSION).txz
+
+.PHONY: strip
diff --git a/mod_ruid2.c b/mod_ruid2.c
index 30d81b2..96f7bcb 100644
--- a/mod_ruid2.c
+++ b/mod_ruid2.c
@@ -1,5 +1,5 @@
/*
- mod_ruid2 0.9.8
+ mod_ruid2
Copyright (C) 2009-2013 Monshouwer Internet Diensten
Author: Kees Monshouwer
@@ -22,9 +22,6 @@
- mod_ruid - http://websupport.sk/~stanojr/projects/mod_ruid/
Copyright 2004 by Pavel Stano. All rights reserved
- Instalation:
- - /usr/apache/bin/apxs -a -i -l cap -c mod_ruid2.c
-
Issues:
- https://github.com/mind04/mod-ruid2/issues
*/
@@ -50,9 +47,6 @@
#include <sys/prctl.h>
#include <sys/capability.h>
-#define MODULE_NAME "mod_ruid2"
-#define MODULE_VERSION "0.9.8"
-
#define RUID_MIN_UID 100
#define RUID_MIN_GID 100