Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta10 #135

Merged
merged 196 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
fccaf31
Added gethostname test
afxgroup Mar 7, 2023
5b08826
Fixed some errors when compiling with -Os
afxgroup Mar 8, 2023
452b50a
Some constructors priority changes
afxgroup Mar 15, 2023
d4ab09c
README.md typos
afxgroup Mar 16, 2023
f762af7
Fix for clearerr. Added opendir test example
afxgroup Mar 16, 2023
ac3497e
Added some SPE optimized functions. Changed GNUMakefile to accept SPE…
afxgroup Apr 4, 2023
5df5455
read() and write() on sockets now are forwarded to send() and recv() …
afxgroup Apr 7, 2023
4235081
Usergroup and unistd fixes
afxgroup Apr 14, 2023
11bbbb0
getpwnam_r fixes
Apr 14, 2023
ea81746
Fixed getpwnam_r and getpwuid_r
afxgroup Apr 14, 2023
12f1200
Trying to implement unix sockets..
afxgroup Apr 14, 2023
0b559ac
Use native GetPID() in unistd getpid().
sodero Apr 14, 2023
866d49e
Don't assume that __STDC_VERSION__ is defined.
sodero Apr 14, 2023
c7ac16f
Reverted code due to problems implementing unix stuff with a static l…
afxgroup Apr 16, 2023
0d7f48c
Reverted code due to problems implementing unix stuff with a static l…
afxgroup Apr 16, 2023
96000cb
Reverted code due to problems implementing unix stuff with a static l…
afxgroup Apr 16, 2023
d3fafe5
Merge pull request #85 from afxgroup/unixsockets
afxgroup Apr 16, 2023
67a298b
Merge pull request #84 from sodero/fix/do_not_assume_that_stdc_versio…
afxgroup Apr 16, 2023
57c9ab4
Merge pull request #83 from sodero/topic/simplify_getpid
afxgroup Apr 16, 2023
51b33c5
Added shared library skeleton
afxgroup Apr 16, 2023
4796064
Merge pull request #86 from afxgroup/shared
afxgroup Apr 16, 2023
88c1205
Added Clib2Interface and stub functions
afxgroup Apr 17, 2023
56cec0c
Joined all stubs file into one. clib2.library now compiles well. Adde…
afxgroup Apr 18, 2023
0f53213
Reworked clib2.library and crtbegin.c files. Finally starting to get …
afxgroup Apr 21, 2023
e22b921
Millions of changes to fix clib2.library. Initialization, constructor…
afxgroup Apr 23, 2023
162d87a
Fixed a problem that was causing to call wrong function pointer. Now …
afxgroup Apr 24, 2023
2a377fe
Some fixes to avoid errors on library expunge
afxgroup Apr 24, 2023
33d0b32
Reworked libc_init_global to work correctly and initialize only share…
afxgroup Apr 25, 2023
51245ac
Merge branch 'beta10' of github.com:afxgroup/clib2 into shared
afxgroup Apr 27, 2023
88658c8
Moved (again..) pthread files to libpthread and aio* functions to lib…
afxgroup Apr 27, 2023
645eb78
Fixed some problems when using librt. Reworked some code and moved so…
afxgroup Apr 28, 2023
5ee3413
Added math functions to avoit libgcc linking
afxgroup Apr 28, 2023
beea0d0
Code cleaning. And moved some global variables into clib2 structures
afxgroup Apr 29, 2023
0982e04
Move __fd and __iob into _clib2 structure
afxgroup Apr 30, 2023
caedc63
Other code cleaning. Fixed a problem on pthread library. Moving some …
afxgroup Apr 30, 2023
615b258
Moved debug objects into libdebug again so it will be possible to add…
afxgroup May 1, 2023
a1cf75d
fixed bool problem in aio_suspend function
afxgroup May 1, 2023
d0fa2a5
Added pthread_num_processors_np
afxgroup May 1, 2023
3c65748
Moved open libraries in clib2 initialization from Lib_Open to Lib_Init
afxgroup May 1, 2023
af479fe
Moved wof_allocator to clib2 structure
May 2, 2023
f68b2c1
Moved stdio_lock to clib2 structure
afxgroup May 2, 2023
15d80f8
Merge fixes
afxgroup May 2, 2023
73e5f64
Some more changes to make library reentrant
afxgroup May 4, 2023
7924e4a
Try to fix stdio problems
May 4, 2023
6c11044
Moved some global variables into clib2 structure
afxgroup May 5, 2023
d58ef9d
Reworked clib2 structure
May 5, 2023
1eee380
A lot of other fixes to make clib2 reentrant
afxgroup May 11, 2023
d55f794
Added global define MIN_OS_VERSION. Fixed a problem on arg_init was s…
May 12, 2023
986b403
More and more changes to make library reentrant
afxgroup May 12, 2023
9094967
More and more changes to make library reentrant
afxgroup May 13, 2023
177ca23
Fixed a problem on stubs that was using a bad offset for first functi…
afxgroup May 15, 2023
cf707b5
Fixed a problem on shared library initialization
afxgroup May 15, 2023
49d8d05
More and more changes to make library reentrant
afxgroup May 15, 2023
ea9c918
Some debug fixes
May 16, 2023
8095989
More debug fixes
May 16, 2023
e2d90d5
Merge pull request #87 from afxgroup/shared
afxgroup May 16, 2023
9b4d78a
Added clib2 installer and fixed make release
May 16, 2023
c6bbfa5
Reverted sigsetjmp/siglongjmp to previous version
May 17, 2023
aab2ba2
Fixed a static variable in raise() was causing wrong signals handling…
May 17, 2023
8aa8366
Fixed atexit() was not reentrant
May 17, 2023
6055e75
Fixed arc4random and environ
afxgroup May 17, 2023
aed5818
Added deb package creation. Fix a getopt_long problem
May 19, 2023
73559c1
Changed ZERO to BZERO to avoid some clash in a lot of programs. Howev…
afxgroup May 21, 2023
ac4f4a5
Get rid of some includes in dos.h that was using OS4 includes could c…
afxgroup May 21, 2023
66b5e8d
Don't disable array bounds check warning
sodero May 21, 2023
3fa4f45
Enable implicit fallthrough warnings
sodero May 21, 2023
471202c
Merge branch 'beta10' into fix/enable_array_bounds_checking
afxgroup May 22, 2023
3893195
Merge pull request #88 from sodero/fix/enable_array_bounds_checking
afxgroup May 22, 2023
fce21f6
Merge branch 'beta10' into fix/do_not_ignore_fallthrough_warnings
afxgroup May 22, 2023
e5e0f47
Merge pull request #89 from sodero/fix/do_not_ignore_fallthrough_warn…
afxgroup May 22, 2023
c15b773
Enable missing braces warning
sodero May 22, 2023
b5055c3
Don't redefine __CLIB2
sodero May 22, 2023
428f1d1
Merge pull request #91 from sodero/fix/do_not_redefine_clib2
afxgroup May 23, 2023
93eea41
Merge pull request #90 from sodero/fix/enable_missing_braces_warning
afxgroup May 23, 2023
9185f5e
Remove redundant NULL check in DoTimer
sodero May 23, 2023
7a3939b
Remove redundant NULL check in DeleteStdIO
sodero May 23, 2023
ce2d61a
Remove redundant NULL check in DeleteExtIO
sodero May 23, 2023
9d267a3
Remove redundant NULL check in itimer_real_task
sodero May 23, 2023
3b32830
Remove redundant return value check in itimer_real_task
sodero May 23, 2023
8078361
Remove redundant NULL check in clib destructor
sodero May 23, 2023
0f4eae4
Remove redundant NULL check in __delete_semaphore
sodero May 23, 2023
4ffb456
Fixed a problem on memory allocator when using threads
afxgroup May 23, 2023
84a43f0
Moved semaphore to the end of dos.h library
afxgroup May 23, 2023
7bcd7ad
Memory leak in langinfo
sodero May 23, 2023
79c1906
Simplify initialization of nan(f)
sodero May 23, 2023
6c28e87
Don't pass NULL to nan/nanf
sodero May 23, 2023
6198e4e
Fix potential out of bounds memory access in termcap
sodero May 23, 2023
4b3be27
Invalid size as mbtowc argument
sodero May 23, 2023
fbf9950
Remove if statements that are always true in clock_gettime
sodero May 23, 2023
d8ac769
Merge pull request #105 from sodero/fix/expr_always_true_in_clock_get…
afxgroup May 24, 2023
3a5912e
Merge pull request #104 from sodero/fix/invalid_size_in_regcomp
afxgroup May 24, 2023
0519072
Merge pull request #103 from sodero/fix/termcap_out_of_bounds
afxgroup May 24, 2023
e240830
Merge pull request #102 from sodero/fix/null_pointer_dereferencing
afxgroup May 24, 2023
9e90b80
Merge pull request #101 from sodero/topic/simplify_init_of_nan
afxgroup May 24, 2023
2733c27
Merge pull request #100 from sodero/fix/memory_leak_in_langinfo
afxgroup May 24, 2023
c5ddc2f
Merge pull request #98 from sodero/fix/redundant_return_value_check_i…
afxgroup May 24, 2023
62c8dbc
Merge pull request #97 from sodero/fix/redundant_null_check_in_itimer…
afxgroup May 24, 2023
47b90d1
Merge pull request #96 from sodero/fix/redundant_null_check_in_dotimer
afxgroup May 24, 2023
ac8fb58
Merge pull request #95 from sodero/fix/redundant_null_check_in_destru…
afxgroup May 24, 2023
79114c5
Merge pull request #94 from sodero/fix/redundant_null_check_in_delete…
afxgroup May 24, 2023
93df0b7
Merge pull request #93 from sodero/fix/redundant_null_check_in_delete…
afxgroup May 24, 2023
154370e
Merge pull request #92 from sodero/fix/redundant_null_check_in_delete…
afxgroup May 24, 2023
7701bf1
Fix a problem on gethostbyaddr was not reentrant
afxgroup May 24, 2023
f50a73a
Remove redundant NULL check in access
sodero May 24, 2023
ea0fc67
Bad initialization in btowc
sodero May 24, 2023
fd31370
Remove redundant NULL check in chdir
sodero May 24, 2023
c7941a7
Remove redundant NULL check in chown
sodero May 24, 2023
eca9e42
Remove redundant if statements in clock_gettime64
sodero May 24, 2023
b3c22a4
Remove redundant NULL check in fchmod
sodero May 24, 2023
684fa02
Remove redundant NULL check in fdhookentry
sodero May 24, 2023
5a9abaf
Fix a strange bug (most probably some editing problem) was causing er…
afxgroup May 24, 2023
ad3b6f3
Remove redundant NULL check in ftruncate(64)
sodero May 24, 2023
20b2d31
Remove setting of unused value
sodero May 24, 2023
fb34891
Remove redundant NULL check in (l)stat
sodero May 24, 2023
2cfdb84
Remove redundant NULL check in fcntl/open
sodero May 24, 2023
a71a19f
Remove redundant NULL check in opendir
sodero May 24, 2023
dae4c2d
Remove redundant NULL checks in record_locking
sodero May 24, 2023
cc6aa0b
Potential null pointer dereference
sodero May 24, 2023
e1a5fe3
Redundant if statements in wof_allocator
sodero May 24, 2023
b73710e
Remove setting of unused value
sodero May 24, 2023
a0661ff
Remove redundant boolean expressions in wc(r)tomb
sodero May 24, 2023
95fcaa1
Remove pointless setting of value in ungetwc
sodero May 24, 2023
8390e47
Remove redundant NULL check in rmdir
sodero May 24, 2023
df3b0af
Invalid comparison in wof_allocator
sodero May 24, 2023
11e0ed6
Merge pull request #106 from sodero/fix/redundant_null_check_in_access
afxgroup May 25, 2023
75a6269
Merge pull request #107 from sodero/fix/bad_initialization
afxgroup May 25, 2023
ae5ab75
Merge pull request #108 from sodero/fix/redundant_null_check_in_chdir
afxgroup May 25, 2023
7ef098f
Merge pull request #109 from sodero/fix/redundant_null_check_in_chown
afxgroup May 25, 2023
e4de85c
Merge pull request #110 from sodero/fix/expr_always_true_in_clock_get…
afxgroup May 25, 2023
2f80bc2
Merge pull request #111 from sodero/fix/redundant_null_check_in_fchmod
afxgroup May 25, 2023
ef06df0
Merge pull request #112 from sodero/fix/redundant_null_check_in_fdhoo…
afxgroup May 25, 2023
fd86e08
Merge pull request #113 from sodero/fix/redundant_null_check_in_ftrun…
afxgroup May 25, 2023
bd0bcd2
Merge pull request #114 from sodero/fix/unused_value_in_libc_init_global
afxgroup May 25, 2023
b88ca5d
Merge pull request #115 from sodero/fix/redundant_null_check_in_stat
afxgroup May 25, 2023
d695ed5
Merge pull request #116 from sodero/fix/redundant_null_check_in_fcntl…
afxgroup May 25, 2023
14f42b7
Merge pull request #117 from sodero/fix/redundant_null_check_in_opendir
afxgroup May 25, 2023
06858a2
Merge pull request #118 from sodero/fix/redundant_null_checks_in_reco…
afxgroup May 25, 2023
56e3949
Merge pull request #119 from sodero/fix/possible_null_pointer_derefer…
afxgroup May 25, 2023
2967fdb
Merge pull request #120 from sodero/fix/invalid_comparison_in_wof_all…
afxgroup May 25, 2023
2cbea9d
Merge pull request #121 from sodero/fix/expression_is_always_true
afxgroup May 25, 2023
18d336e
Merge pull request #122 from sodero/fix/remove_unused_value
afxgroup May 25, 2023
d963fb1
Merge pull request #123 from sodero/fix/expressions_always_true_in_wc…
afxgroup May 25, 2023
6dcdc46
Merge pull request #124 from sodero/fix/setting_a_value_already_set_i…
afxgroup May 25, 2023
87c61d7
Merge pull request #125 from sodero/fix/redundant_null_check_in_rmdir
afxgroup May 25, 2023
4c59061
Make build verbosity optional
sodero May 25, 2023
c8f9da9
Fix memory leak in librt
sodero May 25, 2023
d4b9ac2
Broken memory handling in argz_create_sep
sodero May 25, 2023
25038d7
Null pointer dereferences in record_locking
sodero May 25, 2023
0feccda
Null pointer dereference in unistd access
sodero May 25, 2023
054cc5d
Append compiler options
sodero May 25, 2023
97054d2
Merge pull request #126 from sodero/topic/make_build_verbosity_optional
afxgroup May 26, 2023
04b92a1
Merge pull request #127 from sodero/fix/memory_leak_in_librt
afxgroup May 26, 2023
7995de7
Merge pull request #128 from sodero/fix/broken_memory_mgmt_in_argz_cr…
afxgroup May 26, 2023
0a090aa
Merge pull request #129 from sodero/fix/null_pointer_deref_in_handle_…
afxgroup May 26, 2023
a593058
Merge pull request #130 from sodero/fix/null_ptr_deref_in_access
afxgroup May 26, 2023
0865d26
Merge pull request #131 from sodero/topic/append_make_options
afxgroup May 26, 2023
a937c2d
Added futimens and utimensat to stat.h. Fixed some problems on time w…
afxgroup May 26, 2023
53d5fdc
Added old math functions that should fix problem with c++ includes
afxgroup May 27, 2023
317261a
Fix poll was using a static pipenum variable. Fix a problem in vaspri…
afxgroup May 28, 2023
5e52bb9
Small fixes to dpkg files
May 30, 2023
606556b
Merge branch 'beta10' of github.com:afxgroup/clib2 into beta10
May 30, 2023
f877bc5
Removed some useless AVT_ClearWithValue when allocating new block
afxgroup May 31, 2023
9aea026
Added strtouq
afxgroup Jun 3, 2023
05861a2
Reworked some include files that was causing problems when compiling …
afxgroup Jun 4, 2023
ee07555
c.lib_rev fixes
afxgroup Jun 6, 2023
aa30929
Fixed a problem in fpurge
afxgroup Jun 7, 2023
2fb81a6
Start to work to libintl
afxgroup Jun 8, 2023
852303c
Added libintl
afxgroup Jun 8, 2023
13baf5f
Added memory release on dcngettext
afxgroup Jun 8, 2023
deb60a6
Updated version. Fixed postrm file
afxgroup Jun 8, 2023
0036782
Fixed libintl now can use absolute paths in bindtextdomain
afxgroup Jun 9, 2023
a04069e
Removed useless postrm
afxgroup Jun 9, 2023
f507216
Fixed a problem on poll/select was causing broken input. Added ether …
afxgroup Jun 11, 2023
80bb624
Removed proto/elf.h from dos.h
afxgroup Jun 12, 2023
687d986
Reworked vdprintf to avoid assert and return EOF on errors. Fixed som…
afxgroup Jun 15, 2023
f5f1764
Fixed time global variables was causing compilation errors
afxgroup Jun 15, 2023
a5f737a
Added vdprintf example
afxgroup Jun 15, 2023
da5ea37
Added getrandom/getentropy. unix paths now convert /dev/random and /d…
afxgroup Jun 15, 2023
decc597
Bumped revision
afxgroup Jun 16, 2023
227d885
Added a test for library version and revision in crtbegin
afxgroup Jun 16, 2023
06dd403
Implemented dummy F_GETFD on fcntl was causing a bad return value
afxgroup Jun 16, 2023
62fd954
Found another global variable to move..
afxgroup Jun 19, 2023
e66c057
Moved other global variables to _clib2 struct
afxgroup Jun 19, 2023
fb475cf
Lowered clib2 priority. No need to have huge priority. Removed useles…
afxgroup Jun 19, 2023
686af60
Changed pr_CLibData to pr_EntryData to store global clib2 struct. Thi…
afxgroup Jun 20, 2023
b3e5b42
Removed visibility flag
afxgroup Jun 20, 2023
81a9bf9
Merge branch 'beta10' of github.com:afxgroup/clib2 into beta10
afxgroup Jun 20, 2023
8143a20
Changed pthreads to use NP_UserData instead of NP_EntryData. Some sma…
afxgroup Jun 21, 2023
abc2f74
Some fixes to process handling
afxgroup Jun 21, 2023
149bc0d
Formatting code on some files
afxgroup Jun 22, 2023
522c404
Changed _CLIB2 define in features.h to CLIB2_SHAREDLIB
afxgroup Jun 26, 2023
7fa91c7
New shared pointer login. Replace Semaphores with mutexes in pthread_…
afxgroup Jun 30, 2023
c54ce75
Added unix socket support. Needs to cleanup them correctly
afxgroup Jul 2, 2023
6d12dc3
Fixed unix socket implementation
afxgroup Jul 3, 2023
c46d008
Merge pull request #134 from afxgroup/sharing_data
afxgroup Jul 3, 2023
605825e
Fixed pthread_mutex_timedlock function. Now all pthread_mutex* functi…
afxgroup Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
*.lha
*.bak
/library/compiler.log
clib2.info
compiler.log
*.map
.vscode
build/
clib2.lha
.idea/
clib2_1.0_amd64
*.deb
150 changes: 112 additions & 38 deletions GNUmakefile.os4
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

