From fd29f21e3d455efda90605a1c46b2b42baf54cca Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 15 Mar 2014 12:53:19 -0700 Subject: makefile improvements --- .gitignore | 1 + Makefile | 85 +++++++++++++++++++++++++++++++------------------------------- config.mk | 28 --------------------- st.c | 1 + 4 files changed, 45 insertions(+), 70 deletions(-) delete mode 100644 config.mk diff --git a/.gitignore b/.gitignore index c1a4952..c52de49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .* *.o +*.d *~ st diff --git a/Makefile b/Makefile index e1f9647..fefd863 100644 --- a/Makefile +++ b/Makefile @@ -1,60 +1,61 @@ # st - simple terminal # See LICENSE file for copyright and license details. -include config.mk +# st version +VERSION = 0.3 -SRC = st.c term.c -OBJ = ${SRC:.c=.o} +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib -all: options st +CFLAGS := -g -std=gnu99 -O2 -Wall -Wextra -Werror \ + -Wno-sign-compare \ + -Wno-unused-parameter +CPPFLAGS := -DVERSION=\"${VERSION}\" \ + -D_BSD_SOURCE -D_XOPEN_SOURCE=600 \ + -I. -I/usr/include -I${X11INC} \ + $(shell pkg-config --cflags fontconfig) \ + $(shell pkg-config --cflags freetype2) +LDFLAGS := -g -L/usr/lib -L$(X11LIB) +LDLIBS := -lm -lc -lX11 -lutil -lXft \ + $(shell pkg-config --libs fontconfig) \ + $(shell pkg-config --libs freetype2) -options: - @echo st build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" +all: st -config.h: - cp config.def.h config.h +OBJS = st.o term.o +DEP_FILES := $(wildcard *.d) -.c.o: - @echo CC $< - @${CC} -c ${CFLAGS} $< +ifneq ($(DEP_FILES),) + -include $(DEP_FILES) +endif -${OBJ}: config.h config.mk +st: $(OBJS) -st: ${OBJ} - @echo CC -o $@ - @${CC} -o $@ ${OBJ} ${LDFLAGS} +%.o %.d: %.c + $(CC) $(CPPFLAGS) $(CFLAGS) -MD -MP -MF $*.d -c $< -o $*.o -clean: - @echo cleaning - @rm -f st ${OBJ} st-${VERSION}.tar.gz +config.h: + cp config.def.h config.h -dist: clean - @echo creating dist tarball - @mkdir -p st-${VERSION} - @cp -R LICENSE Makefile README config.mk config.def.h st.info st.1 ${SRC} st-${VERSION} - @tar -cf st-${VERSION}.tar st-${VERSION} - @gzip st-${VERSION}.tar - @rm -rf st-${VERSION} +clean: + $(RM) st $(OBJS) $(DEP_FILES) install: all @echo installing executable file to ${DESTDIR}${PREFIX}/bin - @mkdir -p ${DESTDIR}${PREFIX}/bin - @cp -f st ${DESTDIR}${PREFIX}/bin - @chmod 755 ${DESTDIR}${PREFIX}/bin/st - @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 - @mkdir -p ${DESTDIR}${MANPREFIX}/man1 - @sed "s/VERSION/${VERSION}/g" < st.1 > ${DESTDIR}${MANPREFIX}/man1/st.1 - @chmod 644 ${DESTDIR}${MANPREFIX}/man1/st.1 - @echo Please see the README file regarding the terminfo entry of st. - @tic -s st.info + mkdir -p ${DESTDIR}${PREFIX}/bin + cp -f st ${DESTDIR}${PREFIX}/bin + chmod 755 ${DESTDIR}${PREFIX}/bin/st + echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 + mkdir -p ${DESTDIR}${MANPREFIX}/man1 + sed "s/VERSION/${VERSION}/g" < st.1 > ${DESTDIR}${MANPREFIX}/man1/st.1 + chmod 644 ${DESTDIR}${MANPREFIX}/man1/st.1 + echo Please see the README file regarding the terminfo entry of st. + tic -s st.info uninstall: - @echo removing executable file from ${DESTDIR}${PREFIX}/bin - @rm -f ${DESTDIR}${PREFIX}/bin/st - @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 - @rm -f ${DESTDIR}${MANPREFIX}/man1/st.1 + $(RM) ${DESTDIR}${PREFIX}/bin/st + $(RM) ${DESTDIR}${MANPREFIX}/man1/st.1 -.PHONY: all options clean dist install uninstall +.PHONY: clean install uninstall diff --git a/config.mk b/config.mk deleted file mode 100644 index 6b74046..0000000 --- a/config.mk +++ /dev/null @@ -1,28 +0,0 @@ -# st version -VERSION = 0.3 - -# Customize below to fit your system - -# paths -PREFIX = /usr/local -MANPREFIX = ${PREFIX}/share/man - -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib - -# includes and libs -INCS = -I. -I/usr/include -I${X11INC} \ - $(shell pkg-config --cflags fontconfig) \ - $(shell pkg-config --cflags freetype2) -LIBS = -L/usr/lib -lm -lc -L${X11LIB} -lX11 -lutil -lXft \ - $(shell pkg-config --libs fontconfig) \ - $(shell pkg-config --libs freetype2) - -# flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_XOPEN_SOURCE=600 -CFLAGS += -g -std=gnu99 -Wall -Os ${INCS} ${CPPFLAGS} -LDFLAGS += -g ${LIBS} - -# compiler and linker -CC ?= cc - diff --git a/st.c b/st.c index 6e365f4..0b4adcc 100644 --- a/st.c +++ b/st.c @@ -1075,6 +1075,7 @@ static void xunloadfonts(struct st_window *xw) FcFontSetDestroy(xw->ibfont.set); } +__attribute((unused)) static void xzoom(struct st_window *xw, const union st_arg *arg) { xw->fontzoom = clamp(xw->fontzoom + arg->i, -8, 8); -- cgit v1.2.3