]> git.corax.cc Git - mwm/commitdiff
Initial commit: Start with a minimal Makefile, manpage, and main.c master stable testing
authorMatthias Kruk <m@m10k.eu>
Sat, 1 May 2021 21:48:49 +0000 (06:48 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 1 May 2021 21:48:49 +0000 (06:48 +0900)
This commit adds a minimal Makefile, a short manpage, and a mwm
implementation that does nothing but print a help text.

Makefile [new file with mode: 0644]
docs/man/mwm.1 [new file with mode: 0644]
main.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
index 0000000..8b9c4ab
--- /dev/null
@@ -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 (file)
index 0000000..4caf55b
--- /dev/null
+++ b/main.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <getopt.h>
+
+#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);
+}