Skip to content

Commit

Permalink
Merge pull request #58 from afxgroup/beta3
Browse files Browse the repository at this point in the history
Merged Beta3 into Master
  • Loading branch information
afxgroup authored Jul 13, 2022
2 parents 12bdd25 + 3749b77 commit 63527d9
Show file tree
Hide file tree
Showing 96 changed files with 2,233 additions and 1,101 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*.o
*.a
!libauto.a
*.so
!libs/libauto.a
!libs/libpthread.a
!libs/libpthread.so
*.lha
*.bak
/library/compiler.log
Expand Down
45 changes: 28 additions & 17 deletions GNUmakefile.os4
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SDK_INCLUDE ?= /usr/ppc-amigaos/SDK/include

CC := ppc-amigaos-gcc
AR := ppc-amigaos-ar -q
LD := ppc-amigaos-ld
RANLIB := ppc-amigaos-ranlib

# On AmigaOS use native commands
Expand Down Expand Up @@ -87,13 +88,20 @@ INCLUDES := -I$(LIB_DIR)/include \
-I$(LIB_DIR)/stat \
-I$(LIB_DIR)/mount

OPTIONS := -msdata=data -DHAVE_SYSV -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__CLIB2__ -Wa,-mregnames -fno-builtin -nostdlib
OPTIMIZE := -O2 -mmultiple -mupdate -mstrict-align -DNDEBUG
SHARED := $(if $(SHARED),$(SHARED),yes)
STATIC := $(if $(STATIC),$(STATIC),yes)

DEBUG := -gstabs #-DDEBUG
OPTIONS := -msdata=data -DHAVE_SYSV -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__CLIB2__ -Wa,-mregnames -fno-builtin -nostdlib
OPTIMIZE := -O2 -mmultiple -mupdate -mstrict-align

CFLAGS := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(MEMDEBUG) $(OPTIONS) $(INCLUDES) -D__USE_INLINE__
CFLAGS_N := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(MEMDEBUG) $(OPTIONS) $(INCLUDES)
ifndef DEBUG
OPTIMIZE := $(OPTIMIZE) -DNDEBUG
else
OPTIMIZE := $(OPTIMIZE) -gstabs -DDEBUG
endif

CFLAGS := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES) -D__USE_INLINE__
CFLAGS_N := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES)
AFLAGS := $(COMPILER_VERSION) -Wa,-mregnames

VERBOSE := @
Expand All @@ -102,17 +110,17 @@ VERBOSE := @

# This is the first target: it depends on all the targets

all: prepare all-targets
all: prepare all-targets all-libs

##############################################################################

# The LIBS variable is updated by each of the included library makefiles.

LIBS :=
MAIN_LIB:=

include libc.gmk
include libm.gmk
include libdebug.gmk
include libamiga.gmk
include libprofile.gmk
include libresolv.gmk
Expand All @@ -127,7 +135,10 @@ all-targets: \
$(OUTPUT_LIB)/crtend.o \
$(OUTPUT_LIB)/shcrtbegin.o \
$(OUTPUT_LIB)/shcrtend.o \
$(LIBS)
$(MAIN_LIB)
$(info $(MAIN_LIB))

all-libs: $(LIBS)

##############################################################################

Expand All @@ -145,13 +156,11 @@ clean:
# Update the version numbers bound to the individual libraries
version:
$(COPY) c.lib_rev.rev amiga.lib_rev.rev
$(COPY) c.lib_rev.rev debug.lib_rev.rev
$(COPY) c.lib_rev.rev profile.lib_rev.rev
$(COPY) c.lib_rev.rev m.lib_rev.rev
$(COPY) c.lib_rev.rev resolv.lib_rev.rev
bumprev amiga.lib
bumprev c.lib
bumprev debug.lib
bumprev profile.lib
bumprev m.lib
bumprev resolv.lib
Expand All @@ -170,27 +179,27 @@ $(OUTPUT_LIB)/%.o : %.c

