From fdef025a909e2410aefbe335e3255ab64919c646 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 26 Sep 2014 19:29:25 +0200 Subject: make derp + sed config.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .gitignore | 2 + Makefile | 8 +- TODO | 2 - mk/build.mk | 59 ++++++++---- mk/config.mk | 51 ++++++++++ src/libmdsserver/config.h | 221 ------------------------------------------- src/libmdsserver/config.h.in | 173 +++++++++++++++++++++++++++++++++ 7 files changed, 275 insertions(+), 241 deletions(-) delete mode 100644 src/libmdsserver/config.h create mode 100644 src/libmdsserver/config.h.in diff --git a/.gitignore b/.gitignore index 4f7dd78..ef6dc6f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,7 @@ obj/ *.su *.gch *.out +*.so *.o +/src/libmdsserver/config.h diff --git a/Makefile b/Makefile index 28bf9eb..b01123d 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,12 @@ OBJ_mds-registry_ = mds-registry util globals reexec registry signals \ OBJ_mds-server = $(foreach O,$(OBJ_mds-server_),obj/mds-server/$(O).o) OBJ_mds-registry = $(foreach O,$(OBJ_mds-registry_),obj/mds-registry/$(O).o) +ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) +SEDED = src/libmdsserver/config.h +else +SEDED = +endif + # Build rules. @@ -51,5 +57,5 @@ perms: all .PHONY: clean clean: - -rm -rf obj bin + -rm -rf obj bin $(SEDED) diff --git a/TODO b/TODO index 0659653..3c1d7bd 100644 --- a/TODO +++ b/TODO @@ -54,7 +54,5 @@ A facility is needed to lookup available compose sequences to any character, Servers should be stored in LIBEXECDIR. Implement reconnect_to_display() -src/libmdsserver/config.h should be sed:ed rather than use #ifndef - Something is up with the test, it does not exit on Control+C diff --git a/mk/build.mk b/mk/build.mk index 7e2f8ac..c74d93c 100644 --- a/mk/build.mk +++ b/mk/build.mk @@ -14,9 +14,9 @@ servers: $(foreach S,$(SERVERS),bin/$(S)) # Link large servers. ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) -bin/mds-server: $(OBJ_mds-server) obj/mds-base.o src/mds-server/*.h bin/libmdsserver.so +bin/mds-server: $(OBJ_mds-server) obj/mds-base.o src/mds-server/*.h bin/libmdsserver.so $(SEDED) else -bin/mds-server: $(OBJ_mds-server) obj/mds-base.o src/mds-server/*.h +bin/mds-server: $(OBJ_mds-server) obj/mds-base.o src/mds-server/*.h $(SEDED) endif mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_mds-server) $(OBJ_mds-server) obj/mds-base.o @@ -27,51 +27,45 @@ endif ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) -bin/mds-registry: $(OBJ_mds-registry) obj/mds-base.o src/mds-registry/*.h bin/libmdsserver.so +bin/mds-registry: $(OBJ_mds-registry) obj/mds-base.o src/mds-registry/*.h bin/libmdsserver.so $(SEDED) else -bin/mds-registry: $(OBJ_mds-registry) obj/mds-base.o src/mds-registry/*.h +bin/mds-registry: $(OBJ_mds-registry) obj/mds-base.o src/mds-registry/*.h $(SEDED) endif mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_mds-registry) $(OBJ_mds-registry) obj/mds-base.o - mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_mds-registry) $(OBJ_mds-registry) obj/mds-base.o # Link small servers. ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) -bin/%: obj/%.o obj/mds-base.o bin/libmdsserver.so +bin/%: obj/%.o obj/mds-base.o bin/libmdsserver.so $(SEDED) else -bin/%: obj/%.o obj/mds-base.o +bin/%: obj/%.o obj/mds-base.o $(SEDED) endif mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_$*) $< obj/mds-base.o - mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_$*) $< obj/mds-base.o # Link kernel. ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) -bin/mds: obj/mds.o bin/libmdsserver.so +bin/mds: obj/mds.o bin/libmdsserver.so $(SEDED) else -bin/mds: obj/mds.o +bin/mds: obj/mds.o $(SEDED) endif mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_mds) $< - mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) -o $@ $(LDS) $(LDS_mds) $< # Build object files for kernel/servers. ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) -obj/%.o: src/%.c $(shell dirname src/%)/*.h src/mds-base.h src/libmdsserver/*.h +obj/%.o: src/%.c $(shell dirname src/%)/*.h src/mds-base.h src/libmdsserver/*.h $(SEDED) mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -Isrc -c -o $@ $< else -obj/%.o: src/%.c $(shell dirname src/%)/*.h src/mds-base.h +obj/%.o: src/%.c $(shell dirname src/%)/*.h src/mds-base.h $(SEDED) mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -c -o $@ $< endif @@ -83,7 +77,38 @@ bin/libmdsserver.so: $(foreach O,$(LIBOBJ),obj/libmdsserver/$(O).o) mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -shared -o $@ $^ -obj/libmdsserver/%.o: src/libmdsserver/%.c src/libmdsserver/*.h +obj/libmdsserver/%.o: src/libmdsserver/%.c src/libmdsserver/*.h $(SEDED) mkdir -p $(shell dirname $@) $(CC) $(C_FLAGS) -fPIC -c -o $@ $< + +# sed header files. +ifneq ($(LIBMDSSERVER_IS_INSTALLED),y) +src/libmdsserver/config.h: src/libmdsserver/config.h.in + cp $< $@ + sed -i 's:@PKGNAME@:$(PKGNAME):g' $@ + sed -i 's:@LIBEXECDIR@:$(LIBEXECDIR):g' $@ + sed -i 's:@TMPDIR@:$(TMPDIR):g' $@ + sed -i 's:@RUNDIR@:$(RUNDIR):g' $@ + sed -i 's:@SYSCONFDIR@:$(SYSCONFDIR):g' $@ + sed -i 's:@DEVDIR@:$(DEVDIR):g' $@ + sed -i 's:@ROOT_USER_UID@:$(ROOT_USER_UID):g' $@ + sed -i 's:@ROOT_GROUP_GID@:$(ROOT_GROUP_GID):g' $@ + sed -i 's:@NOBODY_GROUP_GID@:$(NOBODY_GROUP_GID):g' $@ + sed -i 's:@TOKEN_LENGTH@:$(TOKEN_LENGTH):g' $@ + sed -i 's:@ARGC_LIMIT@:$(ARGC_LIMIT):g' $@ + sed -i 's:@LIBEXEC_ARGC_EXTRA_LIMIT@:$(LIBEXEC_ARGC_EXTRA_LIMIT):g' $@ + sed -i 's:@DISPLAY_MAX@:$(DISPLAY_MAX):g' $@ + sed -i 's:@RESPAWN_TIME_LIMIT_SECONDS@:$(RESPAWN_TIME_LIMIT_SECONDS):g' $@ + sed -i 's:@DISPLAY_ENV@:$(DISPLAY_ENV):g' $@ + sed -i 's:@PGROUP_ENV@:$(PGROUP_ENV):g' $@ + sed -i 's:@INITRC_FILE@:$(INITRC_FILE):g' $@ + sed -i 's:@SELF_EXE@:$(SELF_EXE):g' $@ + sed -i 's:@SELF_FD@:$(SELF_FD):g' $@ + sed -i 's:@TOKEN_RANDOM@:$(TOKEN_RANDOM):g' $@ + sed -i 's:@VT_PATH_PATTERN@:$(VT_PATH_PATTERN):g' $@ + sed -i 's:@SHM_PATH_PATTERN@:$(SHM_PATH_PATTERN):g' $@ + sed -i 's:@MDS_RUNTIME_ROOT_DIRECTORY@:$(MDS_RUNTIME_ROOT_DIRECTORY):g' $@ + sed -i 's:@MDS_STORAGE_ROOT_DIRECTORY@:$(MDS_STORAGE_ROOT_DIRECTORY):g' $@ +endif + diff --git a/mk/config.mk b/mk/config.mk index a961a53..d824b73 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -28,10 +28,61 @@ DOCDIR ?= $(DATADIR)/doc INFODIR ?= $(DATADIR)/info # The license base path including prefix. LICENSEDIR ?= $(DATADIR)/licenses +# The transient directory for temporary files. +TMPDIR ?= /tmp +# The transient directory for runtime files. +RUNDIR ?= /run +# The directory for site-specific configurations. +SYSCONFDIR ?= /etc +# The directory for pseudo-devices. +DEVDIR ?= /dev +# The /proc directory +PROCDIR ?= /proc +# The /proc/self directory +SELFPROCDIR ?= $(PROCDIR)/self # The name of the package as it should be installed. PKGNAME ?= mds +# The user ID for the root user. +ROOT_USER_UID = 0 +# The group ID for the root group. +ROOT_GROUP_GID = 0 +# The group ID for the nobody group. +NOBODY_GROUP_GID = $(ROOT_GROUP_GID) +# The path of the symlink to the executed command +SELF_EXE = $(SELFPROCDIR)/exe +# The path to the directory with symlinks to each file that is open +SELF_FD = $(SELFPROCDIR)/fd +# Random number generator to use for generating a token. +TOKEN_RANDOM = $(DEVDIR)/urandom +# Pathname pattern for virtual terminals. +VT_PATH_PATTERN = $(DEVDIR)/tty%i + +# The byte length of the authentication token. +TOKEN_LENGTH = 1024 +# The maximum number of command line arguments to allow. +ARGC_LIMIT = 50 +# The number of additional arguments a libexec server may have. +LIBEXEC_ARGC_EXTRA_LIMIT = 5 +# The maximum number of display allowed on the system. +DISPLAY_MAX = 1000 +# The minimum time that most have elapsed for respawning to be allowed. +RESPAWN_TIME_LIMIT_SECONDS = 5 +# Pattern for the names of shared object to which states are marshalled. +SHM_PATH_PATTERN = /.proc-pid-%ji + +# The name of the environment variable that indicates the index of the display. +DISPLAY_ENV = MDS_DISPLAY +# The name of the environment variable that indicates the display server's process group. +PGROUP_ENV = MDS_PGROUP +# The dot-prefixless basename of the initrc file that the master server executes. +INITRC_FILE = mdsinitrc +# The root directory of all runtime data stored by mds. +MDS_RUNTIME_ROOT_DIRECTORY = $(RUNDIR)/$(PKGNAME) +# The root directory of temporarily stored data stored by mds servers. +MDS_STORAGE_ROOT_DIRECTORY = $(TMPDIR)/.{system-directory}.$(PKGNAME) + # Optimisation level (and debug flags.) OPTIMISE = -Og -g diff --git a/src/libmdsserver/config.h b/src/libmdsserver/config.h deleted file mode 100644 index b4a0087..0000000 --- a/src/libmdsserver/config.h +++ /dev/null @@ -1,221 +0,0 @@ -/** - * mds — A micro-display server - * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef MDS_CONFIG_H -#define MDS_CONFIG_H - - -/** - * The name under which this package is installed - */ -#ifndef PKGNAME -#define PKGNAME "mds" -#endif - - -/** - * The directory where all servers are installed - */ -#ifndef LIBEXECDIR -#define LIBEXECDIR "/usr/libexec" -#endif - - -/** - * The system's directory for non-persistent temporary files - */ -#ifndef TMPDIR -#define TMPDIR "/tmp" -#endif - - -/** - * The system's directory for runtime data - */ -#ifndef RUNDIR -#define RUNDIR "/run" -#endif - - -/** - * The system's directory for site-specific configurations - */ -#ifndef SYSCONFDIR -#define SYSCONFDIR "/etc" -#endif - - -/** - * The system's directory for pseudo-devices - */ -#ifndef DEVDIR -#define DEVDIR "/dev" -#endif - - -/** - * Pathname pattern for virtual terminals - */ -#ifndef VT_PATH_PATTERN -#define VT_PATH_PATTERN DEVDIR "/tty%i" -#endif - - -/** - * The root directory of all runtime data stored by MDS - */ -#ifndef MDS_RUNTIME_ROOT_DIRECTORY -#define MDS_RUNTIME_ROOT_DIRECTORY RUNDIR "/" PKGNAME -#endif - - -/** - * The root directory of temporarily stored data stored by MDS servers - */ -#ifndef MDS_STORAGE_ROOT_DIRECTORY -#define MDS_STORAGE_ROOT_DIRECTORY TMPDIR "/.{system-directory}." PKGNAME -#endif - - -/** - * The user ID for the root user - */ -#ifndef ROOT_USER_UID -#define ROOT_USER_UID 0 -#endif - - -/** - * The group ID for the root group - */ -#ifndef ROOT_GROUP_GID -#define ROOT_GROUP_GID 0 -#endif - - -/** - * The group ID for the nobody group - */ -#ifndef NOBODY_GROUP_GID -#define NOBODY_GROUP_GID ROOT_GROUP_GID -#endif - -/* These three names above are redundant, but that is to avoid errors. */ - - -/** - * The byte length of the authentication token - */ -#ifndef TOKEN_LENGTH -#define TOKEN_LENGTH 1024 -#endif - - -/** - * Random number generator to use for generating a token - */ -#ifndef TOKEN_RANDOM -#define TOKEN_RANDOM "/dev/urandom" -#endif - - -/** - * The path of the symlink to the executed command - */ -#ifndef SELF_EXE -#define SELF_EXE "/proc/self/exe" -#endif - - -/** - * The path to the directory with symlinks to each file that is open - */ -#ifndef SELF_FD -#define SELF_FD "/proc/self/fd" -#endif - - -/** - * Pattern for the names of shared object to which states are marshalled - */ -#ifndef SHM_PATH_PATTERN -#define SHM_PATH_PATTERN "/.proc-pid-%ji" -#endif - - -/** - * The maximum number of command line arguments to allow - */ -#ifndef ARGC_LIMIT -#define ARGC_LIMIT 50 -#endif - - -/** - * The number of additional arguments a libexec server may have - */ -#ifndef LIBEXEC_ARGC_EXTRA_LIMIT -#define LIBEXEC_ARGC_EXTRA_LIMIT 5 -#endif - - -/** - * The maximum number of display allowed on the system - */ -#ifndef DISPLAY_MAX -#define DISPLAY_MAX 1000 -#endif - - -/** - * The name of the environment variable that - * indicates the index of the display - */ -#ifndef DISPLAY_ENV -#define DISPLAY_ENV "MDS_DISPLAY" -#endif - - -/** - * The name of the environment variable that - * indicates the display server's process group - */ -#ifndef PGROUP_ENV -#define PGROUP_ENV "MDS_PGROUP" -#endif - - -/** - * The minimum time that most have elapsed - * for respawning to be allowed - */ -#ifndef RESPAWN_TIME_LIMIT_SECONDS -#define RESPAWN_TIME_LIMIT_SECONDS 5 -#endif - - -/** - * The dot-prefixless basename of the initrc - * file that the master server executes - */ -#ifndef INITRC_FILE -#define INITRC_FILE "mdsinitrc" -#endif - - -#endif - diff --git a/src/libmdsserver/config.h.in b/src/libmdsserver/config.h.in new file mode 100644 index 0000000..ceb6043 --- /dev/null +++ b/src/libmdsserver/config.h.in @@ -0,0 +1,173 @@ +/** + * mds — A micro-display server + * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef MDS_CONFIG_H +#define MDS_CONFIG_H + + +/** + * The name under which this package is installed + */ +#define PKGNAME "@PKGNAME@" + + +/** + * The directory where all servers are installed + */ +#define LIBEXECDIR "@LIBEXECDIR@" + + +/** + * The system's directory for non-persistent temporary files + */ +#define TMPDIR "@TMPDIR@" + + +/** + * The system's directory for runtime data + */ +#define RUNDIR "@RUNDIR@" + + +/** + * The system's directory for site-specific configurations + */ +#define SYSCONFDIR "@SYSCONFDIR@" + + +/** + * The system's directory for pseudo-devices + */ +#define DEVDIR "@DEVDIR@" + + +/** + * Pathname pattern for virtual terminals + */ +#define VT_PATH_PATTERN "@VT_PATH_PATTERN@" + + +/** + * The root directory of all runtime data stored by mds + */ +#define MDS_RUNTIME_ROOT_DIRECTORY "@MDS_RUNTIME_ROOT_DIRECTORY@" + + +/** + * The root directory of temporarily stored data stored by mds servers + */ +#define MDS_STORAGE_ROOT_DIRECTORY "@MDS_STORAGE_ROOT_DIRECTORY@" + + +/** + * The user ID for the root user + */ +#define ROOT_USER_UID @ROOT_USER_UID@ + + +/** + * The group ID for the root group + */ +#define ROOT_GROUP_GID @ROOT_GROUP_GID@ + + +/** + * The group ID for the nobody group + */ +#define NOBODY_GROUP_GID @NOBODY_GROUP_GID@ + +/* These three names above are redundant, but that is to avoid errors. */ + + +/** + * The byte length of the authentication token + */ +#define TOKEN_LENGTH @TOKEN_LENGTH@ + + +/** + * Random number generator to use for generating a token + */ +#define TOKEN_RANDOM "@TOKEN_RANDOM@" + + +/** + * The path of the symlink to the executed command + */ +#define SELF_EXE "@SELF_EXE@" + + +/** + * The path to the directory with symlinks to each file that is open + */ +#define SELF_FD "@SELF_FD@" + + +/** + * Pattern for the names of shared object to which states are marshalled + */ +#define SHM_PATH_PATTERN "@SHM_PATH_PATTERN@" + + +/** + * The maximum number of command line arguments to allow + */ +#define ARGC_LIMIT @ARGC_LIMIT@ + + +/** + * The number of additional arguments a libexec server may have + */ +#define LIBEXEC_ARGC_EXTRA_LIMIT @LIBEXEC_ARGC_EXTRA_LIMIT@ + + +/** + * The maximum number of display allowed on the system + */ +#define DISPLAY_MAX @DISPLAY_MAX@ + + +/** + * The name of the environment variable that + * indicates the index of the display + */ +#define DISPLAY_ENV "@DISPLAY_ENV@" + + +/** + * The name of the environment variable that + * indicates the display server's process group + */ +#define PGROUP_ENV "@PGROUP_ENV@" + + +/** + * The minimum time that most have elapsed + * for respawning to be allowed + */ +#define RESPAWN_TIME_LIMIT_SECONDS @RESPAWN_TIME_LIMIT_SECONDS@ + + +/** + * The dot-prefixless basename of the initrc + * file that the master server executes + */ +#define INITRC_FILE "@INITRC_FILE@" + + +#endif + -- cgit v1.2.3-70-g09d2