From 62b10f1e2c716dcc2b1a7d1a2d7c4ed6042edbf5 Mon Sep 17 00:00:00 2001 From: Ethan Morgan Date: Sat, 14 Feb 2026 16:17:47 +0000 Subject: init repo --- Makefile.in | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Makefile.in (limited to 'Makefile.in') diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..898090d --- /dev/null +++ b/Makefile.in @@ -0,0 +1,75 @@ +# Makefile for impl +VERSION = @VERSION@ + +# Environment and values saved by the configure script +CC = @CC@ +CCOM = @CCOM@ +AR = @AR@ +RANLIB = @RANLIB@ +RM = @RM@ +INSTALL = @INSTALL@ +OPTIMISE = @OPTIMISE@ +PREFIX = @PREFIX@ +SRCDIR = @SRCDIR@ + +# Find all .c files in src/ recursively +SRCS := $(shell find $(SRCDIR)/src -name '*.c' -type f) +# Generate object file names (strip SRCDIR/src/ prefix and change .c to .o) +OBJS := $(patsubst $(SRCDIR)/src/%.c,%.o,$(SRCS)) + +# VPATH for finding source files +VPATH = $(SRCDIR)/src:$(shell find $(SRCDIR)/src -type d 2>/dev/null | tr '\n' ':') + +# Compiler flags +COPTFLAGS_gcc_debug = -O0 -g3 -Wall -Wextra +COPTFLAGS_gcc_release = -O2 -DNDEBUG +COPTFLAGS_clang_debug = -O0 -g3 -Wall -Wextra +COPTFLAGS_clang_release = -O2 -DNDEBUG +COPTFLAGS = $(COPTFLAGS_$(CCOM)_$(OPTIMISE)) + +CSTDFLAGS_gcc = -std=c11 -pedantic +CSTDFLAGS_clang = -std=c11 -pedantic +CSTDFLAGS = $(CSTDFLAGS_$(CCOM)) + +CFLAGS = $(CSTDFLAGS) $(COPTFLAGS) -I$(SRCDIR)/include -I$(SRCDIR)/thirdparty/utest -I. -DHAVE_CONFIG_H=1 +LDFLAGS = + +# Targets +BINARY = impl + +.PHONY: all clean install check + +all: $(BINARY) + +# Create subdirectories for object files if needed +$(BINARY): $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) + +# Suffix rule for compiling (uses VPATH to find .c files) +.SUFFIXES: .c .o + +.c.o: + @test -d $(dir $@) || mkdir -p $(dir $@) + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + $(RM) -f $(BINARY) $(OBJS) + $(RM) -f test_main test_main.o + find . -type f -name '*.o' -delete 2>/dev/null || true + +install: $(BINARY) + $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin + $(INSTALL) -m 755 $(BINARY) $(DESTDIR)$(PREFIX)/bin/ + +# Test target - links with all objects except main.o +TEST_OBJS := $(filter-out main.o,$(OBJS)) + +check: test_main + ./test_main + +test_main: test_main.o $(TEST_OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ + +test_main.o: $(SRCDIR)/tests/test_main.c $(SRCDIR)/include/impl/base.h + $(CC) $(CFLAGS) -c -o $@ $< + -- cgit v1.2.3