Por lo pronto puedo compilar, sin problemas para Windows y Nintendo DS, obteniendo un ejecutable completamente funcional al final en ambas plataformas. Mi problema viene con Linux.
Como más arriba he indicado, estoy usando Makefiles para la compilación en Linux y Nintendo DS, los Makefiles son bastante similares (basicamente un Makefile y otro son copias con cambios en cosas como librerias, carpetas de inclusión, etc) y en principio están correctos, sin embargo, no consigo que enlace las 3 partes de mi proyecto (libreria base, renderizador y codigo del juego) junto a SDL para generar el binario final.
En mi máquina de desarrollo estoy usando Ubuntu 14.04 y he instalado los paquetes necesarios de SDL 1.2 para desarrollo, de hecho tengo todas las librerias instaladas correctamente, y libSDL.so existe. Estas son las líneas generadas por el Makefile a la hora de generar el código y binario final:
Compilación de la primera librería
Código:
gcc -MMD -MP -MF /home/almamu/Escritorio/smash_tmp/smash/nflib/build/video.d -g -Wall -O2 -fomit-frame-pointer -ffast-math -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/win/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/build -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__UNIXBUILD -Wno-unused-result -c /home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c -o video.o
Generacion de la primera libreria estatica
Código:
ar -rc /home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a nf_2d.o nf_3d.o nf_affinebg.o nf_basic.o nf_bitmapbg.o nf_colision.o nf_media.o nf_mixedbg.o nf_sound.o nf_sprite256.o nf_sprite3d.o nf_text16.o nf_text.o nf_tiledbg.o dswifi9.o nitrofs.o debugprint.o console.o keys.o video.o
Compilación de la segunda libreria
Código:
g++ -MMD -MP -MF /home/almamu/Escritorio/smash_tmp/smash/render/build/graphics.d -g -Wall -O2 -fomit-frame-pointer -ffast-math -I/home/almamu/Escritorio/smash_tmp/smash/render/include -I/home/almamu/Escritorio/smash_tmp/smash/render/win/include -I/home/almamu/Escritorio/smash_tmp/smash/core/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/win/include -I/home/almamu/Escritorio/smash_tmp/smash/render/build -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__UNIXBUILD -Wno-unused-result -fno-rtti -fno-exceptions -std=c++11 -c /home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp -o graphics.o
Generacion de la segunda libreria estatica
Código:
ar -rc /home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a graphics.o
Compilacion del codigo fuente del juego
Código:
g++ -MMD -MP -MF /home/almamu/Escritorio/smash_tmp/smash/core/build/strings.d -g -Wall -O2 -fomit-frame-pointer -ffast-math -Wformat=0 -I/home/almamu/Escritorio/smash_tmp/smash/core/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/render/include -I/home/almamu/Escritorio/smash_tmp/smash/render/include -I/home/almamu/Escritorio/smash_tmp/smash/render/win/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/include -I/home/almamu/Escritorio/smash_tmp/smash/nflib/win/include -I/home/almamu/Escritorio/smash_tmp/smash/core/build -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D__UNIXBUILD -fno-rtti -fno-exceptions -fpermissive -std=c++11 -c /home/almamu/Escritorio/smash_tmp/smash/core/source/strings.cpp -o strings.o
Enlazado de todo el proyecto
Código:
g++ -g -Wl,-Map,core.map -L/usr/lib/x86_64-linux-gnu -lSDL assets.o battle.o client.o cmap.o common.o events.o filesystem.o input.o main.o memory.o messages.o mvars.o network.o server.o strings.o -L/home/almamu/Escritorio/smash_tmp/smash/nflib/lib -L/home/almamu/Escritorio/smash_tmp/smash/render/lib -lrender -lnflib -o /home/almamu/Escritorio/smash_tmp/smash/core/core.elf
Como se puede observar en el enlazado final incluyo todas las librerias necesarias para la compilación del juego, sin embargo, lo único que obtengo son un montón de errores de referencias sin definir que me impiden acabar la compilación del proyecto:
Código:
/home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a(graphics.o): En la función `R_PrecacheBackground(assetHeader_t*, unsigned char, unsigned char, bool)':
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:492: referencia a `SDL_CreateRGBSurface' sin definir
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:514: referencia a `SDL_CreateRGBSurfaceFrom' sin definir
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:515: referencia a `SDL_UpperBlit' sin definir
/home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a(graphics.o): En la función `R_UpdateBackground(background_t*)':
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:568: referencia a `SDL_UpperBlit' sin definir
/home/almamu/Escritorio/smash_tmp/smash/render/lib/librender.a(graphics.o): En la función `R_SetBackgroundVisibility(unsigned char, unsigned char, bool)':
/home/almamu/Escritorio/smash_tmp/smash/render/win/source/graphics.cpp:599: referencia a `SDL_FillRect' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(nf_2d.o): En la función `NF_Set2D(unsigned char, unsigned char)':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/nf_2d.cpp:31: referencia a `SDL_MapRGB' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/nf_2d.cpp:31: referencia a `SDL_FillRect' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(nf_tiledbg.o): En la función `NF_ResetTiledBgBuffers()':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/nf_tiledbg.cpp:98: referencia a `SDL_FreeSurface' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(keys.o): En la función `scanKeys':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/keys.c:22: referencia a `SDL_PollEvent' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/keys.c:153: referencia a `SDL_Quit' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/keys.c:22: referencia a `SDL_PollEvent' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(video.o): En la función `defaultExceptionHandler':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:75: referencia a `SDL_Init' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:81: referencia a `SDL_SetVideoMode' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:87: referencia a `SDL_EnableUNICODE' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:88: referencia a `SDL_WM_SetCaption' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:94: referencia a `SDL_MapRGB' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:95: referencia a `SDL_SetColorKey' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:102: referencia a `SDL_CreateRGBSurface' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:103: referencia a `SDL_SetColorKey' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:108: referencia a `SDL_CreateRGBSurface' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:111: referencia a `SDL_FillRect' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:112: referencia a `SDL_SetColorKey' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/lib/libnflib.a(video.o): En la función `swiWaitForVBlank':
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:150: referencia a `SDL_UpperBlit' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:163: referencia a `SDL_UpperBlit' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:167: referencia a `SDL_Flip' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:175: referencia a `SDL_FillRect' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:184: referencia a `SDL_GetTicks' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:189: referencia a `SDL_Delay' sin definir
/home/almamu/Escritorio/smash_tmp/smash/nflib/win/source/libnds/nds/arm9/video.c:192: referencia a `SDL_GetTicks' sin definir
Estos son los ficheros de Makefile involucrados en la compilación del proyecto:
Rules.linux
Código:
# --------------------------------------
# COMPILER DEFINITIONS
# --------------------------------------
export MKFILE_PATH = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export BRANCH_NAME = $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH))))
export DST_PLATFORM = UNIX
export PLATFORM_DEF = __$(DST_PLATFORM)BUILD
# --------------------------------------
# BINARIES CONFIGURATION
# --------------------------------------
export LIB_EXTENSION = a
export EXE_EXTENSION = out
export OUT_EXTENSION = elf
# --------------------------------------
# SDL config
# --------------------------------------
export SDL_CFLAGS = $(shell sdl-config --cflags)
export SDL_DFLAGS = $(shell sdl-config --libs)
# --------------------------------------
# NFLIB config
# --------------------------------------
export NFLIB_NAME = nflib
export NFLIB_DIR = $(MKFILE_PATH)$(NFLIB_NAME)
export NFLIB_LIB = $(NFLIB_DIR)/lib
export NFLIB_INC = include win/include
export NFLIB_EXTENSION = $(LIB_EXTENSION)
# --------------------------------------
# RENDER config
# --------------------------------------
export RENDER_NAME = render
export RENDER_DIR = $(MKFILE_PATH)$(RENDER_NAME)
export RENDER_INC = include win/include
export RENDER_LIB = $(RENDER_DIR)/lib
export RENDER_EXTENSION = $(LIB_EXTENSION)
# --------------------------------------
# GAME config
# --------------------------------------
export GAME_INC = include
export GAME_NAME = core
export GAME_DIR = $(MKFILE_PATH)$(GAME_NAME)
export GAME_EXTENSION = $(EXE_EXTENSION)
# --------------------------------------
# MAKE util
# --------------------------------------
export MAKE = make -C
export MAKEFILE = Makefile.linux
# --------------------------------------
# BUILD utils
# --------------------------------------
export PREFIX :=
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AS := $(PREFIX)as
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
export STRIP := $(PREFIX)strip
export NM := $(PREFIX)nm
ISVC=$(or $(VCBUILDHELPER_COMMAND),$(MSBUILDEXTENSIONSPATH32),$(MSBUILDEXTENSIONSPATH))
ifneq (,$(ISVC))
ERROR_FILTER := 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/g'
endif
# --------------------------------------
# DEBUG utils
# --------------------------------------
# --------------------------------------
# BUILD rules
# --------------------------------------
%.a:
@echo $(notdir $@)
@rm -f $@
$(AR) -rc $@ $^
%.o: %.cpp
@echo $(notdir $<)
$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
# --------------------------------------
%.o: %.c
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
# --------------------------------------
%.o: %.m
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(OBJCFLAGS) -c $< -o $@ $(ERROR_FILTER)
# --------------------------------------
%.o: %.s
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
# --------------------------------------
%.o: %.S
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
# --------------------------------------
%.elf:
@echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
Makefile.linux general
Código:
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
# --------------------------------------
# SYSTEM DEFINITIONS
# --------------------------------------
include Rules.linux
# --------------------------------------
# NORMAL MAKE EXECUTION
# --------------------------------------
.PHONY: run debug nflib render clean game omitnflib omitrender cleanrender cleannflib cleangame
all: nflib render game
omitnflib: render game
omitrender: game
# --------------------------------------
# NFLIB COMPILATION
# --------------------------------------
nflib:
@echo NFLIB
@$(MAKE) $(NFLIB_DIR) -f $(MAKEFILE) clean
@$(MAKE) $(NFLIB_DIR) -f $(MAKEFILE)
# --------------------------------------
# RENDER COMPILATION
# --------------------------------------
render:
@echo RENDER
@$(MAKE) $(RENDER_DIR) -f $(MAKEFILE) clean all
# --------------------------------------
# GAME COMPILATION
# --------------------------------------
game:
@echo GAME
@$(MAKE) $(GAME_DIR) -f $(MAKEFILE)
# --------------------------------------
# FULL PROJECT CLEAN
# --------------------------------------
clean: cleanrender cleannflib cleangame
cleanrender:
@$(MAKE) $(RENDER_DIR) -f $(MAKEFILE) clean
cleannflib:
@$(MAKE) $(NFLIB_DIR) -f $(MAKEFILE) clean
cleangame:
@$(MAKE) $(GAME_DIR) -f $(MAKEFILE) clean
# --------------------------------------
# PROJECT TESTING PURPOSES
# --------------------------------------
run: debug
debug:
@$(MAKE) $(GAME_DIR) -f $(MAKEFILE) run
# --------------------------------------
# PROJECT DEBUG UTILS LAUNCHING
# --------------------------------------
addr2line:
@$(A2L) $(A2L_FLAGS)
Makefile.linux de la primera libreria
Código:
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
include $(MKFILE_PATH)Rules.linux
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := $(NFLIB_NAME)
BUILD := build
SOURCES := win/source win/source/libnds win/source/libnds/nds win/source/libnds/nds/arm9
DATA := data
INCLUDES := $(NFLIB_INC)
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -Wall -O2\
-fomit-frame-pointer -ffast-math \
CFLAGS += $(INCLUDE) -D$(PLATFORM_DEF) -Wno-unused-result
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -Wl,-Map,$(notdir $*.map)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) $(SDL_CFLAGS)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
lib:
@[ -d $@ ] || mkdir -p $@
$(BUILD): lib
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/$(MAKEFILE)
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) lib
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
Makefile.linux de la segunda libreria
Código:
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
include $(MKFILE_PATH)Rules.linux
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := $(RENDER_NAME)
BUILD := build
SOURCES := win/source
DATA := data
INCLUDES := $(RENDER_INC)
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -Wall -O2\
-fomit-frame-pointer -ffast-math \
CFLAGS += $(INCLUDE) -D$(PLATFORM_DEF) -Wno-unused-result
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -Wl,-Map,$(notdir $*.map)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS) $(GAME_DIR)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(NFLIB_INC),-I$(NFLIB_DIR)/$(dir)) \
-I$(CURDIR)/$(BUILD) $(SDL_CFLAGS)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
lib:
@[ -d $@ ] || mkdir -p $@
$(BUILD): lib
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/$(MAKEFILE)
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) lib
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
Makefile.linux del codigo del juego (makefile final)
Código:
#---------------------------------------------------------------------------------
# Makefile for NightFox's Lib Projects
# Modified By Almamu
#
# Changelog:
# Support for paths defined from superior Makefiles added
# This should make the compilation more dynamic and easy to maintain
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
# Compilation Options
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
include $(MKFILE_PATH)Rules.linux
#---------------------------------------------------------------------------------
%.nds: %.elf
@ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES)
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.elf:
@echo linking $(notdir $@)
$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
#---------------------------------------------------------------------------------
TARGET := $(GAME_NAME)
BUILD := build
SOURCES := source
INCLUDES := $(GAME_INC)
DATA := data
GRAPHICS := gfx
NITRODATA := nitrofiles
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -Wall -O2 -fomit-frame-pointer\
-ffast-math -Wformat=0
CFLAGS += $(INCLUDE) -D$(PLATFORM_DEF)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fpermissive -std=c++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) $(SDL_DFLAGS)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -l$(RENDER_NAME) -l$(NFLIB_NAME)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS) $(NFLIB_DIR) $(RENDER_DIR)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
ifneq ($(strip $(NITRODATA)),)
export NITRO_FILES := $(CURDIR)/$(NITRODATA)
endif
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(addsuffix .o,$(PNGFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(GAME_DIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(RENDER_INC),-I$(RENDER_DIR)/$(dir)) \
$(foreach dir,$(NFLIB_INC),-I$(NFLIB_DIR)/$(dir)) \
-I$(CURDIR)/$(BUILD) $(SDL_CFLAGS)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
icons := $(wildcard *.bmp)
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
else
ifneq (,$(findstring icon.bmp,$(icons)))
export GAME_ICON := $(CURDIR)/icon.bmp
endif
endif
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/$(MAKEFILE)
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
La única duda que me asalta (y que básicamente me impide acabar) es el porque la libreria SDL, a pesar de que es enlazada correctamente, sigo teniendo referencias perdidas.
Antes de nada, a quien se tome las molestias de responder, gracias. Llevo varios días con esto y no doy con el problema...