bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
320 stars 66 forks source link

SDL #5

Closed MBeijer closed 6 years ago

MBeijer commented 6 years ago

I noticed that you finally added the SDK SDL. I'm curious of how the SDK install works.

The repository https://github.com/AmigaPorts/libSDL12 has SDL 1.2.15, reworked for AmigaOS3.x with a bunch of bug-fixes over 1.2.6, like fullscreen finally works. As well as AMMX extras working for Vampire cards to get some extra speed with the blitter.

The functioning makefile in this repository is Makefile.bax. The prefix is wrong but the rest should be correct.

The Vampire specific functions are defined in an vasm assembler file, that is compiled with VASM and then included in the gcc linker.

The Apollo/Vampire specifics seem to be in here: https://github.com/AmigaPorts/libSDL12/tree/master/video/apollo

The Apollo/Vampire specifics are designed to only be used if the Apollo based CPU is identified. So it will work on 020, 030, 040 and 060 just as well!

I think Makefile.bax is pretty self explanatory! =)

I need to know how I could implement this in the SDK install process, so we can leave the bug-ridden SDL 1.2.6 from Aminet behind, once and for all!

bebbo commented 6 years ago

You have to make a decision: a) provide a sdk file use this to install precompile binaries b) provide a Makefile snippet this gets added to the Makefile itself. Maybe we find a comfortable way to provide separate Makefiles for such a purpose.

A simple starting point is the integration of libdebug:

# =================================================
# libdebug
# =================================================
CONFIG_LIBDEBUG = --prefix=$(PREFIX) --target=m68k-amigaos --host=m68k-amigaos 

libdebug: build/libdebug/_done

build/libdebug/_done: build/libdebug/Makefile
    cd build/libdebug && $(MAKE)
    cp build/libdebug/libdebug.a $(PREFIX)/m68k-amigaos/lib/
    echo "done" >build/libdebug/_done

build/libdebug/Makefile: build/libnix/Makefile projects/libdebug/configure $(shell find 2>/dev/null projects/libdebug -not \( -path projects/libdebug/.git -prune \) -type f)
    mkdir -p build/libdebug
    cd build/libdebug && $(A) $(PWD)/projects/libdebug/configure $(CONFIG_LIBDEBUG)

projects/libdebug/configure:
    @mkdir -p projects
    cd projects &&  git clone -b master --depth 4 https://github.com/bebbo/libdebug

projects/libdebug/configure is a file which always exists after cloning.

Here is a configure command invoked to create the Makefile in the build folder. Otherwise I use rsync to copy all files.

Then I invoke the makefile and install the files.

bebbo commented 6 years ago

first try:

CONFIG_LIBSDL12 = PREFX=$(PREFIX) PREF=$(PREFIX)  

libSDL12: build/libSDL12/_done

build/libSDL12/_done: build/libSDL12/Makefile.bax
    cd build/libSDL12 && $(MAKE) -f Makefile.bax $(CONFIG_LIBSDL12)
    cp build/libSDL12/libsdl.a $(PREFIX)/m68k-amigaos/lib/
    echo "done" >build/libsdl/_done

build/libSDL12/Makefile.bax: build/libnix/Makefile projects/libSDL12/Makefile.bax $(shell find 2>/dev/null projects/libSDL12 -not \( -path projects/libSDL12/.git -prune \) -type f)
    mkdir -p build/libSDL12
    rsync -a projects/libSDL12/* build/libSDL12 

projects/libSDL12/Makefile.bax:
    @mkdir -p projects
    cd projects &&  git clone -b master --depth 4  https://github.com/AmigaPorts/libSDL12
bebbo commented 6 years ago
./include/SDL_stdinc.h:66:23: fatal error: inttypes.h: No such file or directory
 # include <inttypes.h>
MBeijer commented 6 years ago

I have asked Henryk Richter (author of the libSDL12 repo) to join us in this issue with his input. So please leave this open. :)

MBeijer commented 6 years ago

inttypes.h is always an issue for me with your toolchain, which is why I have added my own inttypes.h file in /opt/m68k-amigaos/include:

/*
 * Copyright (c) 2004, 2005 by
 * Ralf Corsepius, Ulm/Germany. All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * is freely granted, provided that this notice is preserved.
 */

/**
 *  @file  inttypes.h
 */

#ifndef _INTTYPES_H
#define _INTTYPES_H

#include <stdint.h>
#define __need_wchar_t
#include <stdlib.h>

#define __STRINGIFY(a) #a

/* 8-bit types */
#define __PRI8(x) __STRINGIFY(x)
#define __SCN8(x) __STRINGIFY(hh##x)

#define PRId8           __PRI8(d)
#define PRIi8           __PRI8(i)
#define PRIo8           __PRI8(o)
#define PRIu8           __PRI8(u)
#define PRIx8           __PRI8(x)
#define PRIX8           __PRI8(X)

