forked from brson/rust-sdl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
54 lines (42 loc) · 1.03 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
VPATH=%VPATH%
RUSTC ?= rustc
RUSTFLAGS ?= --cfg image --cfg mixer
SDL_PREFIX ?= /usr/local/lib
AR ?= ar
CHMOD ?= chmod
CP ?= cp
LD ?= ld
MV ?= mv
RM ?= rm
RUST_SRC = $(shell find $(VPATH)/src/. -type f -name '*.rs')
.PHONY: all
all: libsdl.dummy
UNAME=$(shell uname)
ifeq ($(UNAME),Darwin)
SDLXMAIN=libSDLXmain.a
ifeq (%SDL_MODE%,framework)
RUSTFLAGS+=--cfg mac_framework
else
RUSTFLAGS+=--cfg mac_dylib
endif
else
SDLXMAIN=
endif
libsdl.dummy: src/sdl.rc $(RUST_SRC) $(SDLXMAIN)
$(RUSTC) $(RUSTFLAGS) $< -o $@
touch $@
demos: demo/demo.rc libsdl.dummy
$(RUSTC) -L . $< -o $@
# Darwin-specific hack to change the name of `main` to `SDLX_main`
$(SDLXMAIN): $(SDL_PREFIX)/libSDLmain.a
$(CP) $< $@
$(AR) -x $@ SDLMain.o || $(RM) -f $@
$(LD) -r SDLMain.o -o SDLXMain.o -alias _main _SDLX_main -unexported_symbol main || $(RM) -f $@
$(MV) SDLXMain.o SDLMain.o || $(RM) -f $@
$(CHMOD) u+w $@ || $(RM) -f $@
$(AR) -r $@ SDLMain.o || $(RM) -f $@
demo: demos
./demos
.PHONY: clean
clean:
rm -f sdl-test *.so *.dylib *.dll *.dummy demos