summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile36
-rw-r--r--doc/simpleswitcher.1 (renamed from simpleswitcher.1)0
-rw-r--r--include/textbox.h (renamed from textbox.h)8
-rw-r--r--source/simpleswitcher.c (renamed from simpleswitcher.c)0
-rw-r--r--source/textbox.c (renamed from textbox.c)8
6 files changed, 36 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..3cca2b70
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.swp
+build/
diff --git a/Makefile b/Makefile
index a8946f2f..cc723c12 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,25 @@
CFLAGS?=-Wall -Wextra -O3
+
+PROGRAM=simpleswitcher
+
+
PREFIX?=$(DESTDIR)/usr
BINDIR?=$(PREFIX)/bin
MANDIR?=$(PREFIX)/share/man/man1
-SOURCES=$(wildcard *.c)
-OBJECTS=$(SOURCES:%.c=%.o)
+BUILD_DIR=build
+SOURCE_DIR=source
+DOC_DIR=doc
+
+SOURCES=$(wildcard $(SOURCE_DIR)/*.c)
+OBJECTS=$(SOURCES:$(SOURCE_DIR)/%.c=$(BUILD_DIR)/%.o)
+HEADERS=$(wildcard include/*.h)
MANPAGE_PATH=$(MANDIR)/simpleswitcher.1.gz
CFLAGS+=-DMANPAGE_PATH="\"$(MANPAGE_PATH)\""
CFLAGS+=-std=c99
+CFLAGS+=-Iinclude/
# Check deps.
ifeq (${DEBUG},1)
@@ -43,22 +53,28 @@ $(info I3 mode is enabled)
CFLAGS+=-DI3 -I${PREFIX}/include/
endif
-all: normal
+all: $(BUILD_DIR)/$(PROGRAM)
+
+$(BUILD_DIR):
+ mkdir -p $@
+# Objects depend on header files and makefile too.
+$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c | Makefile $(HEADERS) $(BUILD_DIR)
+ $(CC) $(CFLAGS) -c -o $@ $^
-normal: $(OBJECTS) | Makefile
- $(CC) -o simpleswitcher $^ $(LDADD) $(LDFLAGS)
+$(BUILD_DIR)/$(PROGRAM): $(OBJECTS)
+ $(CC) -o $@ $^ $(LDADD) $(LDFLAGS)
-install: normal install-man
- install -Dm 755 simpleswitcher $(BINDIR)/simpleswitcher
+install: $(BUILD_DIR)/$(PROGRAM) install-man
+ install -Dm 755 $(BUILD_DIR)/$(PROGRAM) $(BINDIR)/$(PROGRAM)
install-man:
- install -Dm 644 simpleswitcher.1 $(MANDIR)/simpleswitcher.1
+ install -Dm 644 $(DOC_DIR)/simpleswitcher.1 $(MANDIR)/simpleswitcher.1
gzip -f $(MANDIR)/simpleswitcher.1
clean:
- rm -f simpleswitcher $(OBJECTS)
+ rm -rf $(BUILD_DIR)
indent:
- @astyle --style=linux -S -C -D -N -H -L -W3 -f simpleswitcher.c textbox.c
+ @astyle --style=linux -S -C -D -N -H -L -W3 -f $(SOURCES) $(HEADERS)
diff --git a/simpleswitcher.1 b/doc/simpleswitcher.1
index c7d3048d..c7d3048d 100644
--- a/simpleswitcher.1
+++ b/doc/simpleswitcher.1
diff --git a/textbox.h b/include/textbox.h
index 237190be..4e4061b1 100644
--- a/textbox.h
+++ b/include/textbox.h
@@ -28,10 +28,10 @@ typedef enum {
textbox* textbox_create( Window parent,
- TextboxFlags flags,
- short x, short y, short w, short h,
- char *font, char *fg, char *bg,
- char *text, char *prompt );
+ TextboxFlags flags,
+ short x, short y, short w, short h,
+ char *font, char *fg, char *bg,
+ char *text, char *prompt );
void textbox_free( textbox *tb );
diff --git a/simpleswitcher.c b/source/simpleswitcher.c
index df354909..df354909 100644
--- a/simpleswitcher.c
+++ b/source/simpleswitcher.c
diff --git a/textbox.c b/source/textbox.c
index 669c6fda..5d968b81 100644
--- a/textbox.c
+++ b/source/textbox.c
@@ -49,10 +49,10 @@ void textbox_moveresize( textbox *tb, int x, int y, int w, int h );
// Xft text box, optionally editable
textbox* textbox_create( Window parent,
- TextboxFlags flags,
- short x, short y, short w, short h,
- char *font, char *fg, char *bg,
- char *text, char *prompt )
+ TextboxFlags flags,
+ short x, short y, short w, short h,
+ char *font, char *fg, char *bg,
+ char *text, char *prompt )
{
textbox *tb = calloc( 1, sizeof( textbox ) );