So what have I been up to lately?
Converting all of my projects to NFO. Yeap. I’m making the migration to pure NFO. Although, with a twist.
It suddenly struck me as I was commenting the gigantic ae_nabs.nfo, that includes like what I use in php for my website would be fricking fantastic things to have. I could just rip out entire house definitions and put them in a seperate file. I could just 0 * 0 out each line on the NFO, and then let NFORenum patch it all back up. So I went and badgered DaleStan for some sort of include funtionality in either GRFCodec or NFORenum.
Instead the almighty Patchman jumps in and suggests using a C-style #include, and using “gcc -E < target > destination” to patch it all back together. After I toyed with that and got it working, he then suggested creating a makefile to automate the entire process.
Several days later I have finally achieved my goal. Manage an gigantic NFO project how you would a blob of source-code (Well, how I imagine you would, I’m no frickin’ programmer :P).
Makefile (The important part) is block-quoted here, read it, copy it, and bend it to your will. Feel free not to credit me or any of that crap, but if you run around treating it as your own invention, I’ll slap you. I spent a lot of time getting this going.
Bah, whocares, it’s a frickin’ plain-text file. Have fun with it:
# Evil monstorous HNFO compiling makefile of DOOM!
# Written by Richard ‘Aegir’ Eldred. Major kudos to Josef ‘Patchman’ Drexler for the suggestion.
# MINI README:
# What we’re doing here breaks away from NFO coding norms a bit by using C style includes in our NFO files. Our working NFO files we now give the extension “.hnfo”. I have no idea what the significance of the H is, blame Josef for that. So now, we can break up a large NFO into multiple parts.
# From there, we use GCC to preprocess our HNFO. Unfortunatly it strips // comments but leaves # comments intact, so our processed NFO needs some nforenum loving (Which really should be done anyway to fix up sprite numbers and pseudosprite sizes, trying to do those by hand is madness).
# Lastly, with our NFORENUM processed NFO, we can then run GRFCODEC over it as usual.
# Instant lovin’ for your large projects.
# Change the macro’s around to suit your local configuration. I’m a lazy twot who uses grfcodec and nforenum via WINE. This allows my same TTD setup and dev environment to be portable back and forth between Windows and my own Linux machines.
# This should all work on a Windows machine with GCC and MAKE, although you will have to possibly change your CC macro to suit your setup.
# Lastly, you will just need to change around the relevent portion of the macros that alias your particular project, and then you should be about right.
# Have fun.
# Our Steps:
# 1: gcc -E preprocess
# 2: nforenum process
# 3: grfcodec compile
# Macros:
# Paths for our tools
GRFCODEC = wine /media/shared/Games/TTWin95/Data/grfcodec.exe -e
NFORENUM = wine /media/shared/Games/TTWin95/Data/renum.exe -b +
GRFDIR = /media/shared/Games/TTWin95/Data/newgrf
# GCC Settings:
CC = gcc
PREPROCESS = -E - < # Aliases for the set:
NAME = ae_nabs
# Now, the fun stuff:
# Target for all:
all : $(NAME)w.grf $(NAME).grf
# Compile Windows GRF
$(NAME)w.grf : $(NAME)w.nfo
@echo "Compiling Windows GRF:"
$(GRFCODEC) $(NAME)w.nfo .
@echo
# NFORENUM process the Windows copy of the NFO
$(NAME)w.nfo : $(NAME)w.pnfo
@echo "NFORENUM Processing:"
-$(NFORENUM) $(NAME)w.nfo
@echo
# GCC Preprocess the HNFO into the Windows NFO copy
$(NAME)w.pnfo :
@echo "GCC Preprocessing HNFO:"
$(CC) $(PREPROCESS) $(NAME).hnfo > $(NAME)w.nfo
@echo
# Compile DOS GRF
$(NAME).grf : $(NAME).nfo
@echo “Compiling DOS GRF:”
$(GRFCODEC) -em 1 $(NAME).nfo .
@echo
# NFORENUM process the DOS copy of the NFO
$(NAME).nfo : $(NAME).pnfo
@echo “NFORENUM Processing:”
-$(NFORENUM) $(NAME).nfo
@echo
# GCC Preprocess the HNFO into the DOS NFO copy
$(NAME).pnfo :
@echo “GCC Preprocessing HNFO:”
$(CC) $(PREPROCESS) $(NAME).hnfo > $(NAME).nfo
@echo
# Clean the source tree
clean:
@echo “Cleaning source tree:”
@echo “Remove backups:”
-rm *.bak *~
@echo
@echo “Remove .nfo:”
-rm *.nfo
@echo
@echo “Remove compiled .grf:”
-rm *.grf
# Installation process
install:
@echo Installing .grf files to $(GRFDIR).
@echo “Windows GRF:”
-cp $(NAME)w.grf $(GRFDIR)/$(NAME)w.grf
@echo
@echo “DOS GRF:”
-cp $(NAME).grf $(GRFDIR)/$(NAME).grf
Oh, the blockquote screws the makefile up in places, get the real thing here:
http://www.aegir.bur.st/scraps/makefile
Edit: I’ve done a lot of development on this makefile lately, an update will come detailing the changes. :).