mg

port of mg editor (openbsd to linux)
Log | Files | Refs | README

commit d97334e4ba525b3a3694f0f31cd422a6e285fc5c
parent 68738b27fcfc28354c2e0cdfdaac3cbab501537d
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 24 Nov 2014 22:56:57 +0100

update Makefile (suckless-style)

Diffstat:
Makefile | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
config.mk | 22++++++++++++++++++++++
2 files changed, 131 insertions(+), 41 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,52 +1,119 @@ -# $OpenBSD: Makefile,v 1.28 2013/05/31 18:03:43 lum Exp $ +include config.mk -PROG= mg +.SUFFIXES: +.SUFFIXES: .o .c -#LDADD+= -lcurses -lutil -#DPADD+= ${LIBCURSES} ${LIBUTIL} +HDR =\ + chrdef.h\ + def.h\ + funmap.h\ + kbd.h\ + key.h\ + macro.h\ + pathnames.h\ + sysdef.h\ + ttydef.h -# (Common) compile-time options: -# -# FKEYS -- add support for function key sequences. -# REGEX -- create regular expression functions. -# STARTUP -- look for and handle initialization file. -# XKEYS -- use termcap function key definitions. -# note: XKEYS and bsmap mode do _not_ get along. -# -CFLAGS+=-Wall -DFKEYS -DREGEX -DXKEYS +LIBUTIL = libutil.a +LIBUTILSRC =\ + libutil/fparseln.c -SRCS= autoexec.c basic.c bell.c buffer.c cinfo.c dir.c display.c \ - echo.c extend.c file.c fileio.c funmap.c help.c kbd.c keymap.c \ - line.c macro.c main.c match.c modes.c paragraph.c random.c \ - re_search.c region.c search.c spawn.c tty.c ttyio.c ttykbd.c \ - undo.c version.c window.c word.c yank.c +LIBOPENBSD = libopenbsd.a +LIBOPENBSDSRC =\ + libopenbsd/arc4random.c\ + libopenbsd/reallocarray.c\ + libopenbsd/strlcat.c\ + libopenbsd/strlcpy.c\ + libopenbsd/strtonum.c -# -# More or less standalone extensions. -# -SRCS+= cmode.c cscope.c dired.c grep.c tags.c theo.c +LIB = $(LIBOPENBSD) $(LIBUTIL) -CFLAGS += -DDEFFILEMODE=0666 -D__dead="" -I. -Iinclude -Ilibutil -CFLAGS += -Os -LDFLAGS += -lcurses -Llibopenbsd -lopenbsd -Llibutil -lutil -LDFLAGS += -s -static +BIN = mg +LIBOPENBSDOBJ = $(LIBOPENBSDSRC:.c=.o) +LIBUTILOBJ = $(LIBUTILSRC:.c=.o) +SRC = \ + autoexec.c\ + basic.c\ + bell.c\ + buffer.c\ + cinfo.c\ + cmode.c\ + cscope.c\ + dir.c\ + dired.c\ + display.c\ + echo.c\ + extend.c\ + file.c\ + fileio.c\ + funmap.c\ + grep.c\ + help.c\ + kbd.c\ + keymap.c\ + line.c\ + macro.c\ + main.c\ + match.c\ + modes.c\ + paragraph.c\ + random.c\ + re_search.c\ + region.c\ + search.c\ + spawn.c\ + tags.c\ + theo.c\ + tty.c\ + ttyio.c\ + ttykbd.c\ + undo.c\ + version.c\ + window.c\ + word.c\ + yank.c -build: openbsd util clean - cc -c ${SRCS} ${CFLAGS} - cc -o ${PROG} *.o ${LDFLAGS} +OBJ=${SRC:.c=.o} \ + $(LIBOPENBSDOBJ) $(LIBUTILOBJ) -openbsd: - make -C libopenbsd +MAN = mg.1 -util: - make -C libutil +all: $(BIN) + +$(OBJ): $(HDR) config.mk + +.o: + $(LD) $(LDFLAGS) -o $@ $< $(LIB) + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< + +mg: $(LIB) ${OBJ} + @echo CC -o $@ + @${CC} -o $@ ${OBJ} ${LDFLAGS} + +$(LIBOPENBSD): $(LIBOPENBSDOBJ) + $(AR) -r -c $@ $? + $(RANLIB) $@ + +$(LIBUTIL): $(LIBUTILOBJ) + $(AR) -r -c $@ $? + $(RANLIB) $@ + +install: all + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin + cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN) + mkdir -p $(DESTDIR)$(MANPREFIX)/man1 + for m in $(MAN); do cp -f "$$m" $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done + cd $(DESTDIR)$(MANPREFIX)/man1 && chmod 644 $(MAN) + +uninstall: + cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN) + cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN) clean: - rm -f mg *.o libutil/*.o libopenbsd/*.o *.a - -#afterinstall: -# ${INSTALL} -d ${DESTDIR}${DOCDIR}/mg -# ${INSTALL} -m ${DOCMODE} -c ${.CURDIR}/tutorial \ -# ${DESTDIR}${DOCDIR}/mg -# -#.include <bsd.prog.mk> + rm -f $(BIN) $(OBJ) $(LIBUTFOBJ) $(LIBUTIL) $(LIB) mg + +.PHONY: + all install uninstall clean+ \ No newline at end of file diff --git a/config.mk b/config.mk @@ -0,0 +1,22 @@ +# (Common) compile-time options: +# +# FKEYS -- add support for function key sequences. +# REGEX -- create regular expression functions. +# STARTUP -- look for and handle initialization file. +# XKEYS -- use termcap function key definitions. +# note: XKEYS and bsmap mode do _not_ get along. + +# paths +PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man + +CC = cc +LD = $(CC) +AR = ar +RANLIB = ranlib + +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 +CFLAGS = -Os -std=c99 -Wall -pedantic \ + -DDEFFILEMODE=0666 -D__dead="" -I. -Iinclude -Ilibutil \ + -DFKEYS -DREGEX -DXKEYS +LDFLAGS = -s -static -lcurses -Llibopenbsd -lopenbsd -Llibutil -lutil