.PHONY : all all-targets clean version cvs-tag
.PHONY : all all-targets clean version release dpkg

# You may have to change the following sets of macro definitions which will
# be used throughout the build makefile. These definitions cover the paths
Expand Down Expand Up @@ -51,84 +51,102 @@ LIB_ROOT ?= $(shell pwd)
LIB_DIR = $(LIB_ROOT)/library
BUILD_DIR = $(LIB_ROOT)/build
OUTPUT_LIB = $(BUILD_DIR)/lib
DPKG_LIB = clib2_1.0_amd64

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

WARNINGS := \
-Wall -W -Wextra -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
-Wundef -Wmissing-declarations -Wunused -Wwrite-strings -Wno-array-bounds -Wno-missing-braces -Wno-unused-value -Wno-comment \
-Wundef -Wmissing-declarations -Wunused -Wwrite-strings -Wno-unused-value -Wno-comment \
-Wno-deprecated-declarations -Wno-sign-compare -Wno-cast-function-type -Wno-unused-variable -Wno-parentheses -Wno-missing-prototypes \
-Wstrict-aliasing -Wno-shadow -Wno-implicit-fallthrough -Wno-discarded-qualifiers -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing \
-Wno-type-limits -Werror # -Wbad-function-cast -Wconversion -Wformat
-Wstrict-aliasing -Wno-shadow -Wno-discarded-qualifiers -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing \
-Wno-type-limits # -Werror -Wbad-function-cast -Wconversion -Wformat

