1#
2# xrick/Makefile
3#
4# Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
5#
6# The use and distribution terms for this software are contained in the file
7# named README, which can be found in the root of this distribution. By
8# using this software in any fashion, you are agreeing to be bound by the
9# terms of this license.
10#
11# You must not remove this notice, or any other, from this software.
12#
13
14#
15# Vars
16#
17
18SDLVERSION=$(shell sdl-config --version 2>/dev/null)
19ROOTDIR=$(shell pwd)
20TARGET=$(shell uname -s | tr [a-z] [A-Z])
21
22#
23# Config
24#
25
26ifeq ($(strip $(SDLVERSION)),)
27$(error SDL is missing)
28else
29$(warning Detected SDL version $(SDLVERSION))
30endif
31
32ifeq ($(strip $(SDLVERSION)),)
33$(error SDL is missing)
34endif
35
36SDL_MAJ=$(word 1,$(subst ., ,$(SDLVERSION)))
37SDL_MIN=$(word 2,$(subst ., ,$(SDLVERSION)))
38SDL_MIC=$(word 3,$(subst ., ,$(SDLVERSION)))
39
40SDL_MAJ_REQ=1
41SDL_MIN_REQ=2
42SDL_MIC_REQ=1
43
44SDL_CHKVER=$(shell if [ $(SDL_MAJ) -lt $(SDL_MAJ_REQ) ]; then echo "BAD"; fi)
45ifeq ($(SDL_CHKVER),BAD)
46$(error SDL version $(SDL_MAJ_REQ).$(SDL_MIN_REQ).$(SDL_MIC_REQ) is required)
47endif
48
49SDL_CHKVER=$(shell if [ $(SDL_MAJ) -eq $(SDL_MAJ_REQ) -a $(SDL_MIN) -lt $(SDL_MIN_REQ) ]; then echo "BAD"; fi)
50ifeq ($(SDL_CHKVER),BAD)
51$(error SDL version $(SDL_MAJ_REQ).$(SDL_MIN_REQ).$(SDL_MIC_REQ) is required)
52endif
53
54SDL_CHKVER=$(shell if [ $(SDL_MAJ) -eq $(SDL_MAJ_REQ) -a $(SDL_MIN) -eq $(SDL_MIN_REQ) -a $(SDL_MIC) -lt $(SDL_MIC_REQ) ]; then echo "BAD"; fi)
55ifeq ($(SDL_CHKVER),BAD)
56$(error SDL version $(SDL_MAJ_REQ).$(SDL_MIN_REQ).$(SDL_MIC_REQ) is required)
57endif
58
59ifneq (,$(findstring CYGWIN,$(TARGET)))
60XOBJ=xrick.res
61endif
62
63ifneq (,$(findstring MINGW,$(TARGET)))
64XOBJ=xrick.res
65endif
66
67#
68
69# Rules
70#
71
72all:
73	@echo "ROOTDIR=$(ROOTDIR)" > Makefile.global
74	@echo "XOBJ=$(XOBJ)" >> Makefile.global
75	@echo "CFLAGS=-pedantic -Wall -W -pipe -O2 -fno-strict-aliasing  -I $(ROOTDIR)/include $(shell sdl-config --cflags)" >> Makefile.global
76	@echo "LDFLAGS=-lz $(shell sdl-config --libs)" >> Makefile.global
77	@echo "CC=cc" >> Makefile.global
78	@echo "CPP=cc -E" >> Makefile.global
79	$(MAKE) -C src all
80
81clean:
82	for i in src include; do \
83	  $(MAKE) -C $$i clean; \
84	done
85	rm -f *~ log.txt Makefile.global
86
87depend:
88	$(MAKE) -C src depend
89
90# eof
91