diff options
| author | Emil Williams | 2026-02-18 01:24:57 +0000 |
|---|---|---|
| committer | Emil Williams | 2026-02-18 01:24:57 +0000 |
| commit | 8035daa04137c5412050a2f30e6748db256a576b (patch) | |
| tree | 379fef43cc5182b21328eed19ccfdf15c8e96648 | |
| parent | 959be89c2083ac9f6e12549616e636e54916e007 (diff) | |
| download | libchad-8035daa04137c5412050a2f30e6748db256a576b.tar.xz libchad-8035daa04137c5412050a2f30e6748db256a576b.tar.zst | |
better Makefile
| -rw-r--r-- | Makefile | 25 | ||||
| -rw-r--r-- | test/.gitignore | 1 | ||||
| -rw-r--r-- | test/test.c | 2 |
3 files changed, 23 insertions, 5 deletions
@@ -1,8 +1,25 @@ -CFLAGS := -std=c23 -SOURCE := $(wildcard chad/*.c extern/*.c) +CFLAGS := -std=c23 -fPIC +CPPFLAGS := -Ichad +SOURCE.orig := $(wildcard extern/*.c) +SOURCE := $(SOURCE.orig:extern/%=%) +OBJECT := $(addprefix object/,$(SOURCE:.c=.o)) -so: - ${CC} ${CFLAGS} -fPIC -shared ${SOURCE} -o object/libchad.so +vpath %.c extern + +object/%.o: %.c + @echo "CC $<" + @${COMPILE.c} -o $@ $< + +.PHONY: all +all: object/libchad.a object/libchad.so + +object/libchad.a: ${OBJECT} + @echo "AR $<" + @ar rcs $@ $+ + +object/libchad.so: ${OBJECT} + @echo "SO $<" + @${CC} ${CFLAGS} ${CPPFLAGS} -shared $+ -o $@ dist: -mkdir object/chad/ 2> /dev/null diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +test diff --git a/test/test.c b/test/test.c index 8dd4996..4f9df76 100644 --- a/test/test.c +++ b/test/test.c @@ -1,4 +1,4 @@ -// @BAKE @CC -std=c23 ../object/libchad.so +// @BAKE @CC -std=c23 ../object/libchad.a #include "../chad.h" int main () { dictate ( "cogito ergo sum\n" ); |