PIC := -fPIC -DPIC
INCLUDES := -I$(LIB_DIR)/include \
-Ilibrary \
-I$(LIB_DIR)/external/include \
-I$(SDK_INCLUDE) \
-I$(LIB_DIR)/debug \
-I$(LIB_DIR)/amiga \
-I$(LIB_DIR)/profile \
-I$(LIB_DIR)/math \
-I$(LIB_DIR)/argz \
-I$(LIB_DIR)/usergroup \
-I$(LIB_DIR)/string \
-I$(LIB_DIR)/ctype \
-I$(LIB_DIR)/stdio \
-I$(LIB_DIR)/stdlib \
-I$(LIB_DIR)/socket \
-I$(LIB_DIR)/unistd \
-I$(LIB_DIR)/time \
-I$(LIB_DIR)/wchar \
-I$(LIB_DIR)/posix \
-I$(LIB_DIR)/termios \
-I$(LIB_DIR)/search \
-I$(LIB_DIR)/debug \
-I$(LIB_DIR)/dirent \
-I$(LIB_DIR)/fcntl \
-I$(LIB_DIR)/inttypes \
-I$(LIB_DIR)/locale \
-I$(LIB_DIR)/dirent \
-I$(LIB_DIR)/math \
-I$(LIB_DIR)/misc \
-I$(LIB_DIR)/mount \
-I$(LIB_DIR)/posix \
-I$(LIB_DIR)/profile \
-I$(LIB_DIR)/usergroup \
-I$(LIB_DIR)/search \
-I$(LIB_DIR)/socket \
-I$(LIB_DIR)/stat \
-I$(LIB_DIR)/mount
-I$(LIB_DIR)/stdio \
-I$(LIB_DIR)/stdlib \
-I$(LIB_DIR)/string \
-I$(LIB_DIR)/termios \
-I$(LIB_DIR)/time \
-I$(LIB_DIR)/unistd \
-I$(LIB_DIR)/wchar

