# This is the Makefile for openshooter on FreeBSD
# Thanks to Felix Opatz (felix at zotteljedi.de) for mailing this Makefile.
# You should edit this file before you compile openshooter

# Path to make (if unsure then don't change)
MAKE = gmake

# C compiler (if you specify flags, they will be executed on every file)
CC = gcc

# Your operating system (if unsure then don't change)
MAKE_OS = \"`uname -s`\"
 
# Specifies the libraries. You should use the SDL library but if this doesn't
# work then try GLX too.
# For SDL you need this variables:
LIBS = `sdl11-config --libs` -ljpeg -lm -lGL -lGLU -L/usr/X11R6/lib/
CFLAGS = -DPLAT_MAKE -DPLAT_SDL `sdl11-config --cflags` -DMAKE_OS=$(MAKE_OS) -I/usr/X11R6/include/ --std c99 -Wall -pedantic
# And for GLX (uncomment then and comment the SDL variables):
# LIBS = -L/usr/X11R6/lib -lXxf86vm -lpthread -ljpeg -lm -lGL -lGLU
# CFLAGS = -DPLAT_MAKE -DPLAT_GLX -DMAKE_OS=$(MAKE_OS)

# If you need to specify an include path, then append -I/path/to/include/files
# to CFLAGS. To add a library path, append -L/path/to/the/library to LIBS.

# Path to the binary of openshooter
PATH_BIN = /usr/local/bin

# Path to the data files of openshooter
PATH_DATA = /usr/local/lib

###############################################################################
# YOU SHOULDN'T CHANGE ANYTHING BELOW THIS LINE	(except you know what you do) #
###############################################################################

OBJS = cam.o draw.o keys.o main.o texture.o font.o 3dmath.o
EXEC = openshooter.bin
NAME = openshooter
DATA = data

MAKEVARS = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LIBS=$(LIBS)' \
          'CFLAGS= $(CFLAGS)' 'OBJS=$(OBJS)' 'EXEC=$(EXEC)'

$(EXEC):	all

all:	
		@echo + Compiling $(NAME). This may take a while.
		@cd src && $(MAKEVARS)
		@echo + Done. Now type \'make install\' as root to \
			install $(NAME).

clean:
		@echo + Cleaning up
		rm -f $(EXEC)
		@cd src && $(MAKEVARS) clean
		@echo + Done

install:	
		@echo + Creating directories
		mkdir -p $(PATH_BIN)
		mkdir -p $(PATH_DATA)/$(NAME)
		@echo + Installing start script
		echo "#!/bin/sh" > $(PATH_BIN)/$(NAME)
		echo "cd $(PATH_DATA)/$(NAME)" >> $(PATH_BIN)/$(NAME)
		echo "./$(EXEC)" >> $(PATH_BIN)/$(NAME)
		chmod 755 $(PATH_BIN)/$(NAME)
		@echo + Installing binary...
		cp $(EXEC) $(PATH_DATA)/$(NAME)
		@echo + Installing data...
		cp -r $(DATA) $(PATH_DATA)/$(NAME)
		@echo + $(NAME) successfully installed. Type $(NAME) to run it.

uninstall:
		@echo + Removing $(NAME)
		rm -f $(PATH_BIN)/$(NAME)
		rm -rf $(PATH_DATA)/$(NAME)
		@echo + Thank you for using $(NAME)!
