add make install and tolling similar to x48ng's

This commit is contained in:
Gwenhael Le Moine 2024-04-15 13:40:10 +02:00
parent 6503b906da
commit 87765b2b92
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
17 changed files with 56 additions and 25 deletions

View file

@ -1,3 +1,6 @@
PREFIX = /usr
DOCDIR = $(PREFIX)/doc/hpemu
CC = gcc
LIBS = $(shell pkg-config --libs sdl2 SDL2_ttf)
CFLAGS = -Wall -Werror -O3 -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=missing-braces -Wno-error=incompatible-pointer-types
@ -22,11 +25,6 @@ dist/hpemu: src/bus.o \
src/timers.o
$(CC) $(CFLAGS) $(LIBS) -o $@ $+
# Installing
get-roms:
make -C ROMs get-roms
# Cleaning
clean:
-rm src/*.o
@ -39,3 +37,23 @@ clean-all: mrproper
# Formatting
pretty-code:
clang-format -i src/*.c src/*.h
# Installing
get-roms:
make -C dist/ROMs get-roms
install: all get-roms
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
install -c -m 755 dist/hpemu $(DESTDIR)$(PREFIX)/bin/hpemu
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/hpemu
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/hpemu/hplogo.png
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/hpemu/
sed "s|@PREFIX@|$(PREFIX)|g" dist/setup-hpemu-home.sh > $(DESTDIR)$(PREFIX)/share/hpemu/setup-hpemu-home.sh
chmod 755 $(DESTDIR)$(PREFIX)/share/hpemu/setup-hpemu-home.sh
install -m 755 -d -- $(DESTDIR)$(DOCDIR)
cp -R ./*.txt $(DESTDIR)$(DOCDIR)
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications
sed "s|@PREFIX@|$(PREFIX)|g" dist/hpemu.desktop > $(DESTDIR)$(PREFIX)/share/applications/hpemu.desktop

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

9
dist/hpemu.desktop vendored Normal file
View file

@ -0,0 +1,9 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=@PREFIX@/bin/hpemu
Name=hpemu
Icon=@PREFIX@/share/hpemu/hplogo.png
Categories=Utility;

BIN
dist/hplogo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

11
dist/setup-hpemu-home.sh vendored Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
DOTHPEMU=${DOTHPEMU:-.config/hpemu}
ROM=${ROM:-gxrom-r}
mkdir -p ~/"${DOTHPEMU}"
[ -e ~/"${DOTHPEMU}"/rom ] && rm ~/"${DOTHPEMU}"/rom
ln -s @PREFIX@/share/hpemu/ROMs/"$ROM" ~/"${DOTHPEMU}"/rom
cd ~/"${DOTHPEMU}"

View file

@ -367,8 +367,8 @@ void rom_init( char* filename )
printf( "ERROR: can't read ROM file\n" );
exit( 0x14 );
}
// pack_fclose(f);
fclose( f );
if ( buf[ 0 ] & 0xF0 || buf[ 1 ] & 0xF0 ) {
if ( size == 1024 * 1024 ) {
printf( "ERROR: wrong ROM\n" );

View file

@ -14,10 +14,8 @@
int rpl_object_size( byte* obj )
{
int size;
int prologue;
int n;
prologue = nib_to_unsigned( obj, 5 );
int prologue = nib_to_unsigned( obj, 5 );
switch ( prologue ) {
@ -85,9 +83,9 @@ int rpl_object_size( byte* obj )
case 0x02A96: // Directory
n = nib_to_unsigned( obj + 8, 5 );
if ( n == 0 ) {
if ( n == 0 )
size = 13;
} else {
else {
size = 8 + n;
size += 4 + 2 * nib_to_unsigned( obj + size, 2 );
size += rpl_object_size( obj + size );
@ -103,9 +101,8 @@ int rpl_object_size( byte* obj )
static address read_address( address adr )
{
byte buf[ 5 ];
word ocrc;
word ocrc = crc;
ocrc = crc;
bus_read( buf, adr, 5 );
crc = ocrc;
@ -123,12 +120,11 @@ static void write_address( address adr, address val )
static int moveup( address src, address dst, address cnt )
{
byte* buf = malloc( cnt * sizeof( byte ) );
word ocrc;
if ( !buf )
return -1;
ocrc = crc;
word ocrc = crc;
bus_read( buf, src, cnt );
bus_write( buf, dst, cnt );
crc = ocrc;
@ -139,14 +135,12 @@ static int moveup( address src, address dst, address cnt )
address rpl_make_temp( address size )
{
address temptop, rsktop, dsktop;
address temptop = read_address( TEMPTOP );
address rsktop = read_address( RSKTOP );
address dsktop = read_address( DSKTOP );
size += 6;
temptop = read_address( TEMPTOP );
rsktop = read_address( RSKTOP );
dsktop = read_address( DSKTOP );
if ( rsktop + size > dsktop )
return 0;
@ -163,24 +157,23 @@ address rpl_make_temp( address size )
void rpl_push( address adr )
{
address dsktop, avmem;
address avmem = read_address( AVMEM );
avmem = read_address( AVMEM );
if ( !avmem )
return;
write_address( AVMEM, avmem - 1 );
dsktop = read_address( DSKTOP );
address dsktop = read_address( DSKTOP );
dsktop -= 5;
write_address( dsktop, adr );
write_address( DSKTOP, dsktop );
}
int rpl_push_object( byte* obj, address size )
{
address adr;
address adr = rpl_make_temp( size );
adr = rpl_make_temp( size );
if ( !adr )
return -1;