Move the if for GCC 4 to an elseif so it does not interfere with MacOS
[open-adventure.git] / Makefile
index 435adc4622adb602af320034fd342a494a97f263..22f1370edf6665e0db8547cdb0cf35b80751f9cf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,31 +1,42 @@
 # Makefile for the open-source release of adventure 2.5
 
 LIBS=-lrt
-OBJS=main.o init.o actions1.o actions2.o score.o misc.o database/database.o
+UNAME_S := $(shell uname -s)
+GCCVERSIONGTEQ4 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 4)
+ifeq ($(UNAME_S),Darwin)
+       LIBS=
+else ifeq "$(GCCVERSIONGTEQ4)" "1"
+       CC=c99 --std=gnu99
+endif
+
+OBJS=main.o init.o actions1.o actions2.o score.o misc.o database.o
 SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO advent.text control
 
 .c.o:
-       gcc -O $(DBX) -c $<
+       $(CC) -O $(DBX) -c $<
 
-advent:        $(OBJS) database
-       gcc -Wall -std=c99 -O $(DBX) -o advent $(OBJS) $(LIBS)
+advent:        $(OBJS)
+       $(CC) -Wall -std=c99 -O $(DBX) -o advent $(OBJS) $(LIBS)
 
-main.o:                main.h misc.h funcs.h database/database.h
+main.o:                main.h misc.h funcs.h database.h
 
-init.o:                misc.h main.h share.h funcs.h database/database.h
+init.o:                misc.h main.h share.h funcs.h database.h
 
-actions1.o:    misc.h main.h share.h funcs.h database/database.h
+actions1.o:    misc.h main.h share.h funcs.h database.h
 
 actions2.o:    misc.h main.h share.h funcs.h
 
-score.o:       misc.h main.h share.h database/database.h
+score.o:       misc.h main.h share.h database.h
 
-misc.o:                misc.h main.h database/database.h
+misc.o:                misc.h main.h database.h
+
+database.c database.h: compile
+       ./compile
+       $(CC) $(OPTIONS) -O $(DBX) -c database.c
 
 clean:
-       rm -f *.o advent advent.html advent.6 adventure.data
+       rm -f *.o advent advent.html advent.6 database.[ch] compile
        cd tests; $(MAKE) --quiet clean
-       cd database; $(MAKE) clean
 
 check: advent
        cd tests; $(MAKE) --quiet
@@ -47,6 +58,3 @@ release: advent-$(VERS).tar.gz advent.html
 
 refresh: advent.html
        shipper -N -w version=$(VERS) | sh -e -x
-
-database:
-       cd database; $(MAKE)