1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-24 05:17:17 +00:00

Merge pull request #38 from Quuxplusone/makefile-fixes

Minor fixes for Mac and MinGW.
This commit is contained in:
Zeno Rogue 2018-06-17 18:22:45 +02:00 committed by GitHub
commit dabf322095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 74 additions and 19 deletions

View File

@ -1,4 +1,4 @@
# This Makefile works for Mac OS X (Yosemite).
# This Makefile works for Mac OS X (El Capitan).
#
# Run "brew install sdl" to install SDL in /usr/local.
# Run "brew install sdl_gfx".
@ -7,15 +7,31 @@
# Run "make -f Makefile.mac" to build HyperRogue as ./hyper.
CXXFLAGS += -std=c++11 -march=native -DMAC
# CXXFLAGS += -DCAP_ROGUEVIZ
CXXFLAGS += -W -Wall -Wextra -pedantic
CXXFLAGS += -Wno-format-pedantic -Wno-unused-parameter -Wno-char-subscripts -Wno-missing-field-initializers -Wno-vla-extension
CXXFLAGS += ${EXTRA_CXXFLAGS}
CXXFLAGS += -Wno-format-pedantic -Wno-unused-parameter -Wno-missing-field-initializers -Wno-vla-extension
CXXFLAGS += -I/usr/local/include
CXXFLAGS += ${EXTRA_CXXFLAGS}
LDFLAGS += -L/usr/local/lib
hyper: hyper.o
$(CXX) $(CXXFLAGS) hyper.o $(LDFLAGS) -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -framework AppKit -framework OpenGL -o hyper
OBJS = hyper.o
ifeq (a,b)
# Enable PNG screenshots. Requires "brew install libpng".
CXXFLAGS += -DCAP_PNG
LDFLAGS += -lpng
OBJS += savepng.o
else
CXXFLAGS += -DCAP_PNG=0
endif
ifeq (a,b)
# Enable RogueViz.
CXXFLAGS += -DCAP_ROGUEVIZ
endif
hyper: $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LDFLAGS) -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -framework AppKit -framework OpenGL -o hyper
hyper.o: *.cpp language-data.cpp
$(CXX) $(CXXFLAGS) -O2 -c hyper.cpp
@ -23,11 +39,13 @@ hyper.o: *.cpp language-data.cpp
langen: langen.cpp language-??.cpp language-ptbr.cpp
$(CXX) $(CXXFLAGS) -O0 -Wno-embedded-directive langen.cpp -o langen
# Generation of language-data.cpp
language-data.cpp: langen
./langen > language-data.cpp
savepng.o: savepng.cpp
$(CXX) $(CXXFLAGS) -O2 -c savepng.cpp
.PHONY: clean
clean:
rm -f langen language-data.cpp hyper.o hyper
rm -f hyper hyper.o langen language-data.cpp savepng.o

View File

@ -7,11 +7,26 @@
CXXFLAGS += -std=c++11 -mwindows -DWINDOWS
CXXFLAGS += -D_A_VOLID=8
CXXFLAGS += -DCAP_PNG=0
CXXFLAGS += ${EXTRA_CXXFLAGS}
hyper.exe: hyper.obj hyper.res
$(CXX) $(CXXFLAGS) hyper.obj hyper.res -lSDL -lSDL_mixer -lopengl32 -lSDL_ttf -lSDL_gfx -lglew32 -o hyper.exe
OBJS = hyper.obj
ifeq (a,b)
# Enable PNG screenshots. Requires libpng.
CXXFLAGS += -DCAP_PNG
LDFLAGS += -lpng
OBJS += savepng.obj
else
CXXFLAGS += -DCAP_PNG=0
endif
ifeq (a,b)
# Enable RogueViz.
CXXFLAGS += -DCAP_ROGUEVIZ
endif
hyper.exe: $(OBJS) hyper.res
$(CXX) $(CXXFLAGS) $(OBJS) hyper.res -lSDL -lSDL_mixer -lopengl32 -lSDL_ttf -lSDL_gfx -lglew32 -o hyper.exe
hyper.obj: *.cpp language-data.cpp hyper.res
$(CXX) $(CXXFLAGS) -O2 -c hyper.cpp -o hyper.obj
@ -25,7 +40,10 @@ langen.exe: langen.cpp language-??.cpp language-ptbr.cpp
language-data.cpp: langen.exe
./langen.exe > language-data.cpp
savepng.obj: savepng.cpp
$(CXX) $(CXXFLAGS) -O2 -c savepng.cpp -o savepng.obj
.PHONY: clean
clean:
rm -f langen.exe language-data.cpp hyper.obj hyper.res hyper.exe
rm -f hyper.exe hyper.obj hyper.res langen.exe language-data.cpp savepng.obj

View File

@ -754,7 +754,8 @@ void nextPrime(fgeomextra& ex) {
fp.Prime = nextprime;
if(fp.solve() == 0) {
fp.build();
ex.primes.emplace_back(primeinfo{nextprime, size(fp.matrices) / S7, (bool) fp.wsquare});
int cells = fp.matrices.size() / S7;
ex.primes.emplace_back(primeinfo{nextprime, cells, (bool) fp.wsquare});
break;
}
nextprime++;

14
hyper.h
View File

@ -6,6 +6,8 @@
#define VERNUM 10403
#define VERNUM_HEX 0xA0B3
#include <stdarg.h>
namespace hr {
using namespace std;
@ -368,7 +370,7 @@ string its(int i);
int hrand(int i);
#ifndef STDSIZE
template<class T> int size(const T& x) {return int(x.size()); }
template<class T> int size(const T& x) {return x.size(); }
#endif
// initialize the achievement system.
@ -3433,7 +3435,15 @@ int score_default(int id);
void handle_event(SDL_Event& ev);
#ifndef XPRINTF
template<class...T> void Xprintf(const char *fmt, T... t) { printf(fmt, t...); }
#ifdef __GNUC__
__attribute__((__format__ (__printf__, 1, 2)))
#endif
void Xprintf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
#endif
void pop_game();

View File

@ -14,7 +14,9 @@
#include <stdlib.h>
using namespace std;
template<class T> int size(T x) { return x.size(); }
#ifndef STDSIZE
template<class T> int size(const T& x) { return x.size(); }
#endif
#define NUMLAN 7

View File

@ -23,7 +23,7 @@ void rvvideo(const string &fname) {
reached = (2*reached-1) / 3;
else reached *= 2;
}
printf("reached = %Ld\n", reached);
printf("reached = %lld\n", reached);
vector<string> seq;
while(reached>1) {
seq.push_back(llts(reached));

View File

@ -35,6 +35,9 @@ static void png_write_SDL(png_structp png_ptr, png_bytep data, png_size_t length
SDL_RWwrite(rw, data, sizeof(png_byte), length);
}
#ifdef __cplusplus
extern "C"
#endif
SDL_Surface *SDL_PNGFormatAlpha(SDL_Surface *src)
{
SDL_Surface *surf;
@ -56,6 +59,9 @@ SDL_Surface *SDL_PNGFormatAlpha(SDL_Surface *src)
return surf;
}
#ifdef __cplusplus
extern "C"
#endif
int SDL_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
{
png_structp png_ptr;

View File

@ -88,7 +88,7 @@
#define CAP_SDL (!ISMOBILE)
#endif
#ifdef CAP_COMPASS
#ifndef CAP_COMPASS
#define CAP_COMPASS ISMOBILE
#endif