Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 72 lines (60 sloc) 2.457 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
.PHONY: all clean mrproper prepare_bootstrap bootstrap
PARSER_GEN=greg
NQ_PATH=source/rock/frontend/NagaQueen.c
DATE=$(shell date +%Y-%m-%d)
TIME=$(shell date +%H:%M)
OOC_OWN_FLAGS=-sourcepath=source -driver=sequence -noclean -g -v -shout +-w

PREFIX?=/usr
MAN_INSTALL_PATH?=/usr/local/man/man1
BIN_INSTALL_PATH?=${PREFIX}/bin

ifdef WINDIR
OOC_OWN_FLAGS+=+-DROCK_BUILD_DATE=\\\"${DATE}\\\" +-DROCK_BUILD_TIME=\\\"${TIME}\\\"
else
OOC_OWN_FLAGS+=+-DROCK_BUILD_DATE=\"${DATE}\" +-DROCK_BUILD_TIME=\"${TIME}\"
endif

OOC?=rock
OOC_CMD=${OOC} ${OOC_OWN_FLAGS} ${OOC_FLAGS}

all: bootstrap

# Regenerate NagaQueen.c from the greg grammar
# you need ../nagaqueen and greg to be in your path
#
# http://github.com/nddrylliog/nagaqueen
# http://github.com/nddrylliog/greg
grammar:
${PARSER_GEN} ../nagaqueen/grammar/nagaqueen.leg > source/rock/frontend/NagaQueen.c

# Prepares the build/ directory, used for bootstrapping
# The build/ directory contains all the C sources needed to build rock
# and a nice Makefile, too
prepare_bootstrap:
@echo "Preparing boostrap (in build/ directory)"
rm -rf build/
${OOC} -driver=make -sourcepath=source -outpath=c-source rock/rock -o=../bin/c_rock c-source/${NQ_PATH} -v -g +-w
sed s/-w.*/-w\ -DROCK_BUILD_DATE=\\\"\\\\\"bootstrapped\\\\\"\\\"\ -DROCK_BUILD_TIME=\\\"\\\\\"\\\\\"\\\"/ -i build/Makefile
cp ${NQ_PATH} build/c-source/${NQ_PATH}
@echo "Done!"

# For c-source based rock releases, 'make bootstrap' will compile a version
# of rock from the C sources in build/, then use that version to re-compile itself
bootstrap:
@echo "Compiling from C source"
cd build/ && ROCK_DIST=.. make
@echo "Now re-compiling ourself"
OOC=bin/c_rock ROCK_DIST=. make self
@echo "Congrats! you have a boostrapped version of rock in bin/rock now. Have fun!"

# Copy the manpage and create a symlink to the binary
install:
cp -f docs/rock.1 ${MAN_INSTALL_PATH}/
ln -s $(shell pwd)/bin/rock* ${BIN_INSTALL_PATH}/

# Regenerate the man page from docs/rock.1.txt You need ascidoc for that
man:
cd docs/ && a2x -f manpage rock.1.txt

# Compile a clean rock with itself
self:
make clean noclean

# For rock developers - recompile without cleaning, for small changes
# that don't trigger the fragile base class problem.
# - http://en.wikipedia.org/wiki/Fragile_base_class
# This should be fixed by caching the class hierarchy with the json backend
noclean:
${OOC_CMD} rock/rock -o=bin/rock ${NQ_PATH}

clean:
rm -rf *_tmp/
Something went wrong with that request. Please try again.