From f5a3ab03375c86e7168c56a5e9e959612fdbe7f4 Mon Sep 17 00:00:00 2001 From: katherine Date: Mon, 27 May 2019 16:32:04 -0700 Subject: use posix makefile --- Makefile | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 89 --------------------------------------------------------------- 2 files changed, 76 insertions(+), 89 deletions(-) create mode 100644 Makefile delete mode 100755 configure diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3facdac --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +.POSIX: +.SUFFIXES: + +CC = cc +CFLAGS = -Wall -O2 +CFLAGSDEBUG = -std=c99 -Wall -pedantic -ggdb3 -O0 -DDEBUG +PREFIX = /usr/local + +all: confconf + +debug: dbg_confconf + +install: all + mkdir -p $(DESTDIR)$(PREFIX)/bin + mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 + cp -f confconf $(DESTDIR)$(PREFIX)/bin + gzip < confconf.1 > $(DESTDIR)$(PREFIX)/share/man/man1/confconf.1.gz + +confconf: build/release build/release/opt.o build/release/tok.o build/release/main.o build/release/analyse.o build/release/parse.o build/release/gen.o + $(CC) $(LDFLAGS) -o confconf build/release/opt.o build/release/tok.o build/release/main.o build/release/analyse.o build/release/parse.o build/release/gen.o $(LDLIBS) + +dbg_confconf: build/debug build/debug/opt.o build/debug/tok.o build/debug/main.o build/debug/analyse.o build/debug/parse.o build/debug/gen.o + $(CC) $(LDFLAGS) -o dbg_confconf build/debug/opt.o build/debug/tok.o build/debug/main.o build/debug/analyse.o build/debug/parse.o build/debug/gen.o $(LDLIBS) + +build/release: + mkdir -p build/release + +build/debug: + mkdir -p build/debug + +src/version.h: + printf "%s\n%s\n\n%s%s%s\n\n%s\n" \ + "#ifndef CONFCONF_VERSION_H" \ + "#define CONFCONF_VERSION_H" \ + "#define VERSION \"confconf-" "`git describe --always --tags`" "\"" \ + "#endif" > src/version.h + +build/release/opt.o: src/opt.c src/version.h src/opt.h \ + src/../reqs/simple-opt/simple-opt.h + $(CC) -c $(CFLAGS) -o build/release/opt.o src/opt.c +build/release/tok.o: src/tok.c src/tok.h + $(CC) -c $(CFLAGS) -o build/release/tok.o src/tok.c +build/release/main.o: src/main.c src/err.h src/opt.h src/parse.h \ + src/tok.h src/analyse.h src/gen.h + $(CC) -c $(CFLAGS) -o build/release/main.o src/main.c +build/release/analyse.o: src/analyse.c src/err.h src/analyse.h src/tok.h \ + src/parse.h + $(CC) -c $(CFLAGS) -o build/release/analyse.o src/analyse.c +build/release/parse.o: src/parse.c src/parse.h src/tok.h src/err.h + $(CC) -c $(CFLAGS) -o build/release/parse.o src/parse.c +build/release/gen.o: src/gen.c src/gen.h src/parse.h src/tok.h \ + src/analyse.h src/version.h src/gen-consts.h + $(CC) -c $(CFLAGS) -o build/release/gen.o src/gen.c + +build/debug/opt.o: src/opt.c src/version.h src/opt.h \ + src/../reqs/simple-opt/simple-opt.h + $(CC) -c $(CFLAGSDEBUG) -o build/debug/opt.o src/opt.c +build/debug/tok.o: src/tok.c src/tok.h + $(CC) -c $(CFLAGSDEBUG) -o build/debug/tok.o src/tok.c +build/debug/main.o: src/main.c src/err.h src/opt.h src/parse.h src/tok.h \ + src/analyse.h src/gen.h + $(CC) -c $(CFLAGSDEBUG) -o build/debug/main.o src/main.c +build/debug/analyse.o: src/analyse.c src/err.h src/analyse.h src/tok.h \ + src/parse.h + $(CC) -c $(CFLAGSDEBUG) -o build/debug/analyse.o src/analyse.c +build/debug/parse.o: src/parse.c src/parse.h src/tok.h src/err.h + $(CC) -c $(CFLAGSDEBUG) -o build/debug/parse.o src/parse.c +build/debug/gen.o: src/gen.c src/gen.h src/parse.h src/tok.h \ + src/analyse.h src/version.h src/gen-consts.h + $(CC) -c $(CFLAGSDEBUG) -o build/debug/gen.o src/gen.c + +clean: + rm -f src/version.h + rm -f confconf + rm -f dbg_confconf + rm -rf build diff --git a/configure b/configure deleted file mode 100755 index 467c469..0000000 --- a/configure +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh - -# kinda brittle, this, but mostly works -# just don't use names with whitespaces - -target='confconf' -srcdir='src' -sources=`find $srcdir -type f -name '*.c' | sed -e "s/$srcdir\/\(.*\).c/\1.c/"` -objdir='build' -objects=`find $srcdir -type f -name '*.c' | sed -e "s/$srcdir\/\(.*\).c/\1.o/"` - -cc='cc' -cflags='-Wall -O2' -cflagsdebug='-std=c99 -Wall -pedantic -ggdb3 -O0 -DDEBUG' -prefix='/usr/local' - - - -rls_objects=`printf %s "$objects" | sed -e "s/^/$objdir\/release\//" | tr '\n' ' '` -dbg_objects=`printf %s "$objects" | sed -e "s/^/$objdir\/debug\//" | tr '\n' ' '` - -dgen='gcc' -if [ ! `2>/dev/null which gcc` ]; then - if [ ! `2>/dev/null which clang` ]; then - echo 'err: could not find a suitable ' \ - 'compiler for calculating dependencies' - return 1 - fi - dgen='clang' -fi - -if [ -f 'Makefile' ]; then - make clean -fi - -{ - printf %s\\n '.POSIX:' - printf %s\\n '.SUFFIXES:' - printf %s\\n '' - printf %s\\n "CC = $cc" - printf %s\\n "CFLAGS = $cflags" - printf %s\\n "CFLAGSDEBUG = $cflagsdebug" - printf %s\\n "PREFIX = $prefix" - printf %s\\n '' - printf %s\\n "all: $target" - printf %s\\n '' - printf %s\\n "debug: dbg_$target" - printf %s\\n '' - printf %s\\n "install: all" - printf %s\\n ' mkdir -p $(DESTDIR)$(PREFIX)/bin' - printf %s\\n ' mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1' - printf %s\\n " cp -f $target \$(DESTDIR)\$(PREFIX)/bin" - printf %s\\n " gzip < ${target}.1 > \$(DESTDIR)\$(PREFIX)/share/man/man1/${target}.1.gz" - printf %s\\n '' - printf %s\\n "$target: ${objdir}/release $rls_objects" - printf %s\\n " \$(CC) \$(LDFLAGS) -o $target $rls_objects \$(LDLIBS)" - printf %s\\n '' - printf %s\\n "dbg_$target: ${objdir}/debug $dbg_objects" - printf %s\\n " \$(CC) \$(LDFLAGS) -o dbg_$target $dbg_objects \$(LDLIBS)" - printf %s\\n '' - printf %s\\n "${objdir}/release:" - printf %s\\n " mkdir -p ${objdir}/release" - printf %s\\n '' - printf %s\\n "${objdir}/debug:" - printf %s\\n " mkdir -p ${objdir}/debug" - printf %s\\n '' - printf %s\\n 'src/version.h:' - printf %s\\n ' printf "%s\n%s\n\n%s%s%s\n\n%s\n" \' - printf %s\\n ' "#ifndef CONFCONF_VERSION_H" \' - printf %s\\n ' "#define CONFCONF_VERSION_H" \' - printf %s\\n ' "#define VERSION \"confconf-" "`git describe --always --tags`" "\"" \' - printf %s\\n ' "#endif" > src/version.h' - printf %s\\n '' - printf %s\\n "$sources" | (while IFS= read -r s; do - $dgen $CFLAGS -MM -MG -MT ${objdir}/release/`printf %s $s | sed -e 's/\.c$/\.o/'` "$srcdir/$s" | sed -e "s/version.h/$srcdir\/version.h/" - printf %s\\n " \$(CC) -c \$(CFLAGS) -o ${objdir}/release/`printf %s $s | sed -e 's/\.c$/\.o/'` ${srcdir}/$s" - done) - printf %s\\n '' - printf %s\\n "$sources" | (while IFS= read -r s; do - $dgen $CFLAGS -MM -MG -MT ${objdir}/debug/`printf %s $s | sed -e 's/\.c$/\.o/'` "$srcdir/$s" | sed -e "s/version.h/$srcdir\/version.h/" - printf %s\\n " \$(CC) -c \$(CFLAGSDEBUG) -o ${objdir}/debug/`printf %s $s | sed -e 's/\.c$/\.o/'` ${srcdir}/$s" - done) - printf %s\\n '' - printf %s\\n 'clean:' - printf %s\\n ' rm -f src/version.h' - printf %s\\n " rm -f $target" - printf %s\\n " rm -f dbg_$target" - printf %s\\n " rm -rf $objdir" -} > Makefile -- cgit v1.2.3