diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef19aa6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/build/ +/docman +/perf.data* +/massif.out* +/*~ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e8e9f50 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "IUP_Nix"] + path = IUP_Nix + url = ssh://gitea@git.cfpi-fpsi.eu:1337/emil/IUP_Nix.git diff --git a/IUP_Nix b/IUP_Nix new file mode 160000 index 0000000..b7af39b --- /dev/null +++ b/IUP_Nix @@ -0,0 +1 @@ +Subproject commit b7af39ba86443950e534499df8a53f2b43d94002 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13c1209 --- /dev/null +++ b/Makefile @@ -0,0 +1,94 @@ +SRC_DIR := src +BUILD_DIR := build + +SRC := $(shell find $(SRC_DIR) -name '*.c') + +OBJ := $(SRC:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o) +DEP := $(OBJ:.o=.d) + +LC_ALL := C +CC ?= gcc +LD := $(CC) +PKG_CONFIG ?= pkg-config +CCACHE ?= ccache +RM ?= rm -f +STD := gnu23 + +DEBUG ?= 1 +STATIC ?= 0 +PKGS := iup +TOOLS := $(CC) $(LD) $(PKG_CONFIG) $(CCACHE) + +CPPFLAGS = -I$(SRC_DIR) $(shell $(PKG_CONFIG) --cflags $(PKGS) 2>/dev/null) +CFLAGS := -std=$(STD) -Werror -Wextra -Wall -MMD -MP +LDLIBS = $(shell $(PKG_CONFIG) --libs $(PKGS) 2>/dev/null) +LDFLAGS ?= + +TARGET := docman + +ifeq ($(STATIC),1) + LDFLAGS += -static + LDLIBS = $(shell $(PKG_CONFIG) --static --libs $(PKGS) 2>/dev/null || $(PKG_CONFIG) --libs $(PKGS) 2>/dev/null) +else + LDLIBS = $(shell $(PKG_CONFIG) --libs $(PKGS) 2>/dev/null) +endif + +ifeq ($(DEBUG),1) + CFLAGS += -g -DDEBUG + LDFLAGS += -g +else + CFLAGS += -O2 -DNDEBUG +endif + +.DELETE_ON_ERROR: +.PHONY: all check-tools check-libs clean format +all: $(TARGET) + +$(OBJ): | check-libs + +$(TARGET): $(OBJ) + $(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS) + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + mkdir -p $(dir $@) + $(CCACHE) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + +check-tools: + @for t in $(TOOLS); do \ + if path=$$(command -v $$t); then \ + printf "Found tool: %-12s %s\n" "$$t" "$$path"; \ + else \ + printf "Error: missing tool %-12s\n" "$$t"; \ + exit 1; \ + fi; \ + done + @echo "All required tools found" + +check-libs: check-tools + @for lib in $(PKGS); do \ + if $(PKG_CONFIG) --exists $$lib; then \ + ver=$$($(PKG_CONFIG) --modversion $$lib); \ + printf "Found library: %-12s %s\n" "$$lib" "$$ver"; \ + else \ + printf "Error: library %-12s not found\n" "$$lib"; \ + exit 1; \ + fi; \ + done + @echo "All required libraries found. Building" + +clean: + $(RM) -r $(BUILD_DIR) $(TARGET) perf.data* massif.out* + +format: + @if command -v indent >/dev/null 2>&1; then \ + find $(SRC_DIR) -type f \( -name '*.c' -o -name '*.h' \) \ + -exec sh -c 'tmp=$$(mktemp) || tmp=/tmp/indent.$$$$; \ + indent -gnu "$$1" -o "$$tmp" && mv "$$tmp" "$$1"' _ {} \; ; \ + else \ + printf "GNU indent missing, cannot format code\n"; \ + exit 1; \ + fi + + +-include $(DEP) + diff --git a/README.md b/README.md deleted file mode 100644 index c540ae3..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# DocMan - -A document and book management system, similar to Calibre. \ No newline at end of file diff --git a/README.org b/README.org new file mode 100644 index 0000000..4935513 --- /dev/null +++ b/README.org @@ -0,0 +1,3 @@ +#+TITLE: DocMan + +A document and book management system, similar to Calibre. diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..b0fec3b --- /dev/null +++ b/shell.nix @@ -0,0 +1,27 @@ +let + pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-25.11") {}; + ftgl-tecgraf = pkgs.callPackage ./IUP_Nix/ftgl-tecgraf.nix {}; + im = pkgs.callPackage ./IUP_Nix/im.nix { inherit builtins; }; + cd = pkgs.callPackage ./IUP_Nix/cd.nix { inherit builtins ftgl-tecgraf im; }; + iup = pkgs.callPackage ./IUP_Nix/iup.nix { inherit builtins ftgl-tecgraf im cd; }; +in +pkgs.mkShellNoCC { + packages = with pkgs; [ + iup + fftw + libpng + gtk2 + libGLU + ftgl-tecgraf + + gcc + ccache + pkg-config + cloc + valgrind + gdb + cpulimit + perf + indent + ]; +} diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..4d60025 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,7 @@ +# This Makefile is just for the convenience of being able to make +# while having the shell be in src/ + +.PHONY: FORCE + +FORCE: + $(MAKE) -C .. $(MAKECMDGOALS) diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..7e0d7fc --- /dev/null +++ b/src/main.c @@ -0,0 +1,17 @@ +#include +#include + +int +main (int argc, char **argv) +{ + IupOpen (&argc, &argv); + + Ihandle *dlg = IupDialog (NULL); + IupSetAttribute (dlg, "TITLE", "DocMan"); + + IupShowXY (dlg, IUP_CENTER, IUP_CENTER); + IupMainLoop (); + IupClose (); + + return 0; +}