# Makefile for applications/3pp/SDL-1.2.5

### Requires these modules

REQUIRES += link/3pp/xfree86


### Component specification

COMPONENT_TARGETS = $(TARGET_NAME_VIP)
COMPONENT_IS_3PP = true
NEEDS_ABS_PATHS = true


### Tar archive

tar_archive       = $(CURDIR)/SDL-1.2.5.tar.gz
src_dir           = $(CURDIR)/$(TARGET)/SDL-1.2.5
obj_dir           = $(CURDIR)/$(TARGET)/build

patches += $(CURDIR)/sdl-config.in.patch
patches += $(CURDIR)/sdl.patch
patches += $(CURDIR)/sdlx11.patch
patches += $(CURDIR)/xdbe.patch
patches += $(CURDIR)/config.sub.patch


### Targets

bin_targets += sdl-config
BIN_TARGETS = $(patsubst %,$(obj_dir)/%,$(bin_targets))

lib_targets += libSDL.so
lib_targets += libSDL-1.2.so.0
lib_targets += libSDL-1.2.so.0.0.5
LIB_TARGETS = $(patsubst %,$(obj_dir)/src/.libs/%,$(lib_targets))

INTERFACE_LIBS = SDL

headers += begin_code.h
headers += close_code.h
headers += SDL.h
headers += SDL_active.h
headers += SDL_audio.h
headers += SDL_byteorder.h
headers += SDL_cdrom.h
headers += SDL_copying.h
headers += SDL_endian.h
headers += SDL_error.h
headers += SDL_events.h
headers += SDL_getenv.h
headers += SDL_joystick.h
headers += SDL_keyboard.h
headers += SDL_keysym.h
headers += SDL_main.h
headers += SDL_mouse.h
headers += SDL_mutex.h
headers += SDL_name.h
headers += SDL_opengl.h
headers += SDL_quit.h
headers += SDL_rwops.h
headers += SDL_syswm.h
headers += SDL_timer.h
headers += SDL_thread.h
headers += SDL_types.h
headers += SDL_version.h
headers += SDL_video.h


INTERFACE_HEADERS += $(patsubst %,$(src_dir)/include/%,$(headers))
INTERFACE_OMIT_SOURCE_DIR = yes

DOC_TARGETS = $(src_dir)/COPYING
DOC_OMIT_SOURCE_DIR = yes
DOC_PATH = ../../doc/doc

### Extra cleanup

CLEANUP_FILES += $(src_dir) $(obj_dir)


### Common.mk

include ../../../makesystem/common.mk


### Dependencies

# We need to patch the sdl-config file a bit; otherwise it only returns
# -lSDL when asked about libs, and most other 3pps require that also
# -lX11 and so on is returned
$(src_dir): $(tar_archive) $(patches)
	@echo "Expanding $^"
	@rm -rf $(TARGET)
	@mkdir -p $(TARGET)
	@cd $(TARGET) && tar xfz $(tar_archive)
	@cd $(src_dir) && patch -p1 < $(CURDIR)/sdl-config.in.patch
	@cd $(src_dir) && patch -p1 < $(CURDIR)/sdl.patch
	@cd $(src_dir) && patch -p1 < $(CURDIR)/sdlx11.patch
	@cd $(src_dir) && patch -p1 < $(CURDIR)/xdbe.patch
	@cd $(src_dir) && patch -p1 < $(CURDIR)/config.sub.patch
	@touch $@

$(obj_dir)/Makefile: $(src_dir)
	@rm -rf $(obj_dir)
	@mkdir -p $(obj_dir)
	@cd $(obj_dir) && \
		$(BSG_DEVSETUP) $(src_dir)/configure \
			--build=$(ARCH_BUILD) \
			--host=$(TARGET_ARCH) \
			--target=$(TARGET_ARCH) \
			--prefix=$(TARGET_3PP_DIST_DIR) \
			--with-gnu-ld \
			--disable-debug \
			--disable-cdrom \
			--disable-oss \
			--disable-alsa \
			--disable-esd \
			--disable-arts \
			--disable-nas \
			--disable-diskaudio \
			--disable-mintaudio \
			--disable-video-dga \
			--disable-video-photon \
			--disable-video-fbcon \
			--disable-video-directfb \
			--disable-video-ps2gs \
			--disable-video-xbios \
			--disable-video-gem \
			--disable-video-opengl \
			--disable-video-directfb \
			--with-x \
			--disable-dga \
			--x-includes=$(TARGET_3PP_DIST_DIR)/include \
			--x-libraries=$(TARGET_3PP_DIST_DIR)/lib

$(LIB_TARGETS): $(obj_dir)/Makefile
	$(BSG_DEVSETUP) $(MAKE) -C $(obj_dir) 

$(BIN_TARGETS): $(LIB_TARGETS)

$(INTERFACE_HEADERS): $(src_dir)