#define SCNd8           __SCN8(d)
#define SCNi8           __SCN8(i)
#define SCNo8           __SCN8(o)
#define SCNu8           __SCN8(u)
#define SCNx8           __SCN8(x)

#define PRIdLEAST8      __PRI8(d)
#define PRIiLEAST8      __PRI8(i)
#define PRIoLEAST8      __PRI8(o)
#define PRIuLEAST8      __PRI8(u)
#define PRIxLEAST8      __PRI8(x)
#define PRIXLEAST8      __PRI8(X)

#define SCNdLEAST8      __SCN8(d)
#define SCNiLEAST8      __SCN8(i)
#define SCNoLEAST8      __SCN8(o)
#define SCNuLEAST8      __SCN8(u)
#define SCNxLEAST8      __SCN8(x)

#define PRIdFAST8       __PRI8(d)
#define PRIiFAST8       __PRI8(i)
#define PRIoFAST8       __PRI8(o)
#define PRIuFAST8       __PRI8(u)
#define PRIxFAST8       __PRI8(x)
#define PRIXFAST8       __PRI8(X)

#define SCNdFAST8       __SCN8(d)
#define SCNiFAST8       __SCN8(i)
#define SCNoFAST8       __SCN8(o)
#define SCNuFAST8       __SCN8(u)
#define SCNxFAST8       __SCN8(x)

/* 16-bit types */
#define __PRI16(x) __STRINGIFY(x)
#define __SCN16(x) __STRINGIFY(h##x)

#define PRId16          __PRI16(d)
#define PRIi16          __PRI16(i)
#define PRIo16          __PRI16(o)
#define PRIu16          __PRI16(u)
#define PRIx16          __PRI16(x)
#define PRIX16          __PRI16(X)

#define SCNd16          __SCN16(d)
#define SCNi16          __SCN16(i)
#define SCNo16          __SCN16(o)
#define SCNu16          __SCN16(u)
#define SCNx16          __SCN16(x)

#define PRIdLEAST16     __PRI16(d)
#define PRIiLEAST16     __PRI16(i)
#define PRIoLEAST16     __PRI16(o)
#define PRIuLEAST16     __PRI16(u)
#define PRIxLEAST16     __PRI16(x)
#define PRIXLEAST16     __PRI16(X)

#define SCNdLEAST16     __SCN16(d)
#define SCNiLEAST16     __SCN16(i)
#define SCNoLEAST16     __SCN16(o)
#define SCNuLEAST16     __SCN16(u)
#define SCNxLEAST16     __SCN16(x)

#define PRIdFAST16      __PRI16(d)
#define PRIiFAST16      __PRI16(i)
#define PRIoFAST16      __PRI16(o)
#define PRIuFAST16      __PRI16(u)
#define PRIxFAST16      __PRI16(x)
#define PRIXFAST16      __PRI16(X)

#define SCNdFAST16      __SCN16(d)
#define SCNiFAST16      __SCN16(i)
#define SCNoFAST16      __SCN16(o)
#define SCNuFAST16      __SCN16(u)
#define SCNxFAST16      __SCN16(x)

/* 32-bit types */
#if __have_long32
#define __PRI32(x) __STRINGIFY(l##x)
#define __SCN32(x) __STRINGIFY(l##x)
#else
#define __PRI32(x) __STRINGIFY(x)
#define __SCN32(x) __STRINGIFY(x)
#endif

#define PRId32          __PRI32(d)
#define PRIi32          __PRI32(i)
#define PRIo32          __PRI32(o)
#define PRIu32          __PRI32(u)
#define PRIx32          __PRI32(x)
#define PRIX32          __PRI32(X)

#define SCNd32          __SCN32(d)
#define SCNi32          __SCN32(i)
#define SCNo32          __SCN32(o)
#define SCNu32          __SCN32(u)
#define SCNx32          __SCN32(x)

#define PRIdLEAST32     __PRI32(d)
#define PRIiLEAST32     __PRI32(i)
#define PRIoLEAST32     __PRI32(o)
#define PRIuLEAST32     __PRI32(u)
#define PRIxLEAST32     __PRI32(x)
#define PRIXLEAST32     __PRI32(X)

#define SCNdLEAST32     __SCN32(d)
#define SCNiLEAST32     __SCN32(i)
#define SCNoLEAST32     __SCN32(o)
#define SCNuLEAST32     __SCN32(u)
#define SCNxLEAST32     __SCN32(x)

#define PRIdFAST32      __PRI32(d)
#define PRIiFAST32      __PRI32(i)
#define PRIoFAST32      __PRI32(o)
#define PRIuFAST32      __PRI32(u)
#define PRIxFAST32      __PRI32(x)
#define PRIXFAST32      __PRI32(X)

