summaryrefslogtreecommitdiff
path: root/make/template
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-17 00:29:28 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-17 00:29:28 +0000
commit5de7651ebeee56e6deca4d5e357b22869719bb8f (patch)
tree35dfa806556becd8190a6e891d2434dc7caf7c21 /make/template
parent54242e2c5839c5493a344badb49cbcb76e298f9f (diff)
Make a ./configure --system to support system-wide installation of inspircd
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12275 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'make/template')
-rw-r--r--make/template/inspircd17
-rw-r--r--make/template/main.mk35
2 files changed, 34 insertions, 18 deletions
diff --git a/make/template/inspircd b/make/template/inspircd
index 6a74d1ec1..92f3f3bac 100644
--- a/make/template/inspircd
+++ b/make/template/inspircd
@@ -22,6 +22,23 @@ my $runpath = "@BASE_DIR@";
my $valgrindlogpath = "$basepath/valgrindlogs";
my $executable = "@EXECUTABLE@";
my $version = "@VERSION@";
+my $uid = "@UID@";
+
+if ($< == 0 || $> == 0) {
+ if ($uid !~ /^\d+$/) {
+ # Named UID, look it up
+ $uid = getpwnam $uid;
+ }
+ if (!$uid) {
+ die "Cannot find a valid UID to change to";
+ }
+ # drop root if we were configured with an ircd UID
+ $< = $uid;
+ $> = $uid;
+ if ($< == 0 || $> == 0) {
+ die "Could not drop root: $!";
+ }
+}
our($pid,$pidfile);
# Lets see what they want to do.. Set the variable (Cause i'm a lazy coder)
diff --git a/make/template/main.mk b/make/template/main.mk
index 88514029b..1413d2fff 100644
--- a/make/template/main.mk
+++ b/make/template/main.mk
@@ -24,7 +24,10 @@ BASE = "@BASE_DIR@"
CONPATH = "@CONFIG_DIR@"
MODPATH = "@MODULE_DIR@"
BINPATH = "@BINARY_DIR@"
-INSTMODE = 0755
+INSTUID = @UID@
+INSTMODE_DIR = 0755
+INSTMODE_BIN = 0755
+INSTMODE_LIB = 0644
@IFEQ $(CC) icc
CXXFLAGS += -Wshadow
@@ -78,7 +81,7 @@ CXXFLAGS += -Iinclude
@ENDIF
@DO_EXPORT RUNCC CXXFLAGS CC LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS PURE_STATIC
-@DO_EXPORT BASE CONPATH MODPATH BINPATH SOURCEPATH BUILDPATH
+@DO_EXPORT BASE CONPATH MODPATH BINPATH SOURCEPATH BUILDPATH INSTUID
# Default target
TARGET = all
@@ -100,7 +103,6 @@ all: $(FOOTER)
target: $(HEADER)
$(MAKEENV) perl make/calcdep.pl
- @if [ `id -u` = 0 ] && [ ! -e .force-root-ok ]; then echo "Don't compile or install as root!"; exit 1; fi
cd $(BUILDPATH); $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
debug:
@@ -147,15 +149,16 @@ finishmessage: target
@echo "*************************************"
install: target@EXTRA_DIR@
- @-install -d -m $(INSTMODE) $(BASE)
- @-install -d -m $(INSTMODE) $(BASE)/data
- @-install -d -m $(INSTMODE) $(BASE)/logs
- @-install -d -m $(INSTMODE) $(BINPATH)
- @-install -d -m $(INSTMODE) $(CONPATH)
- @-install -d -m $(INSTMODE) $(MODPATH)
- -install -m $(INSTMODE) $(BUILDPATH)/modules/*.so $(MODPATH)
- -install -m $(INSTMODE) $(BUILDPATH)/bin/inspircd $(BINPATH)
- -install -m $(INSTMODE) @STARTSCRIPT@ $(@DESTINATION@) 2>/dev/null
+ @if [ $(INSTUID) = 0 ]; then echo "You must specify a non-root uid for the server"; exit 1; fi
+ @-install -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)
+ @-install -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)/data
+ @-install -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)/logs
+ @-install -d -m $(INSTMODE_DIR) $(BINPATH)
+ @-install -d -m $(INSTMODE_DIR) $(CONPATH)
+ @-install -d -m $(INSTMODE_DIR) $(MODPATH)
+ -install -m $(INSTMODE_BIN) @STARTSCRIPT@ $(BASE) 2>/dev/null
+ -install -m $(INSTMODE_BIN) $(BUILDPATH)/bin/inspircd $(BINPATH)
+ -install -m $(INSTMODE_LIB) $(BUILDPATH)/modules/*.so $(MODPATH)
@$(MAKEENV) make/install-extras.pl install
@echo ""
@echo "*************************************"
@@ -175,12 +178,8 @@ GNUmakefile BSDmakefile: make/template/main.mk configure $(RCS_FILES)
clean:
@echo Cleaning...
- @-rm -f src/inspircd src/modes/modeclasses.a include/inspircd_se_config.h
- @-rm -f src/*.so src/modules/*.so src/commands/*.so
- @-rm -f src/*.o src/*/*.o src/modules/*/*.o
- @-rm -f src/.*.d src/*/.*.d src/modules/*/.*.d
- @-rm -f $(BUILDPATH)/bin/inspircd $(BUILDPATH)/include $(BUILDPATH)/real.mk
- @-rm -rf $(BUILDPATH)/obj $(BUILDPATH)/modules
+ -rm -f $(BUILDPATH)/bin/inspircd $(BUILDPATH)/include $(BUILDPATH)/real.mk
+ -rm -rf $(BUILDPATH)/obj $(BUILDPATH)/modules
@-rmdir $(BUILDPATH)/bin 2>/dev/null
@-rmdir $(BUILDPATH) 2>/dev/null
@echo Completed.