$(OUTPUT_LIB)/crt0.o : $(LIB_DIR)/crt0.S
$(VERBOSE)$(ASSEMBLE)
$(COPY) $(OUTPUT_LIB)/crt0.o $(INSTALL_PREFIX)/lib/
-$(COPY) $(OUTPUT_LIB)/crt0.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/crtbegin.o : CFLAGS += -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtbegin.o : $(LIB_DIR)/crtbegin.c
$(VERBOSE)$(COMPILE)
$(COPY) $(OUTPUT_LIB)/crtbegin.o $(INSTALL_PREFIX)/lib/
-$(COPY) $(OUTPUT_LIB)/crtbegin.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/crtend.o : CFLAGS += -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtend.o : $(LIB_DIR)/crtend.c
$(VERBOSE)$(COMPILE)
$(COPY) $(OUTPUT_LIB)/crtend.o $(INSTALL_PREFIX)/lib/
-$(COPY) $(OUTPUT_LIB)/crtend.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/shcrtbegin.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtbegin.o : $(LIB_DIR)/shcrtbegin.c
$(VERBOSE)$(COMPILE)
$(COPY) $(OUTPUT_LIB)/shcrtbegin.o $(INSTALL_PREFIX)/lib/
-$(COPY) $(OUTPUT_LIB)/shcrtbegin.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/shcrtend.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtend.o : $(LIB_DIR)/shcrtend.c
$(VERBOSE)$(COMPILE)
$(COPY) $(OUTPUT_LIB)/shcrtend.o $(INSTALL_PREFIX)/lib/
-$(COPY) $(OUTPUT_LIB)/shcrtend.o $(INSTALL_PREFIX)/lib/

##############################################################################

Expand Down Expand Up @@ -248,15 +257,17 @@ define MAKESHARED
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)@$(DELETE) $@
$(VERBOSE)echo -e "\rMaking Shared \033[0;31m$@\033[0m"
$(VERBOSE)$(CC) -mcrt=clib2 -shared -o $@ $^ $(LOG_COMMAND) -Lbuild/lib -lc
$(VERBOSE)$(CC) -mcrt=clib2 -shared -use-dynld -o $@ $^ $(LOG_COMMAND) -Lbuild/lib -lc
endef

