Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #96 from tellowkrinkle/FixMacOSVersion
Browse files Browse the repository at this point in the history
Improve build
  • Loading branch information
DanielOaks committed Mar 10, 2020
2 parents 12fcd60 + 8360b30 commit bc26c33
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 2,135 deletions.
2 changes: 0 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ Here are my standard `./configure` and `make` lines, successfully building on OS
make
```

**note**: If you *have* the ``sdl2`` kegs installed via [Homebrew](http://brew.sh/), it will fail to build. This is likely an issue we should fix with our Makefiles and all.

## Building an OS X App

Building a proper application on OS X is fairly easy. Simply make sure you're in the base directory and run this:
Expand Down
42 changes: 27 additions & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ INTERNAL_LIBPNG=\$(findstring true,$INTERNAL_LIBPNG)
INTERNAL_LIBJPEG=\$(findstring true,$INTERNAL_LIBJPEG)
INTERNAL_OGGLIBS=\$(findstring true,$INTERNAL_OGGLIBS)
SDL_CONFIG=$SDL_CONFIG
export PKG_CONFIG_PATH := \$(shell pwd)/extlib/lib/pkgconfig:\$(PKG_CONFIG_PATH)
SHELLENV = PKG_CONFIG_PATH=\$(PKG_CONFIG_PATH)
export CC := $CC
export CXX := $CXX
Expand All @@ -914,9 +916,9 @@ export RANLIB := $RANLIB
# Ponscripter variables
PSCFLAGS = $CFLAGSEXTRA
INCS = $OURINCS \$(shell \$(SDL_CONFIG) --cflags) \\
\$(shell $SMPEG_CONFIG --cflags) \\
\$(shell $FREETYPE_CONFIG --cflags)
INCS = $OURINCS \$(shell \$(SHELLENV) \$(SDL_CONFIG) --cflags) \\
\$(shell \$(SHELLENV) $SMPEG_CONFIG --cflags) \\
\$(shell \$(SHELLENV) $FREETYPE_CONFIG --cflags)
_EOF
case "$SYS" in
MinGW)
Expand All @@ -932,9 +934,9 @@ fi

if $INTERNAL_SDL
then
MY_SDL_LIBS="\$(filter-out -lSDL2main,\$(shell \$(SDL_CONFIG) --static-libs))"
MY_SDL_LIBS="\$(filter-out -lSDL2main,\$(shell \$(SHELLENV) \$(SDL_CONFIG) --static-libs))"
else
MY_SDL_LIBS="\$(shell \$(SDL_CONFIG) --static-libs)"
MY_SDL_LIBS="\$(shell \$(SHELLENV) \$(SDL_CONFIG) --static-libs)"
fi

cat >> $MAKEFILE <<_EOF
Expand All @@ -944,7 +946,7 @@ LIBS = $OURLIBS \\
$NOTIFYLIBS $GTKLIBS\\
-static -Wl,--start-group \\
$MY_SDL_LIBS \\
\$(shell $SMPEG_CONFIG --libs) \$(shell $FREETYPE_CONFIG --libs) \\
\$(shell \$(SHELLENV) $SMPEG_CONFIG --libs) \$(shell \$(SHELLENV) $FREETYPE_CONFIG --libs) \\
$LINKSDL2_image $LINKjpeg $LINKpng $LINKz \\
$LINKSDL2_mixer $LINKogg $LINKvorbis $LINKvorbisfile \\
$LINKbz2 -Wl,--end-group
Expand All @@ -957,15 +959,22 @@ MacOSX)
cat >> $MAKEFILE <<_EOF
LIBS = $OURLIBS \\
\$(shell $SDL_CONFIG --static-libs) \\
\$(shell $SMPEG_CONFIG --libs) \\
\$(shell $FREETYPE_CONFIG --libs) \\
\$(shell \$(SHELLENV) $SDL_CONFIG --static-libs) \\
\$(shell \$(SHELLENV) $SMPEG_CONFIG --libs) \\
\$(shell \$(SHELLENV) $FREETYPE_CONFIG --libs) \\
$LINKSDL2_image $LINKjpeg $LINKpng \\
$LINKSDL2_mixer $LINKogg $LINKvorbis $LINKvorbisfile \\
$LINKbz2 -lm -framework CoreFoundation
CFLAGS = -mmacosx-version-min=10.5 $CFLAGS
CXXFLAGS = -mmacosx-version-min=10.5 $CXXFLAGS
export MACOSX_DEPLOYMENT_TARGET=10.7
# On 10.7 and 10.8 libc++ is available but not default
# Newer compilers no longer ship with libstdc++ so we will prefer libc++ if possible
ifeq (\$(MACOSX_DEPLOYMENT_TARGET),\$(filter \$(MACOSX_DEPLOYMENT_TARGET),10.7 10.8))
ifeq (,\$(filter --stdlib=%,\$(CXXFLAGS)))
export CXXFLAGS += --stdlib=libc++
export LDFLAGS += --stdlib=libc++
endif
endif
SDLOTHERCONFIG = --enable-video-opengl --enable-video-opengles $SDLOTHERCONFIG
DEFS = -DMACOSX -DUTF8_CAPTION -DUTF8_FILESYSTEM -DUSE_OGG_VORBIS $OURDEFS
Expand Down Expand Up @@ -996,9 +1005,9 @@ cat >> $MAKEFILE <<_EOF
LIBS = $OURLIBS \\
$LINKSDL2_image \$(if \$(findstring true,$INTERNAL_SDL_IMAGE),$LINKjpeg $LINKpng $LINKz) \\
$LINKSDL2_mixer \$(if \$(findstring true,$INTERNAL_SDL_MIXER$EXPLICIT_OGGLIBS),$LINKvorbisfile $LINKvorbis $LINKogg) \\
\$(shell $SDL_CONFIG --libs) \\
\$(shell $SMPEG_CONFIG --libs) \\
\$(shell $FREETYPE_CONFIG --libs) \\
\$(shell \$(SHELLENV) $SDL_CONFIG --libs) \\
\$(shell \$(SHELLENV) $SMPEG_CONFIG --libs) \\
\$(shell \$(SHELLENV) $FREETYPE_CONFIG --libs) \\
$LINKbz2 \$(if \$(findstring true,$INTERNAL_SDL),$INTERNAL_LDFLAGS)
DEFS = -DLINUX -DUSE_OGG_VORBIS $EXTRA_DEPS $OURDEFS
Expand Down Expand Up @@ -1174,8 +1183,11 @@ export CSTD := -std=c99
export CXXSTD := $CXXSTD
all: $DEFAULTDOC
all: $DEFAULTDOC SRC
SRC:
\$(MAKE) -C $SRC all
.PHONY: SRC
ifdef GAME
include src/Makefile.\$(if \$(wildcard src/Makefile.\$(GAME)),\$(GAME),game)
Expand Down
14 changes: 10 additions & 4 deletions src/Makefile.extlibs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ $(EB)/sdl2-config: $(SDLSRC)/Makefile
fi # Fix for annoying Windows breakage
@chmod +x $(EB)/sdl2-config # for some reason this isn't happening when
@ # cross-compiling to MinGW
@ # We only make a static lib which means things using pkg-config will get it even if they think they're linking to a dynamic lib, breaking their ldflags
@ # Fix this by replacing `Libs: $libs\nLibs.static $staticonly` with `Libs: $libs $staticonly` in the pc file
@ # Note: This assumes Libs.private immediately follows Libs if it exists, which seems to be the case in most pc files that have it but isn't actually a requirement.
@sed -i '' -e ':a' -e 'N' -e '$$!ba' -e 's/\nLibs.private: //g' $(EL)/pkgconfig/sdl2.pc

#-- SDL_image -----------------------------------------------------------------

Expand All @@ -88,9 +92,9 @@ $(SDLISRC)/Makefile: $(if $(INTERNAL_SDL),$(EB)/sdl2-config) \
$(if $(INTERNAL_LIBPNG),$(EL)/libpng$(LIBSUFFIX)) \
$(if $(INTERNAL_LIBJPEG),$(EL)/libjpeg$(LIBSUFFIX))
@echo Configuring internal SDL_image...
@cd $(SDLISRC) && \
@cd $(SDLISRC) && ./autogen.sh && \
./configure --prefix="$(LPREFIX)" $(OTHERCONFIG) \
$(addprefix --disable-,shared lbm pcx pnm tga xcf xv tif \
$(addprefix --disable-,shared lbm pcx pnm tga xcf xv tif webp \
$(if $(INTERNAL_LIBPNG),png-shared) \
$(if $(INTERNAL_LIBJPEG),jpg-shared)) \
$(REDIR)
Expand Down Expand Up @@ -177,9 +181,9 @@ $(OGGSRC)/Makefile:
$(EL)/libogg$(LIBSUFFIX): $(OGGSRC)/Makefile
@echo Building internal libogg...
@$(MAKE) -C $(OGGSRC) $(REDSO)
@$(MAKE) -C $(OGGSRC) install $(REDSO)
@$(MAKE) -C $(OGGSRC) install -j1 $(REDSO)

$(VORBSRC)/Makefile:
$(VORBSRC)/Makefile: $(if $(INTERNAL_OGGLIBS),$(EL)/libogg$(LIBSUFFIX))
@echo Configuring internal libvorbis...
@cd $(VORBSRC) && \
./configure --prefix="$(LPREFIX)" $(addprefix --disable-,shared dependency-tracking docs) $(OTHERCONFIG) $(REDIR)
Expand Down Expand Up @@ -244,6 +248,7 @@ clean_bzip2:
rm -f $(EL)/libbz2$(LIBSUFFIX) $(EI)/bzlib.h $(BZSRC)/*$(OBJSUFFIX)

$(EL)/libbz2$(LIBSUFFIX): $(foreach fn,$(BZOBJS),$(BZSRC)/$(fn)$(OBJSUFFIX))
mkdir -p $(EL)
rm -f $@
$(AR) cq $@ $^
@if [ -f "$(RANLIB)" -o -f /usr/bin/ranlib -o \
Expand All @@ -252,6 +257,7 @@ $(EL)/libbz2$(LIBSUFFIX): $(foreach fn,$(BZOBJS),$(BZSRC)/$(fn)$(OBJSUFFIX))
fi

$(EI)/bzlib.h: $(BZSRC)/bzlib.h
mkdir -p $(EI)
cp $< $@

#-- steam-sdk
Expand Down
10 changes: 5 additions & 5 deletions src/Makefile.ponscripter
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SCRIPTER_H = PonscripterLabel.h PonscripterMessage.h $(PARSER_H) DirtyRect.h

TARGET ?= ponscr$(EXESUFFIX)
$(TARGET): $(PONSCR_OBJS)
$(CXX) -o $@ $(PONSCR_OBJS) $(LIBS)
$(CXX) -o $@ $(PONSCR_OBJS) $(LIBS) $(LDFLAGS)

pclean:
-$(RM) *$(OBJSUFFIX) $(CLEANUP) $(RCCLEAN)
Expand All @@ -58,10 +58,10 @@ pdistclean: pclean
-$(RM) $(TARGET)

.cpp$(OBJSUFFIX):
$(CXX) -c $(CXXSTD) $(PSCFLAGS) $(INCS) $(DEFS) $<
$(CXX) -c $(CXXSTD) $(PSCFLAGS) $(CXXFLAGS) $(INCS) $(DEFS) $<

bstrlib$(OBJSUFFIX): bstrlib.c
$(CC) -c $(CSTD) $(PSCFLAGS) $(INCS) $(DEFS) $<
$(CC) -c $(CSTD) $(PSCFLAGS) $(CFLAGS) $(INCS) $(DEFS) $<

AnimationInfo$(OBJSUFFIX): $(EXTRADEPS) AnimationInfo.h
AVIWrapper$(OBJSUFFIX): $(EXTRADEPS) AVIWrapper.h
Expand Down Expand Up @@ -98,13 +98,13 @@ SarReader$(OBJSUFFIX): SarReader.h DirectReader.h BaseReader.h $(ENCODING_H)
ScriptHandler$(OBJSUFFIX): $(HANDLER_H)
ScriptParser_command$(OBJSUFFIX): $(PARSER_H)
ScriptParser$(OBJSUFFIX): $(PARSER_H)
prng$(OBJSUFFIX): defs.h
prng$(OBJSUFFIX): $(EXTRADEPS) defs.h

resources$(OBJSUFFIX): $(EXTRADEPS) $(RC_HDRS)

resources.cpp: embed$(EXESUFFIX) $(filter-out =%,$(RESOURCES))
./embed$(EXESUFFIX) $(patsubst =%,%,$(RESOURCES)) > $@

embed$(EXESUFFIX): embed.cpp
$(CXX) $(CXXSTD) $(PSCFLAGS) $< -o $@
$(CXX) $(CXXSTD) $(PSCFLAGS) $(CXXFLAGS) $< -o $@

2 changes: 2 additions & 0 deletions src/extlib/src/SDL2_image-2.0.0/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/.libs
/*.lo
/Makefile
/Makefile.in
/aclocal.m4
/libtool
/sdl2_image.pc
/config.log
Expand Down

0 comments on commit bc26c33

Please sign in to comment.