#define SCNdFAST32      __SCN32(d)
#define SCNiFAST32      __SCN32(i)
#define SCNoFAST32      __SCN32(o)
#define SCNuFAST32      __SCN32(u)
#define SCNxFAST32      __SCN32(x)

/* 64-bit types */
#if __have_longlong64
#define __PRI64(x) __STRINGIFY(ll##x)
#define __SCN64(x) __STRINGIFY(ll##x)
#elif __have_long64
#define __PRI64(x) __STRINGIFY(l##x)
#define __SCN64(x) __STRINGIFY(l##x)
#else
#define __PRI64(x) __STRINGIFY(x)
#define __SCN64(x) __STRINGIFY(x)
#endif

#define PRId64          __PRI64(d)
#define PRIi64          __PRI64(i)
#define PRIo64          __PRI64(o)
#define PRIu64          __PRI64(u)
#define PRIx64          __PRI64(x)
#define PRIX64          __PRI64(X)

#define SCNd64          __SCN64(d)
#define SCNi64          __SCN64(i)
#define SCNo64          __SCN64(o)
#define SCNu64          __SCN64(u)
#define SCNx64          __SCN64(x)

#if __int64_t_defined
#define PRIdLEAST64     __PRI64(d)
#define PRIiLEAST64     __PRI64(i)
#define PRIoLEAST64     __PRI64(o)
#define PRIuLEAST64     __PRI64(u)
#define PRIxLEAST64     __PRI64(x)
#define PRIXLEAST64     __PRI64(X)

#define SCNdLEAST64     __SCN64(d)
#define SCNiLEAST64     __SCN64(i)
#define SCNoLEAST64     __SCN64(o)
#define SCNuLEAST64     __SCN64(u)
#define SCNxLEAST64     __SCN64(x)

#define PRIdFAST64      __PRI64(d)
#define PRIiFAST64      __PRI64(i)
#define PRIoFAST64      __PRI64(o)
#define PRIuFAST64      __PRI64(u)
#define PRIxFAST64      __PRI64(x)
#define PRIXFAST64      __PRI64(X)

#define SCNdFAST64      __SCN64(d)
#define SCNiFAST64      __SCN64(i)
#define SCNoFAST64      __SCN64(o)
#define SCNuFAST64      __SCN64(u)
#define SCNxFAST64      __SCN64(x)
#endif

/* max-bit types */
#if __have_longlong64
#define __PRIMAX(x) __STRINGIFY(ll##x)
#define __SCNMAX(x) __STRINGIFY(ll##x)
#elif __have_long64
#define __PRIMAX(x) __STRINGIFY(l##x)
#define __SCNMAX(x) __STRINGIFY(l##x)
#else
#define __PRIMAX(x) __STRINGIFY(x)
#define __SCNMAX(x) __STRINGIFY(x)
#endif

#define PRIdMAX         __PRIMAX(d)
#define PRIiMAX         __PRIMAX(i)
#define PRIoMAX         __PRIMAX(o)
#define PRIuMAX         __PRIMAX(u)
#define PRIxMAX         __PRIMAX(x)
#define PRIXMAX         __PRIMAX(X)

#define SCNdMAX         __SCNMAX(d)
#define SCNiMAX         __SCNMAX(i)
#define SCNoMAX         __SCNMAX(o)
#define SCNuMAX         __SCNMAX(u)
#define SCNxMAX         __SCNMAX(x)

/* ptr types */
#if __have_longlong64
#define __PRIPTR(x) __STRINGIFY(ll##x)
#define __SCNPTR(x) __STRINGIFY(ll##x)
#elif __have_long64
#define __PRIPTR(x) __STRINGIFY(l##x)
#define __SCNPTR(x) __STRINGIFY(l##x)
#else
#define __PRIPTR(x) __STRINGIFY(x)
#define __SCNPTR(x) __STRINGIFY(x)
#endif

#define PRIdPTR         __PRIPTR(d)
#define PRIiPTR         __PRIPTR(i)
#define PRIoPTR         __PRIPTR(o)
#define PRIuPTR         __PRIPTR(u)
#define PRIxPTR         __PRIPTR(x)
#define PRIXPTR         __PRIPTR(X)

#define SCNdPTR         __SCNPTR(d)
#define SCNiPTR         __SCNPTR(i)
#define SCNoPTR         __SCNPTR(o)
#define SCNuPTR         __SCNPTR(u)
#define SCNxPTR         __SCNPTR(x)

typedef struct {
  intmax_t      quot;
  intmax_t      rem;
} imaxdiv_t;

#ifdef __cplusplus
extern "C" {
#endif

extern intmax_t  imaxabs(intmax_t j);
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
extern intmax_t  strtoimax(const char *__restrict, char **__restrict, int);
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
extern intmax_t  wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);

#ifdef __cplusplus
}
#endif