SHARED := $(if $(SHARED),$(SHARED),yes)
STATIC := $(if $(STATIC),$(STATIC),yes)

LARGEDATA := -msdata=data
OPTIONS := $(LARGEDATA) -DHAVE_SYSV -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__CLIB2__ -Wa,-mregnames -fno-builtin -nostdlib -D_GNU_SOURCE -D_XOPEN_SOURCE -D_USE_GNU
OPTIMIZE := -O3 -mmultiple -mupdate -mstrict-align
LARGEDATA :=
OPTIONS += $(LARGEDATA) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__CLIB2__ -Wa,-mregnames -fno-builtin -nostdlib -D_GNU_SOURCE -D_XOPEN_SOURCE -D_USE_GNU
OPTIMIZE := -O3 -mregnames -mmultiple -mupdate -mstrict-align

STABS :=
DLIBS :=

ifndef DEBUG
OPTIMIZE += -gstabs -DNDEBUG
OPTIMIZE += $(STABS) -DNDEBUG
else
OPTIMIZE += -gstabs -DDEBUG
DLIBS += $(BUILD_DIR)/lib/libdebug.a
endif

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

VERBOSE := @
ifdef SPE
CFLAGS := $(CFLAGS) -DSPE
endif

VERBOSE ?= @

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

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

