# Vulture's Makefile ifdef BUILD ifndef CC CC := gcc endif LD := ld ifndef SDL_CFLAGS ifndef SDL_CONFIG OS := $(shell uname -s) ifeq ($(OS),FreeBSD) SDL_CONFIG := sdl11-config else SDL_CONFIG := sdl-config endif endif SDL_CFLAGS = $(shell $(SDL_CONFIG) --cflags) endif CFLAGS := $(BASECFLAGS) $(SDL_CFLAGS) -DUSE_SDL_SYSCALLS -g -O ifeq ($(BUILD), nethack) BUILDDIR := build_n CFLAGS += -DVULTURESEYE else BUILDDIR := build_s CFLAGS += -DVULTURESCLAW endif # build target OUTPUT_OBJ := $(BUILDDIR)/vultures.o NHDIR := ../$(BUILD) NHSRC := $(NHDIR)/src INCLUDE := -I $(NHDIR)/include/ -I . -I $(BUILDDIR)/ # list of sources. list of objects and dependency files are autogenerated from it VSOURCES := $(wildcard *.c) VOBJ := $(patsubst %.c,$(BUILDDIR)/%.o, $(VSOURCES)) $(BUILDDIR)/vultures_gametiles.o VDEPS := $(subst .o,.d, $(VOBJ)) # add vultures_gametiles.c to sources; due to it's different path it would have caused problems before... VSOURCES += $(BUILDDIR)/vultures_gametiles.c # objects and libs for tiletrans TTOBJ := $(NHSRC)/monst.o $(NHSRC)/objects.o $(BUILDDIR)/util/tiletrans.o $(BUILDDIR)/util/tilespec.o TTCFLAGS = -g -O2 -Wall $(SDL_CFLAGS) # tiletrans uses SDL_endian.h to become endian-safe TTLIBS := -L/usr/local/lib -lpng -lm -lz TILESRC := ./gamedata/graphics/tilesrc TTOUTPUT := $(BUILDDIR)/vultures_gametiles.c $(BUILDDIR)/vultures_gametiles.h gamedata/graphics/gametiles.bin # how to genereate dependency info define gendeps @mkdir -p $(BUILDDIR) @set -e; rm -f $@; \ $(CC) -MM $(CFLAGS) $(INCLUDE) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,$(BUILDDIR)/\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ endef .PHONY : all all: $(OUTPUT_OBJ) @echo finished building the files for the vultures interface $(OUTPUT_OBJ): $(VOBJ) gamedata/graphics/gametiles.bin @echo combining objects to $@ @$(LD) -r $(VOBJ) -o $(OUTPUT_OBJ) #pseudo dependency of vultures_gametiles.h on vultures_gametiles.c to unbreak parallel make $(BUILDDIR)/vultures_gametiles.h: $(BUILDDIR)/vultures_gametiles.c #create vultures_gametiles.c and vultures_gametiles.h $(TTOUTPUT): $(BUILDDIR)/tiletrans $(TILESRC)/*.png @echo "running tiletrans:" @mkdir -p $(BUILDDIR) @$(BUILDDIR)/tiletrans ./gamedata/graphics/gametiles.bin $(TILESRC)/ @mv vultures_gametiles.c $(BUILDDIR)/ @mv vultures_gametiles.h $(BUILDDIR)/ # build tiletrans $(BUILDDIR)/tiletrans: $(TTOBJ) @echo "building tiletrans" @$(CC) $(TTCFLAGS) $(TTLIBS) $(TTOBJ) -o $(BUILDDIR)/tiletrans $(BUILDDIR)/util/%.o: util/%.c util/tiletrans.h GNUmakefile @mkdir -p $(BUILDDIR)/util @echo compiling $< @$(CC) $(TTCFLAGS) $(INCLUDE) -c $< -o $@ # including the dependency files will cause them to be built if they don't exist -include $(VDEPS) # additionally, all our objects depend on the Makefile: $(VOBJ): GNUmakefile # rules to generate the dependencies using the gendeps macro $(BUILDDIR)/%.d: %.c $(gendeps) $(BUILDDIR)/vultures_gametiles.d: $(BUILDDIR)/vultures_gametiles.c $(gendeps) # this will cause all regular files to be built # NOTE: this rule will match for ../nethack/src/monst.c -> ../nethack/src/monst.o # too, if necessary. Normally monst.o will already exist when we get here, # but it may be useful when testing tiletrans... %.o $(BUILDDIR)/%.o: %.c @echo compiling $< @mkdir -p $(BUILDDIR) @$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ else # BUILD not defined .PHONY:all all: @echo "you must invoke this makefile with BUILD=(nethack|slashem)" @echo "so that we can find our includes..." @echo "you may also give additional parameters such as CFLAGS= etc" endif .PHONY: clean: rm -rf build_n/ build_s/ vultures_gametiles.h