fixed makefile to build on IRIX by auto-detecting it needs to link with
[miniglut] / Makefile
1 src = miniglut.c test.c
2 obj = $(src:.c=.o)
3 bin = test
4
5 CFLAGS = -pedantic -Wall -g
6
7 isx86 ?= $(shell uname -m | sed 's/x86_64/x86/; s/i.86/x86/')
8
9 sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
10 ifeq ($(sys), mingw)
11         obj = $(src:.c=.w32.o)
12         bin = test.exe
13
14         LDFLAGS = -mconsole -lopengl32 -lgdi32 -lwinmm
15 else ifeq ($(sys)-$(isx86), Linux-x86)
16         LDFLAGS = -lX11 -lGL
17 else
18         # for other UNIX or non-x86 where sys_ and trig functions are not
19         # implemented, just use libc
20         CFLAGS += -DMINIGLUT_USE_LIBC
21         LDFLAGS = -lX11 -lGL -lm
22         ifeq ($(sys), IRIX)
23                 CC = gcc
24         endif
25 endif
26
27 $(bin): $(obj)
28         $(CC) -o $@ $(obj) $(LDFLAGS)
29
30 %.w32.o: %.c
31         $(CC) -o $@ $(CFLAGS) -c $<
32
33 .PHONY: clean
34 clean:
35         rm -f $(obj) $(bin)
36
37 .PHONY: cross
38 cross:
39         $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw
40
41 .PHONY: cross-clean
42 cross-clean:
43         $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw clean