Change readme, and add changable build dir

This commit is contained in:
Gvidas Juknevičius 2025-06-02 16:39:17 +03:00
parent 804c8c5254
commit 4e3de1cfb2
Signed by: MCorange
GPG Key ID: 5BE6B533CB76FE86
2 changed files with 25 additions and 9 deletions

View File

@ -1,5 +1,7 @@
LIB=libcx LIB=libcx
BUILD_DIR?=build
COM_FLAGS = -fPIC -Isrc/include COM_FLAGS = -fPIC -Isrc/include
CC_FLAGS = -std=c23 -ggdb CC_FLAGS = -std=c23 -ggdb
CXX_FLAGS = -std=c++23 -nostdinc++ -ggdb -fexceptions CXX_FLAGS = -std=c++23 -nostdinc++ -ggdb -fexceptions
@ -11,28 +13,28 @@ AR=ar
cxx_sources=$(wildcard src/*.cpp) cxx_sources=$(wildcard src/*.cpp)
c_sources=$(wildcard src/*.c) c_sources=$(wildcard src/*.c)
objects=$(patsubst src/%.cpp,build/obj/%.cpp.o,$(cxx_sources)) $(patsubst src/%.c,build/obj/%.c.o,$(c_sources)) objects=$(patsubst src/%.cpp,$(BUILD_DIR)/obj/%.cpp.o,$(cxx_sources)) $(patsubst src/%.c,$(BUILD_DIR)/obj/%.c.o,$(c_sources))
all: shared static compile_commands.json all: shared static compile_commands.json
shared: build/$(LIB).so shared: $(BUILD_DIR)/$(LIB).so
static: build/$(LIB).a static: $(BUILD_DIR)/$(LIB).a
build/$(LIB).a: $(objects) $(BUILD_DIR)/$(LIB).a: $(objects)
$(AR) rcs $@ $^ $(AR) rcs $@ $^
build/$(LIB).so: $(objects) $(BUILD_DIR)/$(LIB).so: $(objects)
$(LD) -shared -o $@ $^ $(LD) -shared -o $@ $^
clean: clean:
rm -r build/obj/ rm -r $(BUILD_DIR)/obj/
build/obj/%.cpp.o: */%.cpp $(BUILD_DIR)/obj/%.cpp.o: */%.cpp
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CXX) -c -o $@ $< $(CXX_FLAGS) $(COM_FLAGS) $(CXX) -c -o $@ $< $(CXX_FLAGS) $(COM_FLAGS)
build/obj/%.c.o: */%.c $(BUILD_DIR)/obj/%.c.o: */%.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) -c -o $@ $< $(CC_FLAGS) $(COM_FLAGS) $(CC) -c -o $@ $< $(CC_FLAGS) $(COM_FLAGS)

View File

@ -6,9 +6,23 @@ so headers will work for now as this is in heavy development.
## Building ## Building
Just run `make`, no other library than libc is used as of now. It will create both a static and shared library. Just run `make`. It will create both a static and shared library.
I cant guarantee the shared lib working, cuz i dont really use it for now. I cant guarantee the shared lib working, cuz i dont really use it for now.
It only links with `libc` and `libgcc` but only with the supc++ library, the normal stdlib is stll non existant.\
Output from an executable that uses libcx:
```sh
-> % ldd test/test
linux-vdso.so.1 (0x0000785c05ea6000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x0000785c05e20000)
libc.so.6 => /usr/lib/libc.so.6 (0x0000785c05c30000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x0000785c05ea8000)
```
```
```
## Contributing ## Contributing
Just clone it and do the changes, then make a PR. Or even better just DM me on Discord: `@mcorange` Just clone it and do the changes, then make a PR. Or even better just DM me on Discord: `@mcorange`