From b0d90af320cc4e0cb599adc2c537e396b0728cfd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 15 Sep 2021 14:06:01 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- base/new-c-proj | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- emacs/init.el | 1 + 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/base/new-c-proj b/base/new-c-proj index be109ae..0d5459c 100755 --- a/base/new-c-proj +++ b/base/new-c-proj @@ -43,6 +43,8 @@ cat > .gitignore <> .git/info/exclude if printf '%s\n' "$1" | grep '^lib' >/dev/null 2>/dev/null; then UPPERCASE="$(printf '%s\n' "$1" | tr '[a-z-]' '[A-Z_]')" + LIBNAME="$(printf '%s\n' "$1" | sed 's/^lib//')" printf '%s\n' >> "$1".h \ '/* See LICENSE file for copyright and license details. */' \ @@ -61,19 +64,38 @@ if printf '%s\n' "$1" | grep '^lib' >/dev/null 2>/dev/null; then '' \ '#endif' + mkdir -p -- mk + cat <<-EOF | sed 's/x\t/\t/g' > Makefile .POSIX: CONFIGFILE = config.mk include \$(CONFIGFILE) + OS = linux + # Linux: linux + # Mac OS: macos + # Windows: windows + include mk/\$(OS).mk + + + LIB_MAJOR = 1 + LIB_MINOR = 0 + LIB_VERSION = \$(LIB_MAJOR).\$(LIB_MINOR) + LIB_NAME = \${LIBNAME} + + OBJ = HDR =\\ x $1.h - all: $1.a + LOBJ = \$(OBJ:.o=.lo) + + + all: $1.a $1.\$(LIBEXT) \$(OBJ): \$(HDR) + \$(LOBJ): \$(HDR) .c.o: x \$(CC) -c -o \$@ \$< \$(CFLAGS) \$(CPPFLAGS) @@ -85,24 +107,55 @@ if printf '%s\n' "$1" | grep '^lib' >/dev/null 2>/dev/null; then x @rm -f -- \$@ x \$(AR) rc \$@ \$(OBJ) - install: $1.a + $1.\$(LIBEXT): \$(LOBJ) + x \$(CC) \$(LIBFLAGS) -o $@ \$(LOBJ) \$(LDFLAGS) + + install: $1.a $1.\$(LIBEXT) x mkdir -p -- "\$(DESTDIR)\$(PREFIX)/lib" x mkdir -p -- "\$(DESTDIR)\$(PREFIX)/include" x cp -- $1.a "\$(DESTDIR)\$(PREFIX)/lib/" + x cp -- $1.\$(LIBEXT) "\$(DESTDIR)\$(PREFIX)/lib/$1.\$(LIBMINOREXT)" + x ln -sf -- $1.\$(LIBMINOREXT) "\$(DESTDIR)\$(PREFIX)/lib/$1.\$(LIBMAJOREXT)" + x ln -sf -- $1.\$(LIBMAJOREXT) "\$(DESTDIR)\$(PREFIX)/lib/$1.\$(LIBEXT)" x cp -- $1.h "\$(DESTDIR)\$(PREFIX)/include/" uninstall: x -rm -f -- "\$(DESTDIR)\$(PREFIX)/lib/$1.a" + x -rm -f -- "\$(DESTDIR)\$(PREFIX)/lib/$1.\$(LIBMAJOREXT)" + x -rm -f -- "\$(DESTDIR)\$(PREFIX)/lib/$1.\$(LIBMINOREXT)" + x -rm -f -- "\$(DESTDIR)\$(PREFIX)/lib/$1.\$(LIBEXT)" x -rm -f -- "\$(DESTDIR)\$(PREFIX)/include/$1.h" clean: - x -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda + x -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.dll *.dylib + x -rm -f -- *.gch *.gcov *.gcno *.gcda *.\$(LIBEXT) .SUFFIXES: .SUFFIXES: .lo .o .c .PHONY: all install uninstall clean EOF + + cat <<-EOF | sed 's/x\t/\t/g' > mk/linux.mk + LIBEXT = so + LIBFLAGS = -shared -Wl,-soname,lib\$(LIB_NAME).\$(LIBEXT).\$(LIB_MAJOR) + LIBMAJOREXT = \$(LIBEXT).\$(LIB_MAJOR) + LIBMINOREXT = \$(LIBEXT).\$(LIB_VERSION) + EOF + + cat <<-EOF | sed 's/x\t/\t/g' > mk/macos.mk + LIBEXT = dylib + LIBFLAGS = -dynamiclib + LIBMAJOREXT = \$(LIB_MAJOR).\$(LIBEXT) + LIBMINOREXT = \$(LIB_VERSION).\$(LIBEXT) + EOF + + cat <<-EOF | sed 's/x\t/\t/g' > mk/windows.mk + LIBEXT = dll + LIBFLAGS = -mdll + LIBMAJOREXT = \$(LIB_MAJOR).\$(LIBEXT) + LIBMINOREXT = \$(LIB_VERSION).\$(LIBEXT) + EOF else printf '%s\n' "/$1" >> .gitignore diff --git a/emacs/init.el b/emacs/init.el index 1a98a14..6ef9006 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -44,3 +44,4 @@ (add-to-list 'auto-mode-alist '("/PKGBUILD$" . shell-script-mode)) (add-to-list 'auto-mode-alist '("/APKBUILD$" . shell-script-mode)) +(setq auto-mode-alist (cons '("\.cl$" . c-mode) auto-mode-alist)) -- cgit v1.2.3-70-g09d2