diff --git a/Makefile b/Makefile index a55c30e..fc15aea 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lib/c/Makefile b/lib/c/Makefile index 7c3ecb8..496f2ba 100644 --- a/lib/c/Makefile +++ b/lib/c/Makefile @@ -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 diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile index d32bdde..7bacf89 100644 --- a/lib/crypto/Makefile +++ b/lib/crypto/Makefile @@ -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 diff --git a/lib/csu/Makefile b/lib/csu/Makefile index ecd0332..feaf7ac 100644 --- a/lib/csu/Makefile +++ b/lib/csu/Makefile @@ -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 diff --git a/lib/lzp/Makefile b/lib/lzp/Makefile index c9eb8aa..916ab23 100644 --- a/lib/lzp/Makefile +++ b/lib/lzp/Makefile @@ -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 diff --git a/share/mk/stpd.lib.mk b/share/mk/stpd.lib.mk new file mode 100644 index 0000000..a7176a4 --- /dev/null +++ b/share/mk/stpd.lib.mk @@ -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 diff --git a/share/mk/stpd.man.mk b/share/mk/stpd.man.mk index e5154fd..23115da 100644 --- a/share/mk/stpd.man.mk +++ b/share/mk/stpd.man.mk @@ -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