The-Powder-Toy/Makefile

173 lines
8.1 KiB
Makefile
Raw Normal View History

SOURCES := $(wildcard src/*.c src/elements/*.c)
HEADERS := $(wildcard includes/*.h)
OBJS := $(patsubst src/%.c,build/obj/%.o,$(SOURCES))
CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -Iincludes/ -D_GNU_SOURCE
2010-07-25 09:03:39 -05:00
OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
LFLAGS := -lpthread -lSDL -lfftw3f -lm -lbz2 -lX11 -llua5.1 -lrt
LFLAGS_X := -lm -lbz2 -lSDLmain
LFLAGS_WIN := -lmingw32 -lgnurx -lws2_32 -lSDLmain -lpthread -lSDL -lfftw3f -lm -lbz2 -llua5.1
2011-01-01 14:02:00 -06:00
MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3
MFLAGS_SSE2 := -march=native -DX86 -DX86_SSE2 -msse2
MFLAGS_SSE := -march=native -DX86 -DX86_SSE
FLAGS_DBUG := -Wall -pg -g
COMPILER := gcc
2010-07-25 09:03:39 -05:00
LINUX_TARG := powder-64-sse2 powder-sse powder-sse2
WIN32_TARG := powder-sse.exe powder-sse2.exe
CC := gcc
CC_WIN := i686-w64-mingw32-gcc
WIN_RES := i686-w64-mingw32-windres
powder: build/powder
powder-debug: build/powder-debug
powder-sse3: build/powder-sse3
powder-sse2: build/powder-sse2
powder-sse: build/powder-sse
powder-sse3-opengl: build/powder-sse3-opengl
powder-64-sse3: build/powder-64-sse3
powder-64-sse2: build/powder-64-sse2
powder-debug-64: build/powder-debug-64
powder-64-sse3-opengl: build/powder-64-sse3-opengl
powder-sse3.exe: build/powder-sse3.exe
powder-sse2.exe: build/powder-sse2.exe
powder-sse.exe: build/powder-sse.exe
# general compiler flags
build/powder: CFLAGS += -DINTERNAL -DLIN64 $(OFLAGS)
build/powder-debug: CFLAGS += -m32 -DLIN32 $(FLAGS_DBUG)
build/powder-sse3 build/powder-sse2 build/powder-sse build/powder-sse3-opengl: CFLAGS += -m32 -DLIN32 $(OFLAGS)
build/powder-64-sse3 build/powder-64-sse2 build/powder-64-sse3-opengl: CFLAGS += -m64 -DLIN64 $(OFLAGS)
build/powder-debug-64: CFLAGS += -m64 -DLIN64 $(FLAGS_DBUG)
build/powder-sse3.exe build/powder-sse2.exe build/powder-sse.exe: CFLAGS += -mwindows -DWIN32 $(OFLAGS)
build/powder-64-sse3-opengl build/powder-sse3-opengl: CFLAGS += -DOGLR -DPIX32OGL -DPIXALPHA
# SSE flags:
build/powder build/powder-sse3 build/powder-sse3-opengl build/powder-64-sse3 build/powder-64-sse3-opengl build/powder-debug build/powder-debug-64 build/powder-sse3.exe: CFLAGS += -march=native -DX86 -DX86_SSE3 -msse3
build/powder-sse2 build/powder-64-sse2 build/powder-sse2.exe: CFLAGS += -march=native -DX86 -DX86_SSE2 -msse2
build/powder-sse build/powder-sse.exe: CFLAGS += -march=native -DX86 -DX86_SSE
# libs:
build/powder build/powder-debug build/powder-sse3 build/powder-sse2 build/powder-sse build/powder-sse3-opengl build/powder-debug-64 build/powder-64-sse3 build/powder-64-sse2 build/powder-64-sse3-opengl: LIBS += $(LFLAGS)
build/powder-sse3.exe build/powder-sse2.exe build/powder-sse.exe: LIBS += $(LFLAGS_WIN)
build/powder-64-sse3-opengl build/powder-sse3-opengl: LIBS += -lGL
# extra windows stuff
build/powder-sse3.exe build/powder-sse2.exe build/powder-sse.exe: EXTRA_OBJS += build/obj/powder-res.o
build/powder-sse3.exe build/powder-sse2.exe build/powder-sse.exe: CC := $(CC_WIN)
build/powder-sse3.exe build/powder-sse2.exe build/powder-sse.exe: build/obj/powder-res.o
build/powder: $(patsubst build/obj/%.o,build/obj/%.powder.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder.o,$(OBJS)) $(LIBS) -o $@
build/obj/%.powder.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-debug: $(patsubst build/obj/%.o,build/obj/%.powder-debug.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-debug.o,$(OBJS)) $(LIBS) -o $@
build/obj/%.powder-debug.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-sse3: $(patsubst build/obj/%.o,build/obj/%.powder-sse3.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse3.o,$(OBJS)) $(LIBS) -o $@
2010-08-11 07:48:32 -05:00
strip $@
build/obj/%.powder-sse3.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
2011-04-12 06:19:21 -05:00
build/powder-sse2: $(patsubst build/obj/%.o,build/obj/%.powder-sse2.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse2.o,$(OBJS)) $(LIBS) -o $@
2010-09-03 07:26:54 -05:00
strip $@
build/obj/%.powder-sse2.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-sse: $(patsubst build/obj/%.o,build/obj/%.powder-sse.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse.o,$(OBJS)) $(LIBS) -o $@
strip $@
build/obj/%.powder-sse.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-sse3-opengl: $(patsubst build/obj/%.o,build/obj/%.powder-sse3-opengl.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse3-opengl.o,$(OBJS)) $(LIBS) -o $@
strip $@
build/obj/%.powder-sse3-opengl.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-64-sse3: $(patsubst build/obj/%.o,build/obj/%.powder-64-sse3.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-64-sse3.o,$(OBJS)) $(LIBS) -o $@
2010-08-11 07:48:32 -05:00
strip $@
build/obj/%.powder-64-sse3.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-64-sse2: $(patsubst build/obj/%.o,build/obj/%.powder-64-sse2.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-64-sse2.o,$(OBJS)) $(LIBS) -o $@
2010-08-11 07:48:32 -05:00
strip $@
build/obj/%.powder-64-sse2.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
2010-07-25 09:03:39 -05:00
build/powder-debug-64: $(patsubst build/obj/%.o,build/obj/%.powder-debug-64.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-debug-64.o,$(OBJS)) $(LIBS) -o $@
build/obj/%.powder-debug-64.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
2010-12-23 17:11:25 -06:00
build/powder-64-sse3-opengl: $(patsubst build/obj/%.o,build/obj/%.powder-64-sse3-opengl.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-64-sse3-opengl.o,$(OBJS)) $(LIBS) -o $@
strip $@
build/obj/%.powder-64-sse3-opengl.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/powder-sse3.exe: $(patsubst build/obj/%.o,build/obj/%.powder-sse3.exe.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse3.exe.o,$(OBJS)) $(LIBS) -o $@
2010-08-11 07:48:32 -05:00
strip $@
chmod 0644 $@
build/obj/%.powder-sse3.exe.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
# Extra compiler flag to fix stack alignment
# When Windows creates the gravity calculation thread, it has 4 byte stack alignment
# But we need 16 byte alignment so that SSE instructions in FFTW work without crashing
build/obj/gravity.powder-sse3.exe.o: src/gravity.c $(HEADERS)
$(CC) -c $(CFLAGS) -mincoming-stack-boundary=2 -o $@ $<
build/powder-sse2.exe: $(patsubst build/obj/%.o,build/obj/%.powder-sse2.exe.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse2.exe.o,$(OBJS)) $(LIBS) -o $@
2010-08-11 07:48:32 -05:00
strip $@
chmod 0644 $@
build/obj/%.powder-sse2.exe.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/obj/gravity.powder-sse2.exe.o: src/gravity.c $(HEADERS)
$(CC) -c $(CFLAGS) -mincoming-stack-boundary=2 -o $@ $<
build/powder-sse.exe: $(patsubst build/obj/%.o,build/obj/%.powder-sse.exe.o,$(OBJS))
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(patsubst build/obj/%.o,build/obj/%.powder-sse.exe.o,$(OBJS)) $(LIBS) -o $@
2010-08-11 07:48:32 -05:00
strip $@
chmod 0644 $@
build/obj/%.powder-sse.exe.o: src/%.c $(HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
build/obj/gravity.powder-sse.exe.o: src/gravity.c $(HEADERS)
$(CC) -c $(CFLAGS) -mincoming-stack-boundary=2 -o $@ $<
.PHONY: clean
clean:
rm -f build/obj/*.o
rm -f build/obj/elements/*.o
powder-icc: $(SOURCES)
/opt/intel/Compiler/11.1/073/bin/intel64/icc -m64 -o$@ -Iincludes/ -O2 -march=core2 -msse3 -mfpmath=sse -lSDL -lbz2 -lm -xW $(SOURCES) -std=c99 -D_POSIX_C_SOURCE=200112L
build/obj/powder-res.o: src/Resources/powder-res.rc src/Resources/powder.ico src/Resources/document.ico
cd src/Resources && $(WIN_RES) powder-res.rc powder-res.o
mv src/Resources/powder-res.o build/obj/powder-res.o
2011-04-12 06:19:21 -05:00
2010-09-04 16:12:41 -05:00
powder-x: $(SOURCES)
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL
2010-08-11 07:48:32 -05:00
strip $@
mv $@ build
2010-09-04 16:12:41 -05:00
powder-x-ogl: $(SOURCES)
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DOpenGL -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL -framework OpenGL
2010-09-03 04:32:37 -05:00
strip $@
2010-12-20 12:14:21 -06:00
mv $@ build