minor gitignore additions
[summerhack] / Makefile
index 459126d..105f352 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,34 +8,78 @@ obj = $(src:.cpp=.o) $(csrc:.c=.o)
 
 opt = -O1
 opt = -g
-CXXFLAGS = -ansi -pedantic -Wall $(opt) -Isrc/3dengfx/src `src/3dengfx/3dengfx-config --cflags`
-CFLAGS = -std=c89 -pedantic -Wall $(opt) `src/3dengfx/3dengfx-config --cflags`
-libs = src/3dengfx/lib3dengfx.a `src/3dengfx/3dengfx-config --libs-no-3dengfx` -lGL -lvorbisfile
+incdir = -Isrc/3dengfx/src -Ilibs -Ilibs/png -Ilibs/jpeglib -Ilibs/ogg -Ilibs/vorbis
+CXXFLAGS = -ansi -pedantic -Wall $(opt) $(incdir) -MMD `sdl-config --cflags`
+CFLAGS = -std=c89 -pedantic -Wall $(opt) $(incdir) -MMD `sdl-config --cflags`
+libs = $(libdir) $(libsys) src/3dengfx/lib3dengfx.a `sdl-config --libs` $(libgl) \
+          -lvorbis -logg -ljpeg -lpng -lz -l3ds $(libc)
 
-$(bin): $(obj) src/3dengfx/lib3dengfx.a data/tex_list
+sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
+ifeq ($(sys), mingw)
+       obj = $(src:.cpp=.w32.o) $(csrc:.c=.w32.o)
+       bin = sumhack-thelab.exe
+       libdir = -Llibs/w32
+       libgl = -lopengl32
+       libsys = -lmingw32 -lgdi32 -mconsole
+       libc = -lm
+
+else
+       libdir = -Llibs
+       libgl = -lGL
+       libc = -lm
+endif
+
+
+$(bin): $(obj) 3dengfx libs
        $(CXX) -o $@ $(obj) $(libs)
 
-src/3dengfx/lib3dengfx.a:
-       cd src/3dengfx;\
-       ./configure --with-gfxlib=sdl --disable-ft --enable-opt --disable-debug && make
+%.w32.o: %.c
+       $(CC) -o $@ $(CFLAGS) -c $<
 
-data/tex_list: $(src)
-       tools/find_textures >$@
+%.w32.o: %.cpp
+       $(CXX) -o $@ $(CXXFLAGS) -c $<
 
--include $(obj:.o=.d)
+.PHONY: 3dengfx
+3dengfx:
+       $(MAKE) -C src/3dengfx
 
-%.d: %.cpp
-       @set -e; rm -f $@; $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$; \
-       sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$
+.PHONY: 3dengfx-clean
+3dengfx-clean:
+       $(MAKE) -C src/3dengfx clean
 
-%.d: %.c
-       @set -e; rm -f $@; $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
-       sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$
+-include $(obj:.o=.d)
 
 .PHONY: clean
 clean:
        $(RM) $(obj) $(bin)
 
+.PHONY: clean-all
+clean-all: clean 3dengfx-clean cleandep clean-libs
+
 .PHONY: cleandep
 cleandep:
-       find src \( -name '*.d' -o -name '*.d.*' \) -exec $(RM) '{}' ';'
+       $(RM) $(obj:.o=.d)
+
+.PHONY: libs
+libs:
+       $(MAKE) -C libs
+
+.PHONY: clean-libs
+clean-libs:
+       $(MAKE) -C libs clean
+
+.PHONY: cross
+cross:
+       $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw
+
+.PHONY: cross-libs
+cross-libs:
+       $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw -C libs
+
+.PHONY: cross-clean
+cross-clean:
+       $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw clean
+
+.PHONY: cross-clean-libs
+cross-clean-libs:
+       $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw -C libs clean