diff options
author | Freya Murphy <freya@freyacat.org> | 2025-03-25 17:36:52 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-03-25 17:38:22 -0400 |
commit | 6af21e6a4f2251e71353562d5df7f376fdffc270 (patch) | |
tree | de20c7afc9878422c81e34f30c6b010075e9e69a /lib/Make.mk | |
download | comus-6af21e6a4f2251e71353562d5df7f376fdffc270.tar.gz comus-6af21e6a4f2251e71353562d5df7f376fdffc270.tar.bz2 comus-6af21e6a4f2251e71353562d5df7f376fdffc270.zip |
initial checkout from wrc
Diffstat (limited to 'lib/Make.mk')
-rw-r--r-- | lib/Make.mk | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/Make.mk b/lib/Make.mk new file mode 100644 index 0000000..2f8de2c --- /dev/null +++ b/lib/Make.mk @@ -0,0 +1,73 @@ +# +# Makefile fragment for the library components of the system. +# +# THIS IS NOT A COMPLETE Makefile - run GNU make in the top-level +# directory, and this will be pulled in automatically. +# + +SUBDIRS += lib + +################### +# FILES SECTION # +################### + +# +# library file lists +# + +# "common" library functions, used by kernel and users +CLIB_SRC := lib/bound.c lib/cvtdec.c lib/cvtdec0.c \ + lib/cvthex.c lib/cvtoct.c lib/cvtuns.c \ + lib/cvtuns0.c lib/memclr.c lib/memcpy.c \ + lib/memset.c lib/pad.c lib/padstr.c \ + lib/sprint.c lib/str2int.c lib/strcat.c \ + lib/strcmp.c lib/strcpy.c lib/strlen.c + +# user-only library functions +ULIB_SRC := lib/ulibc.c lib/ulibs.S lib/entry.S + +# kernel-only library functions +KLIB_SRC := lib/klibc.c + +# lists of object files +CLIB_OBJ:= $(patsubst lib/%.c, $(BUILDDIR)/lib/%.o, $(CLIB_SRC)) + +ULIB_OBJ:= $(patsubst lib/%.c, $(BUILDDIR)/lib/%.o, $(ULIB_SRC)) +ULIB_OBJ:= $(patsubst lib/%.S, $(BUILDDIR)/lib/%.o, $(ULIB_OBJ)) + +KLIB_OBJ := $(patsubst lib/%.c, $(BUILDDIR)/lib/%.o, $(KLIB_SRC)) +KLIB_OBJ := $(patsubst lib/%.S, $(BUILDDIR)/lib/%.o, $(KLIB_OBJ)) + +# library file names +CLIB_NAME := libcommon.a +ULIB_NAME := libuser.a +KLIB_NAME := libkernel.a + +################### +# RULES SECTION # +################### + +# how to make everything +lib: $(BUILDDIR)/lib/$(CLIB_NAME) \ + $(BUILDDIR)/lib/$(KLIB_NAME) \ + $(BUILDDIR)/lib/$(ULIB_NAME) + +$(BUILDDIR)/lib/%.o: lib/%.c $(BUILDDIR)/.vars.CFLAGS + @mkdir -p $(@D) + $(CC) $(CFLAGS) -c -o $@ $< + +$(BUILDDIR)/lib/%.o: lib/%.S $(BUILDDIR)/.vars.CFLAGS + @mkdir -p $(@D) + $(CPP) $(CPPFLAGS) -o $(@D)/$*.s $< + $(AS) $(ASFLAGS) -o $@ $(@D)/$*.s -a=$(@D)/$*.lst + $(RM) -f $(@D)/$*.s + $(NM) -n $@ > $(@D)/$*.sym + +$(BUILDDIR)/lib/$(CLIB_NAME): $(CLIB_OBJ) + $(AR) $(ARFLAGS) $@ $(CLIB_OBJ) + +$(BUILDDIR)/lib/$(ULIB_NAME): $(ULIB_OBJ) + $(AR) $(ARFLAGS) $@ $(ULIB_OBJ) + +$(BUILDDIR)/lib/$(KLIB_NAME): $(KLIB_OBJ) + $(AR) $(ARFLAGS) $@ $(KLIB_OBJ) |