X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=Makefile;h=0fc7e973bb463b834a25b5a811be010311b90beb;hb=refs%2Fheads%2Fscreensaver;hp=a1dc85bec22ccf2a8c2057a564c395d7e1ad1467;hpb=fc0cfd2c7c9f5efddddb21fc94a15cc42685ca1d;p=censuslogo diff --git a/Makefile b/Makefile index a1dc85b..0fc7e97 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,25 @@ -src = $(wildcard src/*.c) +src = $(src_main) $(filter-out $(wildcard src/main_*.c), $(wildcard src/*.c)) obj = $(src:.c=.o) dep = $(obj:.o=.d) bin = censuslogo -CFLAGS = -pedantic -Wall -g -LDFLAGS = -lGL -lGLU -lglut -lm +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') + +CFLAGS = -pedantic -Wall -g -DNOLOAD +LDFLAGS = $(ldflags_sys) -lm + + +ifeq ($(sys), mingw) + src_main = src/main_w32.c + obj = $(src:.c=.w32.o) + bin = censuslogo.exe + CFLAGS += -DFREEGLUT_STATIC + + ldflags_sys = -lmingw32 -mconsole -lfreeglut_static -lopengl32 -lglu32 -lgdi32 -lwinmm +else + src_main = src/main_x11.c + ldflags_sys = -lGL -lGLU -lX11 +endif $(bin): $(obj) $(CC) -o $@ $(obj) $(LDFLAGS) @@ -21,3 +36,15 @@ clean: .PHONY: cleandep cleandep: rm -f $(dep) + +# --- cross-compile rules for win32 --- +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + +.PHONY: cross +cross: + $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw + +.PHONY: cross-clean +cross-clean: + $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw clean