all: prepare all-targets all-libs
all: prepare all-targets all-libs clib2.library.debug clib2.library

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

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

LIBS :=
MAIN_LIB:=
OBJ_C_LIB =
OBJ_C_SRC =
OUT_SHARED_LIB := $(BUILD_DIR)/shared

include libc.gmk
include libm.gmk
include libamiga.gmk
include libdebug.gmk
include libprofile.gmk
include libpthread.gmk
include libcrypt.gmk
include librt.gmk
include shared.gmk

prepare:
-$(MAKEDIR) $(BUILD_DIR)/shared
-$(MAKEDIR) $(INSTALL_PREFIX)/lib
-$(MAKEDIR) $(INSTALL_PREFIX)/include

Expand All @@ -138,8 +156,10 @@ all-targets: \
$(OUTPUT_LIB)/crtend.o \
$(OUTPUT_LIB)/shcrtbegin.o \
$(OUTPUT_LIB)/shcrtend.o \
$(OUT_SHARED_LIB)/shared_library/clib2.o \
$(OUT_SHARED_LIB)/shared_library/math.o \
$(MAIN_LIB)
$(info $(MAIN_LIB))
#$(info $(OBJ_C_SRC))

all-libs: $(LIBS)

Expand All @@ -148,24 +168,41 @@ all-libs: $(LIBS)
# Delete all object files and libraries
clean:
-$(DELETE) $(BUILD_DIR)/obj
-$(DELETE) $(BUILD_DIR)/obj.shared
-$(DELETE) $(BUILD_DIR)/obj.shared
-$(DELETE) $(BUILD_DIR)/shared
-$(DELETE) $(OUTPUT_LIB)
-$(DELETE) $(BUILD_DIR)/compiler.log
-$(DELETE) $(BUILD_DIR)/clib2.library*
-$(DELETE) clib2.lha
-$(DELETE) clib2.bak
-$(DELETE) $(DPKG_LIB)
-$(DELETE) $(DPKG_LIB).deb
-cd test_programs; make 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 profile.lib_rev.rev
$(COPY) c.lib_rev.rev m.lib_rev.rev
$(COPY) c.lib_rev.rev amiga/amiga.lib_rev.rev
$(COPY) c.lib_rev.rev profile/profile.lib_rev.rev
$(COPY) c.lib_rev.rev math/m.lib_rev.rev
$(COPY) c.lib_rev.rev math/crypt.lib_rev.rev
$(COPY) c.lib_rev.rev math/pthread.lib_rev.rev
bumprev amiga.lib
bumprev c.lib
bumprev profile.lib
bumprev m.lib
bumprev crypt.lib
bumprev pthread.lib

