initial commit
[liquidmodel] / Makefile
1 src = $(wildcard src/*.c) $(wildcard src/scr/*.c) $(wildcard src/pc/*.c) \
2           libs/glew/glew.c
3 obj = $(src:.c=.o)
4 dep = $(src:.c=.d)
5 bin = modeller
6
7 warn = -pedantic -Wall
8 dbg = -g
9 #opt = -O3 -ffast-math -fno-strict-aliasing -DNDEBUG
10 def = -DMINIGLUT_USE_LIBC -DGLEW_STATIC
11 incdir = -Isrc -Ilibs -Ilibs/imago/src -Ilibs/treestore -Ilibs/glew
12 libs_path = libs/unix
13 libdir = -L$(libs_path)
14
15 libs = $(libs_path)/libimago.a $(libs_path)/libtreestore.a $(libs_path)/libanim.a \
16            $(libs_path)/libpsys.a $(libs_path)/libminiaudio.a
17
18 CFLAGS = $(warn) $(dbg) $(opt) $(def) $(incdir) -fcommon -MMD
19 LDFLAGS = $(libdir) $(libsys) $(libgl) -limago -lpsys -lanim -ltreestore -lminiaudio \
20                   $(libc)
21
22 sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
23 ifeq ($(sys), mingw)
24         obj = $(src:.c=.w32.o)
25         bin = demo.exe
26         libgl = -lopengl32
27         libsys = -lmingw32 -lgdi32 -lwinmm -mconsole
28         libs_path = libs/w32
29         libc = -lm
30 else
31         libsys = -pthread
32         libgl = -lGL -lX11 -lXext
33         libc = -lm -ldl
34 endif
35
36 $(bin): $(obj) Makefile $(libs)
37         $(CC) -o $@ $(obj) $(LDFLAGS)
38
39 -include $(dep)
40
41 %.w32.o: %.c
42         $(CC) -o $@ $(CFLAGS) -c $<
43
44 $(libs_path)/%.a:
45         $(MAKE) -C libs
46
47 .PHONY: clean
48 clean:
49         rm -f $(obj) $(bin)
50
51 .PHONY: cleandep
52 cleandep:
53         rm -f $(dep)
54
55 .PHONY: libs
56 libs:
57         $(MAKE) -C libs
58
59 .PHONY: clean-libs
60 clean-libs:
61         $(MAKE) -C libs clean
62
63 .PHONY: android
64 android:
65         $(MAKE) -f Makefile.android
66
67 .PHONY: android-clean
68 android-clean:
69         $(MAKE) -f Makefile.android clean
70
71 .PHONY: android-libs
72 android-libs:
73         $(MAKE) -f Makefile.android libs
74
75 .PHONY: install
76 install:
77         $(MAKE) -f Makefile.android install
78
79 .PHONY: run
80 run:
81         $(MAKE) -f Makefile.android install run
82
83 .PHONY: stop
84 stop:
85         $(MAKE) -f Makefile.android stop
86
87 .PHONY: cross
88 cross:
89         $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw
90
91 .PHONY: cross-libs
92 cross-libs:
93         $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw -C libs
94
95 .PHONY: cross-clean
96 cross-clean:
97         $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw clean
98
99 .PHONY: cross-clean-libs
100 cross-clean-libs:
101         $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw -C libs clean