build: add stpd.lib.mk

This commit is contained in:
d0p1 🏳️‍⚧️ 2025-10-12 16:26:03 +02:00
parent a79916574a
commit b2178714f7
7 changed files with 63 additions and 93 deletions

View file

@ -23,7 +23,7 @@ BUILD_RULES := build-tools .WAIT
BUILD_RULES += includes-kernel includes-include includes-lib .WAIT
BUILD_RULES += build-user build-kernel
USER_RULES := install-bin install-sbin
USER_RULES := install-lib .WAIT install-bin install-sbin
KERNEL_RULES := install-boot install-kernel install-modules
IMAGES = stupid.iso stupid.hdd floppy1440.img floppy2880.img
@ -56,7 +56,7 @@ build-user: $(USER_RULES)
build-kernel: $(KERNEL_RULES)
$(eval $(foreach X,kernel include lib,$(call subdir-rule,includes,$X)))
$(eval $(foreach X,bin sbin,$(call subdir-rule,install,$X)))
$(eval $(foreach X,lib bin sbin,$(call subdir-rule,install,$X)))
$(eval $(foreach X,boot kernel modules,$(call subdir-rule,install,$X)))
.PHONY: stupid.tar.gz

View file

@ -1,27 +1,5 @@
LIBS = libc.a
LIB = c
OBJS = ctype.o
INCS = stddef.h time.h ctype.h
INST = $(addprefix $(DESTDIR)$(INCDIR)/, $(INCS)) \
$(addprefix $(DESTDIR)$(LIBDIR)/, $(LIBS))
.PHONY: all
all: $(LIBS)
$(LIBS): $(OBJS)
$(AR) rcs $@ $^
%.o: %.asm
$(AS) $< $@
$(DESTDIR)$(LIBDIR)/%.a: %.a
install -D $< $@
.PHONY: clean
clean:
$(RM) $(LIBS) $(OBJS)
.PHONY: install
install: $(INST)
include stpd.inc.mk
include stpd.lib.mk

View file

@ -1,4 +1,4 @@
LIBS = libcrypto.a
LIB = crypto
OBJS = sha2/sha256.o sha2/sha512.o \
chacha/chacha.o \
hchacha/hchacha.o
@ -12,26 +12,4 @@ ASMINCS = sha2/sha2.inc \
chacha/chacha.inc \
hchacha/hchacha.inc
INST = $(addprefix $(DESTDIR)$(LIBDIR)/, $(LIBS))
.PHONY: all
all: $(LIBS)
$(LIBS): $(OBJS)
$(AR) rcs $@ $^
%.o: %.asm
$(AS) $< $@
$(DESTDIR)$(LIBDIR)/%.a: %.a
install -D $< $@
.PHONY: clean
clean:
$(RM) $(LIBS) $(OBJS)
.PHONY: install
install: $(INST)
include stpd.inc.mk
include stpd.lib.mk

View file

@ -1,18 +1,13 @@
LIBS = crt0.o
INST = $(addprefix $(DESTDIR)$(LIBDIR)/, $(LIBS))
all: $(LIBS)
%.o: %.asm
$(AS) $< $@
$(DESTDIR)$(LIBDIR)/%.o: %.o
install -D $< $@
clean:
$(RM) $(LIBS)
install: $(INST)
include stpd.base.mk
all: crt0.o
install: $(DESTDIR)$(LIBDIR)/crt0.o
$(DESTDIR)$(LIBDIR)/crt0.o: crt0.o
$(MSG_INSTALL)
@install -D $< $@
CLEANFILES = crt0.o
include stpd.clean.mk

View file

@ -1,30 +1,7 @@
LIBS = liblzp.a
OBJS = lzp.o
LIB = lzp
OBJS= lzp.o
INCS = lzp.h
ASMINCS = lzp.inc
INST = $(addprefix $(DESTDIR)$(INCDIR)/, $(INCS)) \
$(addprefix $(DESTDIR)$(ASMDIR)/, $(ASMINCS)) \
$(addprefix $(DESTDIR)$(LIBDIR)/, $(LIBS))
.PHONY: all
all: $(LIBS)
$(LIBS): $(OBJS)
$(AR) rcs $@ $^
%.o: %.asm
$(AS) $< $@
$(DESTDIR)$(LIBDIR)/%.a: %.a
install -D $< $@
.PHONY: clean
clean:
$(RM) $(LIBS) $(OBJS)
.PHONY: install
install: $(INST)
include stpd.inc.mk
include stpd.lib.mk

26
share/mk/stpd.lib.mk Normal file
View file

@ -0,0 +1,26 @@
include stpd.base.mk
ifdef LIB
_LIB:=lib$(LIB).a
_LIBINST=$(addprefix $(DESTDIR)$(LIBDIR)/, $(_LIB))
all: $(_LIB)
$(_LIB): $(OBJS)
$(MSG_BUILD)
@$(AR) rcs $@ $^
install: $(_LIBINST)
$(_LIBINST): $(_LIB)
$(MSG_INSTALL)
@install -D $< $@
CLEANFILES += $(_LIB) $(OBJS)
include stpd.inc.mk
include stpd.man.mk
include stpd.clean.mk
endif

View file

@ -2,7 +2,23 @@ include stpd.base.mk
ifdef MAN
define maninstall-rule
$1/$2: $2
$$(MSG_INSTALL)
@install -D $2 $1/$2
endef
_MSECTIONS= 1 2 3 4 5 6 7 8 9
_MANINST=$(foreach S,$(_MSECTIONS),$(addprefix $(DESTDIR)$(MANDIR)/$S/,$(filter %.$S,$(MAN))))
maninstall: $(_MANINST)
$(eval $(foreach S,$(_MSECTIONS), \
$(foreach M,$(filter %.$S,$(MAN)), \
$(call maninstall-rule,$(DESTDIR)$(MANDIR)/$S,$M))))
install: maninstall
endif