Created
April 10, 2018 22:11
-
-
Save rain-1/bd0d745c3bd0c4a643a49b74a8c5eb4a to your computer and use it in GitHub Desktop.
example makesfile to build jq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -x | |
function clean { | |
rm -f src/version.h | |
rm -f src/builtin.inc | |
rm -f src/*.o | |
rm -f jq | |
} | |
function all { | |
# Remake the version.h header file if, and only if, the git ID has changed | |
#.PHONY: .FORCE | |
#.FORCE: | |
#generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | sed 's/.*/\#define JQ_VERSION \"&\"/'`" | |
#.remake-version-h: .FORCE | |
# @ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h | |
#src/version.h: .remake-version-h | |
# $(AM_V_GEN) $(generate_ver); echo "$$ver" > $@ | |
#src/main.c: src/version.h | |
makes src/version.h && | |
( ./scripts/version | sed 's/.*/\#define JQ_VERSION \"&\"/' > src/version.h ) | |
#src/builtin.inc: src/builtin.jq | |
# $(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $^ > $@ | |
#src/builtin.o: src/builtin.inc | |
makes src/builtin.inc \ | |
src/builtin.jq && | |
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$/\\n"/' src/builtin.jq > src/builtin.inc | |
#BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \ | |
# src/builtin.inc src/version.h | |
#src/lexer.c: src/lexer.l | |
# $(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $< | |
#src/lexer.h: src/lexer.c | |
makes src/lexer.c \ | |
src/lexer.l && | |
flex -o src/lexer.c --header-file=src/lexer.h src/lexer.l | |
makes src/lexer.h \ | |
src/lexer.c && | |
flex -o src/lexer.c --header-file=src/lexer.h src/lexer.l | |
#AC_C_BIGENDIAN( | |
# AC_DEFINE([IEEE_MC68k], 1, [machine is bigendian]), | |
# AC_DEFINE([IEEE_8087], 1, [machine is littleendian]), | |
# AC_MSG_ERROR(unknown endianess), | |
# AC_MSG_ERROR(universial endianess not supported) | |
#) | |
CFLAGS+="-DIEEE_8087=1" | |
find src/ -iname '*.c' -print0 | \ | |
while IFS="" read -r -d "" file ; do | |
echo processing "$file" ; | |
makes "${file%.c}.o" \ | |
"$file" src/version.h src/builtin.inc && | |
gcc -c -o "${file%.c}.o" $CFLAGS -I . "$file" || exit | |
true | |
done | |
OBJECTS=" \ | |
./src/jv_print.o \ | |
./src/jv_unicode.o \ | |
./src/jv_aux.o \ | |
./src/jv_alloc.o \ | |
./src/jv_file.o \ | |
./src/jv_dtoa.o \ | |
./src/jq_test.o \ | |
./src/jv_parse.o \ | |
./src/parser.o \ | |
./src/main.o \ | |
./src/bytecode.o \ | |
./src/builtin.o \ | |
./src/inject_errors.o \ | |
./src/lexer.o \ | |
./src/util.o \ | |
./src/locfile.o \ | |
./src/linker.o \ | |
./src/jv.o \ | |
./src/execute.o \ | |
./src/compile.o \ | |
" | |
makes jq \ | |
$OBJECTS && | |
gcc -o jq -lm -ldl $OBJECTS | |
} | |
TARGET="${1:-all}" | |
case $TARGET in | |
clean*) | |
clean | |
;; | |
all*) | |
all | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment