X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=makefile;h=fdf79bca85a29cf4a8cfc85ee1932b5138ae170b;hb=d22f243fc585a46e4c29d00bd32727d9f9f4055c;hp=311395c217330f9009d52accd2356f8e839cb060;hpb=27ad8041c00ff80e50ba0ad9022c3eaa7a05b8b0;p=thunder diff --git a/makefile b/makefile old mode 100755 new mode 100644 index 311395c..fdf79bc --- a/makefile +++ b/makefile @@ -1,59 +1,140 @@ # # Makefile for Thunder SDL # +# by James Hammons +# (C) 2009 Underground Software +# This software is licensed under the GPL v3 or later +# + +ifeq "$(OSTYPE)" "msys" # Win32 + +SYSTYPE = __GCCWIN32__ +EXESUFFIX = .exe +GLLIB = -lopengl32 +ICON = obj/icon.o +SDLLIBTYPE = --libs +MSG = Win32 on MinGW -# Uncomment the following lines to compile for Win32 +else +#ifeq "$(OSTYPE)" "darwin" +ifeq "darwin" "$(findstring darwin,$(OSTYPE))" # Should catch both 'darwin' and 'darwin7.0' -SYSTYPE = __GCCWIN32__ -EXESUFFIX = .exe -GLLIB = opengl32 -ICON = thunder-ico.o +SYSTYPE = __GCCUNIX__ -D_OSX_ +EXESUFFIX = +GLLIB = +ICON = +SDLLIBTYPE = --static-libs +MSG = Mac OS X -# Uncomment the following lines to compile for *nix +else # *nix -#SYSTYPE = __GCCUNIX__ -#EXESUFFIX = -#GLLIB = GL -#ICON = +SYSTYPE = __GCCUNIX__ +EXESUFFIX = +GLLIB = -lGL +ICON = +SDLLIBTYPE = --libs +MSG = generic Unix/Linux + +endif +endif CC = gcc LD = gcc TARGET = thunder -SDL_CFLAGS = -I/c/mingw/include/SDL -Dmain=SDL_main -SDL_CONFIG = /mingw/bin/sdl-config -SDL_LIBS = -L/c/mingw/lib -lmingw32 -lSDLmain -lSDL -mwindows +CFLAGS = -MMD -Wall -Wno-switch -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) -fomit-frame-pointer `sdl2-config --cflags` +CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) \ + -fomit-frame-pointer `sdl2-config --cflags` \ + -g +# -DLOG_UNMAPPED_MEMORY_ACCESSES + +LDFLAGS = + +# Ugh, let's get rid of the ref to -lcurses [DONE] +LIBS = `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz -lm $(GLLIB) + +INCS = -I. -Isrc + +OBJS = \ + obj/dis63701.o \ + obj/dis6809.o \ + obj/gui.o \ + obj/icon-64x64.o \ + obj/log.o \ + obj/psg.o \ + obj/resource.o \ + obj/screen.o \ + obj/sound.o \ + obj/v63701.o \ + obj/v6809.o \ + obj/video.o \ + obj/ym2151.o \ + obj/thunder.o \ + $(ICON) + +all: checkenv message obj $(TARGET)$(EXESUFFIX) + @echo + @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m" -# DEFS = -DX86_ASM -DLSB_FIRST -DEFS = -CFLAGS = -fstrength-reduce -fomit-frame-pointer -O2 -Wall -Wno-unused \ - -Wno-uninitialized -Wno-comment $(SDL_CFLAGS) -LIBS = -lstdc++ $(SDL_LIBS) -OBJS = obj/log.o obj/v6809.o obj/screen.o obj/gui.o obj/resource.o obj/thunder.o $(ICON) +# Check the compilation environment, barf if not appropriate -all: obj $(TARGET) +checkenv: + @echo + @echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m" +ifeq "" "$(shell which sdl-config)" + @echo + @echo + @echo -e "\033[01;33mIt seems that you don't have the SDL development libraries installed. + @echo -e "have installed them, make sure that the sdl-config file is somewhere in your" + @echo -e "path and is executable.\033[00m" + @echo +#Is there a better way to break out of the makefile? + @break +else + @echo -e "\033[01;37mOK\033[00m" +endif + +message: + @echo + @echo -e "\033[01;33m***\033[00;32m Building Thunder/SDL for $(MSG)...\033[00m" + @echo clean: - rm -rf obj - rm -f ./$(TARGET)$(EXESUFFIX) + @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m" + @rm -rf obj + @rm -f ./$(TARGET)$(EXESUFFIX) + @echo -e "\033[01;37mdone!\033[00m" obj: - mkdir obj + @mkdir obj -$(TARGET): $(OBJS) - $(LD) $(LDFLAGS) -o $@$(EXESUFFIX) $(OBJS) $(LIBS) -# strip --strip-all $(TARGET)$(EXESUFFIX) -# upx -9 $(TARGET)$(EXESUFFIX) +# This is only done for Win32 at the moment... + +ifneq "" "$(ICON)" +$(ICON): res/$(TARGET).rc res/$(TARGET).ico + @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m" + @windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res +endif -#obj/%.o: src/%.c -# $(CC) -c $< -o $@ +obj/%.o: src/%.c + @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m" + @$(CC) $(CFLAGS) $(INCS) -c $< -o $@ -#obj/%.o: src/%.cpp -obj/%.o: %.cpp %.h - $(CC) $(CFLAGS) -c $< -o $@ +obj/%.o: src/%.cpp + @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m" + @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@ + +obj/%.o: src/%.asm + @echo -e "\033[01;33m***\033[00;32m Assembling $<...\033[00m" + @nasm -f elf64 -I ./res/ $< -o $@ + +$(TARGET)$(EXESUFFIX): $(OBJS) + @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m" + @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) +# strip --strip-all $(TARGET)$(EXESUFFIX) +# upx -9 $(TARGET)$(EXESUFFIX) -obj/%.o: %.cpp - $(CC) $(CFLAGS) -c $< -o $@ +# Pull in dependencies autogenerated by gcc's -MMD switch +# The "-" in front in there just in case they haven't been created yet -obj/%.o: %.asm %.h - nasm -f coff $< -o $@ +-include obj/*.d