memzap

replay memory writes
git clone git://git.2f30.org/memzap.git
Log | Files | Refs | README | LICENSE

commit 20e255d7fbd44812f0a1e2853439f9d5dea4e851
parent 1b7da1f9acb7bb64739fdceadc02f69026d857d8
Author: sin <sin@2f30.org>
Date:   Sun Mar  3 04:59:54 +0200

Better Makefile system

Diffstat:
Makefile | 48+++++++++++++++---------------------------------
Makefile.linux | 48+++++++++++++++---------------------------------
Makefile.openbsd | 48+++++++++++++-----------------------------------
common.mk | 14++++++++++++++
commonvar.mk | 20++++++++++++++++++++
5 files changed, 77 insertions(+), 101 deletions(-)
diff --git a/Makefile b/Makefile @@ -1,39 +1,21 @@ -BIN = memzap -VER = 0.1 -SRC = memzap.c mem.c utils.c md5.c mdiff.c linux_ops.c -OBJ = ${SRC:.c=.o} -TERMBOX_SRC = $(wildcard termbox/*.c) -TERMBOX_OBJ = ${TERMBOX_SRC:.c=.o} +include commonvar.mk +SRC := linux_ops.c $(SRC) +OBJ = $(SRC:.c=.o) -PREFIX = /usr +include common.mk -CC = gcc +memzap: $(OBJ) memzap.c + @echo -e " LD\t$@" + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -INCS = -I/usr/local/include -LIBS = -L/usr/local/lib - -CFLAGS += -g -O3 -Wall -Wextra -Wunused -DVERSION=\"${VER}\" ${INCS} -LDFLAGS += - -${BIN}: ${OBJ} ${TERMBOX_OBJ} - ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJ} ${TERMBOX_OBJ} +mdiffdump: $(OBJ) mdiffdump.c + @echo -e " LD\t$@" + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ termbox/%.o: termbox/%.c $(wildcard termbox/*.h) - ${CC} ${CFLAGS} -Itermbox -c -o $@ $< - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< - -clean: - rm -rf ${BIN} ${OBJ} ${TERMBOX_OBJ} - -all: memzap - -install: - cp -f ${BIN} ${PREFIX}/bin - chmod 755 ${PREFIX}/bin/${BIN} - -uninstall: - rm -f ${PREFIX}/bin/${BIN} + @echo -e " CC\t$@" + @$(CC) $(CFLAGS) -Itermbox -c -o $@ $< -.PHONY: all clean install uninstall +%.o: %.c $(wildcard *.h) + @echo -e " CC\t$@" + @$(CC) $(CFLAGS) -c -o $@ $< diff --git a/Makefile.linux b/Makefile.linux @@ -1,39 +1,21 @@ -BIN = memzap -VER = 0.1 -SRC = memzap.c mem.c utils.c md5.c mdiff.c linux_ops.c -OBJ = ${SRC:.c=.o} -TERMBOX_SRC = $(wildcard termbox/*.c) -TERMBOX_OBJ = ${TERMBOX_SRC:.c=.o} +include commonvar.mk +SRC := linux_ops.c $(SRC) +OBJ = $(SRC:.c=.o) -PREFIX = /usr +include common.mk -CC = gcc +memzap: $(OBJ) memzap.c + @echo -e " LD\t$@" + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -INCS = -I/usr/local/include -LIBS = -L/usr/local/lib - -CFLAGS += -g -O3 -Wall -Wextra -Wunused -DVERSION=\"${VER}\" ${INCS} -LDFLAGS += - -${BIN}: ${OBJ} ${TERMBOX_OBJ} - ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJ} ${TERMBOX_OBJ} +mdiffdump: $(OBJ) mdiffdump.c + @echo -e " LD\t$@" + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ termbox/%.o: termbox/%.c $(wildcard termbox/*.h) - ${CC} ${CFLAGS} -Itermbox -c -o $@ $< - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< - -clean: - rm -rf ${BIN} ${OBJ} ${TERMBOX_OBJ} - -all: memzap - -install: - cp -f ${BIN} ${PREFIX}/bin - chmod 755 ${PREFIX}/bin/${BIN} - -uninstall: - rm -f ${PREFIX}/bin/${BIN} + @echo -e " CC\t$@" + @$(CC) $(CFLAGS) -Itermbox -c -o $@ $< -.PHONY: all clean install uninstall +%.o: %.c $(wildcard *.h) + @echo -e " CC\t$@" + @$(CC) $(CFLAGS) -c -o $@ $< diff --git a/Makefile.openbsd b/Makefile.openbsd @@ -1,39 +1,17 @@ -BIN = memzap -VER = 0.1 -SRC = memzap.c mem.c utils.c md5.c mdiff.c openbsd_ops.c -OBJ = ${SRC:.c=.o} -TERMBOX_SRC = $(wildcard termbox/*.c) -TERMBOX_OBJ = ${TERMBOX_SRC:.c=.o} +include commonvar.mk +SRC := openbsd_ops.c $(SRC) +OBJ = $(SRC:.c=.o) -PREFIX = /usr +include common.mk -CC = gcc +memzap: $(OBJ) memzap.c + @echo -e " LD\t$@" + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $> -INCS = -I/usr/local/include -LIBS = -L/usr/local/lib +mdiffdump: $(OBJ) mdiffdump.c + @echo -e " LD\t$@" + @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $> -CFLAGS += -g -O3 -Wall -Wextra -Wunused -DVERSION=\"${VER}\" ${INCS} -LDFLAGS += - -${BIN}: ${OBJ} ${TERMBOX_OBJ} - ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJ} ${TERMBOX_OBJ} - -termbox/%.o: termbox/%.c $(wildcard termbox/*.h) - ${CC} ${CFLAGS} -Itermbox -c -o $@ $< - -%.o: %.c - ${CC} ${CFLAGS} -c -o $@ $< - -clean: - rm -rf ${BIN} ${OBJ} ${TERMBOX_OBJ} - -all: memzap - -install: - cp -f ${BIN} ${PREFIX}/bin - chmod 755 ${PREFIX}/bin/${BIN} - -uninstall: - rm -f ${PREFIX}/bin/${BIN} - -.PHONY: all clean install uninstall +.c.o: + @echo -e " CC\t$@" + @$(CC) $(CFLAGS) -c -o $@ $< diff --git a/common.mk b/common.mk @@ -0,0 +1,14 @@ +all: memzap mdiffdump + +clean: + rm -rf memzap mdiffdump $(OBJ) + +install: all + @mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BIN) + +uninstall: + rm -f $(PREFIX)/bin/$(BIN) + +.PHONY: all clean install uninstall diff --git a/commonvar.mk b/commonvar.mk @@ -0,0 +1,20 @@ +VER = 0.1 +PREFIX ?= /usr/local +CC := $(CROSS_COMPILE)$(CC) + +CFLAGS += -g -O3 -Wall -Wextra -Wunused -DVERSION=\"$(VER)\" $(INCS) +LDFLAGS += + +INCS = -I/usr/local/include +LIBS = -L/usr/local/lib + +SRC = mem.c \ + utils.c \ + md5.c \ + mdiff.c \ + termbox/input.c \ + termbox/ringbuffer.c \ + termbox/termbox.c \ + termbox/memstream.c \ + termbox/term.c \ + termbox/utf8.c