diff options
| author | peter <peter@pmikkelsen.com> | 2026-09-13 21:04:43 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-09-13 21:04:43 +0000 |
| commit | 9489815e240d0c3b2f0d20999b0e58ae0221f224 (patch) | |
| tree | 389f4442f0b4ebc73493438cadf16c968e5ed7d9 | |
| parent | 83bdc0e59232434fc30f94e2fc3a22e81989e4dd (diff) | |
Initial bit of work to get rid of cmake.
FossilOrigin-Name: 4d6a05bd71d4971e09528f5c534603092047a97afea1ea68615be4a5d49313d0
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | make/all.mk | 65 | ||||
| -rw-r--r-- | make/arch/x86_64.mk | 0 | ||||
| -rw-r--r-- | make/bin.mk | 7 | ||||
| -rw-r--r-- | make/lib.mk | 7 | ||||
| -rw-r--r-- | make/os/Linux.mk | 2 | ||||
| -rw-r--r-- | make/os/posix.mk | 8 | ||||
| -rw-r--r-- | make/testbin.mk | 8 | ||||
| -rw-r--r-- | src/bin/Makefile | 5 | ||||
| -rw-r--r-- | src/lib/Makefile | 5 | ||||
| -rw-r--r-- | tests/Makefile | 5 |
11 files changed, 117 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..78bd27a --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +.POSIX: +ROOT = . +include $(ROOT)/make/all.mk + +all: $(APLWC) diff --git a/make/all.mk b/make/all.mk new file mode 100644 index 0000000..c26ec84 --- /dev/null +++ b/make/all.mk @@ -0,0 +1,65 @@ +OS != uname -s +ARCH != uname -m + +CLEAN_FILES ::= +TEST_BINS ::= +APLWC_SUBDIR = $(ROOT)/src/bin +LIBAPLWC_SUBDIR = $(ROOT)/src/lib +LIBAPLWC_INCLUDES = $(ROOT)/src/include +TEST_SUBDIR = $(ROOT)/tests + +-include $(ROOT)/make/os/$(OS).mk +-include $(ROOT)/make/arch/$(ARCH).mk + +.SUFFIXES: +.SUFFIXES: .c $(OBJEXT) + +.PHONY: all clean +all: + +clean: + rm -f $(CLEAN_FILES) + +# APLWC +HDRS = \ + $(APLWC_SUBDIR)/aplwc_repl.h +SRCS = \ + $(APLWC_SUBDIR)/main.c \ + $(APLWC_SUBDIR)/util.c +TARG = $(APLWC) +EXTRA_OBJS = $(LIBAPLWC) +include $(ROOT)/make/bin.mk + +# LIBAPLWC +HDRS = \ + $(LIBAPLWC_SUBDIR)/aplwc_internal.h \ + $(LIBAPLWC_SUBDIR)/boot.h +SRCS = \ + $(LIBAPLWC_SUBDIR)/eval.c \ + $(LIBAPLWC_SUBDIR)/main.c \ + $(LIBAPLWC_SUBDIR)/memory.c \ + $(LIBAPLWC_SUBDIR)/module.c \ + $(LIBAPLWC_SUBDIR)/string.c \ + $(LIBAPLWC_SUBDIR)/symtab.c \ + $(LIBAPLWC_SUBDIR)/syntax.c +TARG = $(LIBAPLWC) +EXTRA_OBJS = +include $(ROOT)/make/lib.mk + +# boot.h +$(LIBAPLWC_SUBDIR)/boot.h: $(LIBAPLWC_SUBDIR)/boot.aplwc + xxd -i -n boot_src $< $@ +CLEAN_FILES += $(LIBAPLWC_SUBDIR)/boot.h + +# tests +TEST = aplwc_errstr +include $(ROOT)/make/testbin.mk + +TEST = aplwc_eval +include $(ROOT)/make/testbin.mk + +TEST = aplwc_read +include $(ROOT)/make/testbin.mk + +TEST = aplwc_utf8 +include $(ROOT)/make/testbin.mk diff --git a/make/arch/x86_64.mk b/make/arch/x86_64.mk new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/make/arch/x86_64.mk diff --git a/make/bin.mk b/make/bin.mk new file mode 100644 index 0000000..2739bbf --- /dev/null +++ b/make/bin.mk @@ -0,0 +1,7 @@ +OBJS = $(SRCS:.c=$(OBJEXT)) +$(OBJS): $(HDRS) + +$(TARG): $(OBJS) $(EXTRA_OBJS) + $(CC) -o $@ $^ + +CLEAN_FILES += $(TARG) $(OBJS) diff --git a/make/lib.mk b/make/lib.mk new file mode 100644 index 0000000..4b8d8cc --- /dev/null +++ b/make/lib.mk @@ -0,0 +1,7 @@ +OBJS = $(SRCS:.c=$(OBJEXT)) +$(OBJS): $(HDRS) + +$(TARG): $(OBJS) $(EXTRA_OBJS) + $(AR) rcs $@ $^ + +CLEAN_FILES += $(TARG) $(OBJS) diff --git a/make/os/Linux.mk b/make/os/Linux.mk new file mode 100644 index 0000000..a3af37b --- /dev/null +++ b/make/os/Linux.mk @@ -0,0 +1,2 @@ +CC = gcc +include $(ROOT)/make/os/posix.mk diff --git a/make/os/posix.mk b/make/os/posix.mk new file mode 100644 index 0000000..fbad393 --- /dev/null +++ b/make/os/posix.mk @@ -0,0 +1,8 @@ +OBJEXT = .o +APLWC = $(APLWC_SUBDIR)/aplwc +LIBAPLWC = $(LIBAPLWC_SUBDIR)/libaplwc.a +CFLAGS += -DAPLWC_BUILD_TYPE_DEBUG +CFLAGS += -I$(LIBAPLWC_INCLUDES) + +.c.o: + $(CC) $(CFLAGS) -o $@ -c $< diff --git a/make/testbin.mk b/make/testbin.mk new file mode 100644 index 0000000..928ee1a --- /dev/null +++ b/make/testbin.mk @@ -0,0 +1,8 @@ +HDRS = +EXTRA_OBJS = $(LIBAPLWC) + +SRCS = $(TEST_SUBDIR)/$(TEST).c +TARG = $(TEST_SUBDIR)/testbin-$(TEST) +TEST_BINS += $(TARG) + +include $(ROOT)/make/bin.mk diff --git a/src/bin/Makefile b/src/bin/Makefile new file mode 100644 index 0000000..6d94deb --- /dev/null +++ b/src/bin/Makefile @@ -0,0 +1,5 @@ +.POSIX: +ROOT=../.. +include $(ROOT)/make/all.mk + +all: $(APLWC) diff --git a/src/lib/Makefile b/src/lib/Makefile new file mode 100644 index 0000000..6f7f6b7 --- /dev/null +++ b/src/lib/Makefile @@ -0,0 +1,5 @@ +.POSIX: +ROOT = ../.. +include $(ROOT)/make/all.mk + +all: $(LIBAPLWC) diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..3504beb --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,5 @@ +.POSIX: +ROOT = .. +include $(ROOT)/make/all.mk + +all: $(TEST_BINS) |