Basic project structure

This commit is contained in:
2026-07-26 18:55:30 +02:00
parent 5b72111ed8
commit c2feeddbbb
9 changed files with 157 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
/build/
/docman
/perf.data*
/massif.out*
/*~
+3
View File
@@ -0,0 +1,3 @@
[submodule "IUP_Nix"]
path = IUP_Nix
url = ssh://gitea@git.cfpi-fpsi.eu:1337/emil/IUP_Nix.git
Submodule
+1
Submodule IUP_Nix added at b7af39ba86
+94
View File
@@ -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)
-3
View File
@@ -1,3 +0,0 @@
# DocMan
A document and book management system, similar to Calibre.
+3
View File
@@ -0,0 +1,3 @@
#+TITLE: DocMan
A document and book management system, similar to Calibre.
+27
View File
@@ -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
];
}
+7
View File
@@ -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)
+17
View File
@@ -0,0 +1,17 @@
#include <iup.h>
#include <stddef.h>
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;
}