Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Makefile, by default install binary as runawklite

  • Loading branch information...
commit e9a6671fc95543624cdae3f99da1c79b346d7ef4 1 parent 9b625cb
@dubiousjim authored
Showing with 53 additions and 14 deletions.
  1. +47 −0 Makefile
  2. +6 −14 README
View
47 Makefile
@@ -0,0 +1,47 @@
+PREFIX= /usr
+AWK= /usr/bin/awk
+RUNAWK= runawklite
+
+WARNINGS= -Wall -Wextra -std=c99 -pedantic \
+ -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-overflow=4 \
+ -Waggregate-return -Wbad-function-cast \
+ -Wswitch-default -Wswitch-enum \
+ -Wwrite-strings -Wformat=2 \
+ -Wshadow -Wuninitialized -Winit-self \
+ -Wstrict-prototypes -Wold-style-definition \
+ -Werror-implicit-function-declaration \
+ -Wredundant-decls \
+ -Wnested-externs \
+ -Wundef -Wmissing-include-dirs \
+ -Wno-unused-function
+
+ifdef STRICT
+WARNINGS+= -Wconversion -Wmissing-prototypes -Wmissing-declarations \
+ -Wunreachable-code -Wunused-function -Wfloat-equal
+endif
+
+CFLAGS= -O ${WARNINGS} ${CPPFLAGS}
+
+all: runawk
+
+runawk:
+ifeq (${AWK},/bin/busybox)
+ ${CC} -o runawk -D'AWK="${AWK}"' -D'AWK2="awk"' ${CFLAGS} runawk.c
+else
+ ${CC} -o runawk -D'AWK="${AWK}"' ${CFLAGS} runawk.c
+endif
+
+install: all
+ install -d -m755 "${DESTDIR}${PREFIX}/bin"
+ install -d -m755 "${DESTDIR}${PREFIX}/share/awkenough/utils"
+ install -m755 runawk "${DESTDIR}${PREFIX}/bin/${RUNAWK}"
+ install -m644 library.awk "${DESTDIR}${PREFIX}/share/awkenough/library.awk"
+ cd utils && for f in *; do \
+ sed -e "1 s@#!/[a-z/]*/runawk -f /[a-z/]*/library.awk@#!${PREFIX}/bin/${RUNAWK} -f ${PREFIX}/share/awkenough/library.awk@" "$$f" > "../$$f.new"; \
+ install -m644 "../$$f.new" "${DESTDIR}${PREFIX}/share/awkenough/utils/$$f"; \
+ if [ ! -e "${PREFIX}/bin/$$f" ]; then ln -s "${PREFIX}/share/awkenough/utils/$$f" "${DESTDIR}${PREFIX}/bin/$$f"; fi; \
+ done
+
+clean:
+ rm -f *.new runawk
+
View
20 README
@@ -11,21 +11,13 @@ This package includes:
Installation
============
-PREFIX=/usr
-cc -Wall -o runawk runawk.c
-install -D -m644 runawk $PREFIX/bin/runawk
-install -D -m644 library.awk $PREFIX/share/awkenough/library.awk
-install -d -m755 $PREFIX/share/awkenough/utils
-for f in utils/*; do
- sed "1s@#!/[a-z/]+/runawk -f /[a-z/]+/library.awk@#!${PREFIX}/bin/runawk -f ${PREFIX}/share/awkenough/library.awk@" $f > $f.new
- install -D -m644 $f.new $PREFIX/share/awkenough/$f
- [ ! -e $PREFIX/bin/${f#utils/} ] && \
- ln -s $PREFIX/share/awkenough/$f $PREFIX/bin/${f#utils/}
-done
+1. gmake AWK=/usr/bin/awk
+2. sudo gmake PREFIX=/usr DESTDIR=/ install
-By default, runawk will invoke whatever binary is present or linked from /usr/bin/awk. You can also configure it differently; for example, this will build a runawk that always invokes BusyBox awk, even if another awk is linked from /usr/bin/awk:
+The displayed values for the make variables are the defaults, and can be omitted if you're happy with those values.
+
+AWK can also be set to /bin/busybox; in that case, the runawk binary will invoke busybox with an "awk" argument. This permits building runawk so that it always invokes BusyBox awk, even if another awk is linked from /usr/bin/awk.
-cc -Wall -o runawk -D'AWK="/bin/busybox"' -D'AWK2="awk"' runawk.c
Runawk
@@ -128,7 +120,7 @@ but can't be invoked like this:
That is, the -f option can't be mixed with providing an awk script directly on the command line, rather than in a separate file. Gawk and runawk's -e option provide a way to do this:
- awk -f library.awk -e '...awk script...' argv1 ...
+ runawk -f library.awk -e '...awk script...' argv1 ...
Runawk also knows how to handle gawk's --exec option. See the source for details.
Please sign in to comment.
Something went wrong with that request. Please try again.