From: Matthias Kruk Date: Sat, 1 May 2021 21:48:49 +0000 (+0900) Subject: Initial commit: Start with a minimal Makefile, manpage, and main.c X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=5131ef7569caba37fab998c32fd338e30d81fa3e;p=mwm Initial commit: Start with a minimal Makefile, manpage, and main.c This commit adds a minimal Makefile, a short manpage, and a mwm implementation that does nothing but print a help text. --- 5131ef7569caba37fab998c32fd338e30d81fa3e diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..916e762 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +OUTPUT = mwm +OBJECTS = main.o + +ifeq ($(PREFIX), ) + PREFIX = /usr/local +endif +ifeq ($(MANPREFIX), ) + MANPREFIX = $(PREFIX)/share/man +endif + +CFLAGS = -std=c99 -pedantic -Wall -Wextra +LDFLAGS = + +PHONY = all clean install uninstall + +ifeq ($(DEBUG), 1) + CFLAGS += -g + LDFLAGS += -g +endif + +all: mwm + +install: all + mkdir -p $(DESTDIR)$(PREFIX)/bin + install -oroot -groot -m755 mwm $(DESTDIR)$(PREFIX)/bin + mkdir -p $(DESTDIR)$(MANPREFIX)/man1 + install -oroot -groot -m 644 docs/man/mwm.1 $(DESTDIR)$(MANPREFIX)/man1/mwm.1 + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/mwm + rm -f $(DESTDIR)$(MANPREFIX)/man1/mwm.1 + +mwm: $(OBJECTS) + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm -rf $(OBJECTS) + +.PHONY: $(PHONY) diff --git a/docs/man/mwm.1 b/docs/man/mwm.1 new file mode 100644 index 0000000..8b9c4ab --- /dev/null +++ b/docs/man/mwm.1 @@ -0,0 +1,21 @@ +.TH MWM 1 mwm\-0.1 + +.SH NAME +mwm \- m window manager + +.SH SYNOPSIS +.B mwm +.RB [ \-h ] + +.SH DESCRIPTION +mwm is a tiling window manager for X. +.P + +.SH OPTIONS +.TP +.B \-h, \-\-help +prints a help text to standard output. + + +.SH AUTHORS +.B Matthias Kruk diff --git a/main.c b/main.c new file mode 100644 index 0000000..4caf55b --- /dev/null +++ b/main.c @@ -0,0 +1,40 @@ +#include +#include + +#define SHORTOPTS "h" + +static struct option cmd_opts[] = { + { "help", no_argument, 0, 'h' }, + { NULL } +}; + +static void print_usage(const char *argv0) +{ + printf("Usage: %s [-h]\n" + "\n" + "Options:\n" + " -h --help Print this text\n", + argv0); + return; +} + +int main(int argc, char *argv[]) +{ + int opt; + + do { + opt = getopt_long(argc, argv, SHORTOPTS, cmd_opts, NULL); + + switch(opt) { + case 'h': + print_usage(argv[0]); + return(1); + + default: + opt = -1; + break; + } + } while(opt >= 0); + + return(0); +}