#endif
MBeijer commented 6 years ago

I believe I've mentioned this before, but been told I've done something wrong. Eventually I just added the file myself.

It's required for me to compile MilkyTracker as well.

MBeijer commented 6 years ago

I don't know how much of this file is actually needed.

bebbo commented 6 years ago

I'll add it to ixemul --> ends up in sys-includes

next:

ideo/amigaos/SDL_cgxvideo.c:40:41: fatal error: cybergraphics/cybergraphics.h: No such file or directory
 #include <cybergraphics/cybergraphics.h>

it depends on the cgx.sdk

bebbo commented 6 years ago

but there it is CGraphX/C/Include/cybergraphx/cybergraphics.h

MBeijer commented 6 years ago

Yeah, for some reason the include path for cybergraphics has changed between cybergraphx and cybergraphics between generations. While one is still used in MorphOS, another is used in your toolchain. And depending on source I've been working with it's been switched around. Pretty stupid. How does the toolchain handle symlinks?

bebbo commented 6 years ago

if symlinks exists, they are used :-) I could add symlink creation to sdk install

bebbo commented 6 years ago

next one:

-I/opt/amiga/os-include

should be /$(PREFX)/m68k-amigaos/sys-include

no?

MBeijer commented 6 years ago

yup, it differs on older GCC toolchains, especially if you use the old gg toolchain in Workbench

MBeijer commented 6 years ago

I added you to the SDL team on AmigaPorts. Feel free to make changes to the libSDL12 repo.

bebbo commented 6 years ago

I will look tomorrow - I pushed what I already did.

bebbo commented 6 years ago

make libSDL12 is built now.

But the headers are currently not installed, because I don't like the fact that all headers are duplicated. I'd prefer having the SDL headers in the SDL folder.

MBeijer commented 6 years ago

Yeah, I don't know why that is like that. I have to ask Henryk about this.

On Sun, Feb 11, 2018 at 12:49 PM, bebbo notifications@github.com wrote:

make libSDL12 is built now.

But the headers are currently not installed, because I don't like the fact that all headers are duplicated. I'd prefer having the SDL headers in the SDL folder.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bebbo/amiga-gcc/issues/5#issuecomment-364745620, or mute the thread https://github.com/notifications/unsubscribe-auth/AIXahVLEScN2Ru8GLZuj0GStnbt1ADtPks5tTtO6gaJpZM4R_HVr .

HenrykRichter commented 6 years ago

I knew that this thing would be going to haunt me. Yes, you both are absolutely right. There are redundant files in this particular Amiga SDL port. I didn't find time and motivation to clean the source up, as of yet.

FWIW, I've deleted the superfluous includes and kept only the SDL subdirectory. The lib builds just as fine. As Bebbo pointed out, inttypes.h is not really necessary to build SDL itself. Hence, it is disabled now in SDL_config_amigaos.h.

Hope it helps along a little.

MBeijer commented 6 years ago

Thanks for that! :)

Bebbo: One request I have is that I'd like it if the SDL includes ends up in /opt/m68k-amigaos/include/ SDL/ rather than /opt/m68k-amigaos/m68k-amigaos/include/ so system specific includes doesn't get mixed in with ported libs and such.

bebbo commented 6 years ago

now the SDL and GL folders are copied.

MBeijer commented 6 years ago

As a side-note, I intend to apply the fixes from the libSDL12 repo to the AmigaPorts/SDL repo. When it's time to switch I'll let you know. Until then libSDL12 serves its purpose.

MBeijer commented 6 years ago

Awesome, thank you! :) 👍

MBeijer commented 6 years ago

Make-script fails at libSDL12:

make[2]: Leaving directory '/home/marlon/tmp/Programming/Amiga/Tools/amiga-gcc'
make[1]: Leaving directory '/home/marlon/tmp/Programming/Amiga/Tools/amiga-gcc'
cd build/libSDL12 && "CFLAGS=-Os -g -fomit-frame-pointer" make -f Makefile.bax PREFX=/opt/m68k-amigaos PREF=/opt/m68k-amigaos
/bin/bash: CFLAGS=-Os -g -fomit-frame-pointer: command not found
make: *** [Makefile:623: build/libSDL12/_done] Error 127
MBeijer commented 6 years ago

Simply moving the first " from "CFLAGS= to CFLAGS=" fixes this.

bebbo commented 6 years ago

... happens :-)

bebbo commented 6 years ago

what's left to do here?

MBeijer commented 6 years ago

Nothing until we're/I'm done merging the libSDL12 repo into the AmigaPorts/SDL/SDL-1.2 branch, which is a lot of manual work!

bebbo commented 6 years ago

reopened if necessary

arczi84 commented 5 years ago

"Fire-0.3" demo from https://su2.info/demos/ displays only half of particles on the screen. Tried various -O flags with same result. Works on older gcc's.