install:
$(DELETE) $(INSTALL_PREFIX)/include/*
$(DELETE) $(INSTALL_PREFIX)/lib/*
$(COPY) LICENSE* $(INSTALL_PREFIX)/
$(COPY) $(OUTPUT_LIB)/* $(INSTALL_PREFIX)/lib/
$(COPY) libauto.a $(INSTALL_PREFIX)/lib/
$(COPY) libs/libauto.a $(INSTALL_PREFIX)/lib/
$(COPY) libs/libpthread.a $(INSTALL_PREFIX)/lib/
$(COPY) libs/libpthread.so $(INSTALL_PREFIX)/lib/
$(COPY) $(LIB_ROOT)/library/include/* $(INSTALL_PREFIX)/include/

release:
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,23 @@ Clib2 now contain also libauto with almost all OS4 components. We'll try to keep

### libresolv

Added resolv library to use dns functions.
Added resolv library to use dns functions. It needs libpthread.a

### libdebug
### debug

To use `libdebug` you have to explicitly link `-lc` and then `-ldebug` otherwise you will have undefined references to debug library functions in libc because the C library is added
by the linker at the end of the link command (use gcc -v to see the verbose output)
To use `debug` functions you have to explicitly pass `DEBUG=true` to GNUMakefile.os4 and
debug functions will be enabled

### Known problems

Don't call `exit()` function in an `alarm()` handler otherwise your program will be stuck at exit.

### TODO

- There is a memory leak at clib2 end needs to be tracked down
- Try to use Microsoft <a href="https://github.com/microsoft/mimalloc">`mimalloc`</a> as memory allocator that should be faster and more better when there are multiple cores.
- Create a shared library
- Add a test suite

## Legal status

Expand Down
13 changes: 7 additions & 6 deletions libamiga.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
OUT_STATIC := $(BUILD_DIR)/obj/libamiga
OUT_SHARED := $(BUILD_DIR)/obj.shared/libamiga

LIBS += \
$(OUTPUT_LIB)/libamiga.so \
$(OUTPUT_LIB)/libamiga.a

##############################################################################
ifeq ($(SHARED),yes)
LIBS += $(OUTPUT_LIB)/libamiga.so
endif
ifeq ($(STATIC),yes)
LIBS += $(OUTPUT_LIB)/libamiga.a
endif

AMIGA_LIB = \
amiga/amiga.lib_rev.o \
Expand Down Expand Up @@ -64,5 +65,5 @@ $(OUT_SHARED)/%.o : $(LIB_DIR)/%.c
$(OUTPUT_LIB)/libamiga.a : $(SOURCES_STATIC)
$(VERBOSE)$(MAKELIB)

$(OUTPUT_LIB)/libamiga.so : $(SOURCES_SHARED)
$(OUTPUT_LIB)/libamiga.so : $(OUTPUT_LIB)/libc.so $(SOURCES_SHARED)
$(VERBOSE)$(MAKESHARED)
56 changes: 51 additions & 5 deletions libc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
OUT_STATIC := $(BUILD_DIR)/obj/libc
OUT_SHARED := $(BUILD_DIR)/obj.shared/libc

LIBS += $(OUTPUT_LIB)/libc.so \
$(OUTPUT_LIB)/libc.a
ifeq ($(SHARED),yes)
MAIN_LIB += $(OUTPUT_LIB)/libc.so
endif
ifeq ($(STATIC),yes)
MAIN_LIB += $(OUTPUT_LIB)/libc.a
endif

C_BASE := \
c.lib_rev.o \
Expand Down Expand Up @@ -57,6 +61,40 @@ C_CTYPE := \
ctype/tolower.o \
ctype/toupper.o

ifdef DEBUG
$(info Adding debug objects)
C_DEBUG := \
debug/debug.lib_rev.o \
debug/debug.o \
debug/cmpstrexec.o \
debug/kcmpstr.o \
debug/kdofmt.o \
debug/kgetc.o \
debug/kgetch1.o \
debug/kgetch2.o \
debug/kgetchar1.o \
debug/kgetchar2.o \
debug/kgetnum1.o \
debug/kgetnum2.o \
debug/kmaygetch.o \
debug/kmaygetchar.o \
debug/kprintf1.o \
debug/kprintf2.o \
debug/kputc.o \
debug/kputch1.o \
debug/kputch2.o \
debug/kputchar1.o \
debug/kputchar2.o \
debug/kputfmt.o \
debug/kputs1.o \
debug/kputs2.o \
debug/kputstr1.o \
debug/kputstr2.o \
debug/kvprintf1.o \
debug/kvprintf2.o \
debug/level.o
endif

C_DIRENT := \
dirent/alphasort.o \
dirent/closedir.o \
Expand Down Expand Up @@ -420,7 +458,6 @@ C_STDLIB := \
stdlib/abort.o \
stdlib/abs.o \
stdlib/aligned_alloc.o \
stdlib/arith64.o \
stdlib/assertion_failure.o \
stdlib/atexit.o \
stdlib/atof.o \
Expand Down Expand Up @@ -535,6 +572,7 @@ C_STRING := \
string/memcpy.o \
string/memccpy.o \
string/mempcpy.o \
string/memmem.o \
string/memmove.o \
string/memrchr.o \
string/memset.o \
Expand All @@ -558,6 +596,7 @@ C_STRING := \
string/strcasestr.o \
string/strcat.o \
string/strchr.o \
string/strchrnul.o \
string/strcmp.o \
string/strcoll.o \
string/strcpy.o \
Expand All @@ -581,6 +620,7 @@ C_STRING := \
string/strstr.o \
string/strtok.o \
string/strtok_r.o \
string/strverscmp.o \
string/strxfrm.o

C_TERMCAP := \
Expand Down Expand Up @@ -684,13 +724,15 @@ C_UNISTD := \
unistd/ftruncate.o \
unistd/ftruncate64.o \
unistd/getcwd.o \
unistd/get_current_dir_name.o \
unistd/getdomainname.o \
unistd/getlogin.o \
unistd/getlogin_r.o \
unistd/getopt.o \
unistd/getopt_long.o \
unistd/getpid.o \
unistd/getppid.o \
unistd/getwd.o \
unistd/init_exit.o \
unistd/isatty.o \
unistd/lchown.o \
Expand Down Expand Up @@ -779,7 +821,8 @@ C_WCHAR := \
wchar/getwchar.o \
wchar/mbrlen.o \
wchar/mbrtowc.o \
wchar/_mbtowc.o \
wchar/_mbstowcs_r.o \
wchar/_mbtowc_r.o \
wchar/mbsinit.o \
wchar/mbsrtowcs.o \
wchar/putwc.o \
Expand Down Expand Up @@ -817,6 +860,7 @@ C_WCHAR := \
wchar/wcstok.o \
wchar/wcstol.o \
wchar/wcstoll.o \
wchar/_wcstombs_r.o \
wchar/wcstombs.o \
wchar/wcstoul.o \
wchar/wcstoull.o \
Expand Down Expand Up @@ -858,6 +902,7 @@ C_LIB := \
$(C_ARGZ) \
$(C_CTYPE) \
$(C_DIRENT) \
$(C_DEBUG) \
$(C_ICONV) \
$(C_INTTYPES) \
$(C_LOCALE) \
Expand Down Expand Up @@ -910,4 +955,5 @@ $(OUTPUT_LIB)/libc.so : $(SOURCES_SHARED)
@$(MAKEDIR) $(@D)
@$(DELETE) $@
$(VERBOSE)echo "Making Shared \033[0;31m$@\033[0m"
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND) -ldebug
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND)
$(COPY) $(OUTPUT_LIB)/libc.so $(INSTALL_PREFIX)/lib/
Loading

0 comments on commit 63527d9

Please sign in to comment.