# Shared clib2.library rules

clib2.library.debug: $(OBJ_C_LIB)
$(VERBOSE)$(CC) -o $(BUILD_DIR)/$@ $(CFLAGS) $(BUILD_DIR)/shared/shared_library/clib2.o $(BUILD_DIR)/shared/shared_library/math.o $(OBJ_C_LIB) $(DLIBS) -Wl,--cref,-M,-Map=$(BUILD_DIR)/$@.map -nostartfiles -nostdlib

clib2.library: clib2.library.debug
cp $(BUILD_DIR)/$< $(BUILD_DIR)/$@
ppc-amigaos-strip -R.comment -R.sdata2 --strip-unneeded-rel-relocs $(BUILD_DIR)/$@

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

Expand All @@ -183,17 +220,17 @@ $(OUTPUT_LIB)/crt0.o : $(LIB_DIR)/crt0.S
$(VERBOSE)$(ASSEMBLE)
-$(COPY) $(OUTPUT_LIB)/crt0.o $(INSTALL_PREFIX)/lib/

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

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

$(OUTPUT_LIB)/shcrtbegin.o : CFLAGS += $(PIC) -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtbegin.o : CFLAGS += $(PIC) $(STABS) -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtbegin.o : $(LIB_DIR)/shcrtbegin.c
$(VERBOSE)$(COMPILE)
-$(COPY) $(OUTPUT_LIB)/shcrtbegin.o $(INSTALL_PREFIX)/lib/
Expand All @@ -220,7 +257,7 @@ endef
define COMPILE_ASM
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rCompiling Static ASM \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) -o $@ -c $< $(LOG_COMMAND)
$(VERBOSE)$(CC) -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_SHARED
Expand All @@ -243,10 +280,28 @@ endef

define COMPILE_REG
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rAssembling with regnames \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) -mvrsave -mregnames -DVRSAVE -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_ALTIVEC_REG
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rAssembling altivec \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) -maltivec -mabi=altivec -mvrsave -mregnames -DVRSAVE -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_SPE
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rCompiling SPE \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) -mspe -mcpu=8540 -mfloat-gprs=double -mabi=spe -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_SHARED_SPE
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rCompiling Shared SPE \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) -mspe -mcpu=8540 -mfloat-gprs=double -mabi=spe $(PIC) -o $@ -c $< $(LOG_COMMAND)
endef

define MAKELIB
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)@$(DELETE) $@
Expand All @@ -263,7 +318,7 @@ $(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $
endef

compile-tests:
cd $(LIB_ROOT)/test_programs; CC="$(CC)" CXX="$(CXX)" COPY="$(COPY)" DELETE="$(DELETE)" MAKEDIR="$(MAKEDIR)" && make
+make -C $(LIB_ROOT)/test_programs; CC="$(CC)" CXX="$(CXX)" COPY="$(COPY)" DELETE="$(DELETE)" MAKEDIR="$(MAKEDIR)"

install:
$(DELETE) $(INSTALL_PREFIX)/include/*
Expand All @@ -274,12 +329,31 @@ install:

release:
-$(DELETE) clib2.lha
-$(DELETE) clib2.info
-$(MAKEDIR) clib2/include
-$(MAKEDIR) clib2/lib
-$(COPY) *.md clib2/
-$(COPY) LICENSE* clib2/
-$(COPY) installer/Install* clib2/
-$(COPY) installer/clib2.info .
-$(COPY) installer/README.md.info clib2/
-$(COPY) $(BUILD_DIR)/clib2.library clib2/
-$(COPY) misc clib2/
-$(COPY) libs/libauto.a clib2/lib/
-$(COPY) $(OUTPUT_LIB)/* clib2/lib/
-$(COPY) $(LIB_ROOT)/library/include/* clib2/include/
jlha -aqo7i clib2.lha clib2
-$(DELETE) clib2
jlha -aqo7i clib2.lha clib2 clib2.info
-$(DELETE) clib2
-$(DELETE) clib2.info

dpkg:
-$(DELETE) $(DPKG_LIB)
-$(DELETE) $(DPKG_LIB).deb
-$(MAKEDIR) $(DPKG_LIB)/usr/ppc-amigaos/SDK/clib2/lib
-$(MAKEDIR) $(DPKG_LIB)/usr/ppc-amigaos/SDK/clib2/include
-$(MAKEDIR) $(DPKG_LIB)/DEBIAN
-$(COPY) libs/libauto.a $(DPKG_LIB)/usr/ppc-amigaos/SDK/clib2/lib/
-$(COPY) $(OUTPUT_LIB)/* $(DPKG_LIB)/usr/ppc-amigaos/SDK/clib2/lib/
-$(COPY) $(LIB_ROOT)/library/include/* $(DPKG_LIB)/usr/ppc-amigaos/SDK/clib2/include/
-$(COPY) misc/control $(DPKG_LIB)/DEBIAN/
dpkg --build $(DPKG_LIB)
Loading