From 37b001bc3276f68b28ecf08eef3a98064f5619a9 Mon Sep 17 00:00:00 2001 From: Lukas Fittl Date: Sun, 31 Dec 2023 19:49:04 +0000 Subject: [PATCH] WIP --- Makefile.win32 | 126 +++++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 78 deletions(-) diff --git a/Makefile.win32 b/Makefile.win32 index 2b0ff658..7249005c 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -1,82 +1,52 @@ TARGET = pg_query - -PG_VERSION = 16.1 -PG_VERSION_MAJOR = 16 -PROTOC_VERSION = 25.1 - -VERSION = 5.0.0 -VERSION_MAJOR = 5 -VERSION_MINOR = 0 -VERSION_PATCH = 0 - -SO_VERSION = 5.0 - -SOLIB = $(TARGET).lib -SONAME = $(SOLIB).$(SO_VERSION) -SOLIBVER = $(SONAME).$(VERSION_PATCH) -SOFLAG = +ARLIB = $(TARGET).lib SRC_FILES = src/*.c src/postgres/*.c vendor/protobuf-c/protobuf-c.c vendor/xxhash/xxhash.c protobuf/pg_query.pb-c.c -OBJ_FILES = src/*.o src/postgres/*.o vendor/protobuf-c/protobuf-c.o vendor/xxhash/xxhash.o protobuf/pg_query.pb-c.o CFLAGS = -I. -I./vendor -I./src/postgres/include -I./src/include -I./src/postgres/include/port/win32 -I./src/postgres/include/port/win32_msvc -TEST_CFLAGS = -I. -I./vendor -I./src/postgres/include -I./src/include -I./src/postgres/include/port/win32 -I./src/postgres/include/port/win32_msvc - -CLEANLIBS = $(SOLIB) -CLEANOBJS = $(OBJ_FILES) -CLEANFILES = $(PGDIRBZ2) - -INSTALL = install -LN_S = ln -s -RM = rm -f -ECHO = echo +RM = del all: examples test build -build: $(SOLIB) +build: $(ARLIB) clean: - del *.obj - del pg_query.exp - del pg_query.lib - del pg_query.dll + $(RM) *.obj + $(RM) pg_query.lib .PHONY: all clean build build_shared extract_source examples test install -.c.o: - @$(ECHO) compiling $(<) - @$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< - -$(SOLIB): clean $(OBJ_FILES) Makefile - link /dll /DEF:pg_query.def *.obj +$(ARLIB): clean $(SRC_FILES) + $(CC) $(CFLAGS) /c $(SRC_FILES) + lib /OUT:pg_query.lib *.obj EXAMPLES = examples/simple examples/scan examples/normalize examples/simple_error examples/normalize_error examples/simple_plpgsql examples: $(EXAMPLES) .\examples\simple -# .\examples\scan BROKEN + .\examples\scan .\examples\normalize .\examples\simple_error .\examples\normalize_error .\examples\simple_plpgsql -examples/simple: examples/simple.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ -g examples/simple.c /link $(SOLIB) $(TEST_LDFLAGS) +examples/simple: examples/simple.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ -g examples/simple.c $(ARLIB) -examples/scan: examples/scan.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ -g examples/scan.c /link $(SOLIB) $(TEST_LDFLAGS) +examples/scan: examples/scan.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ -g examples/scan.c $(ARLIB) -examples/normalize: examples/normalize.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ -g examples/normalize.c /link $(SOLIB) $(TEST_LDFLAGS) +examples/normalize: examples/normalize.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ -g examples/normalize.c $(ARLIB) -examples/simple_error: examples/simple_error.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ -g examples/simple_error.c /link $(SOLIB) $(TEST_LDFLAGS) +examples/simple_error: examples/simple_error.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ -g examples/simple_error.c $(ARLIB) -examples/normalize_error: examples/normalize_error.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ -g examples/normalize_error.c /link $(SOLIB) $(TEST_LDFLAGS) +examples/normalize_error: examples/normalize_error.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ -g examples/normalize_error.c $(ARLIB) -examples/simple_plpgsql: examples/simple_plpgsql.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ -g examples/simple_plpgsql.c /link $(SOLIB) $(TEST_LDFLAGS) +examples/simple_plpgsql: examples/simple_plpgsql.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ -g examples/simple_plpgsql.c $(ARLIB) TESTS = test/deparse test/fingerprint test/fingerprint_opts test/normalize test/parse test/parse_opts test/parse_protobuf test/parse_protobuf_opts test/parse_plpgsql test/scan test/split test: $(TESTS) @@ -88,49 +58,49 @@ test: $(TESTS) .\test\parse_opts .\test\parse_protobuf .\test\parse_protobuf_opts -# .\test\scan + .\test\scan .\test\split # Doesn't work because of C2026: string too big, trailing characters truncated -#test/complex: test/complex.c $(SOLIB) +#test/complex: test/complex.c $(ARLIB) # We have "-Isrc/" because this test uses pg_query_fingerprint_with_opts -# $(CC) $(TEST_CFLAGS) -o $@ -Isrc/ test/complex.c /link $(SOLIB) $(TEST_LDFLAGS) +# $(CC) $(CFLAGS) -o $@ -Isrc/ test/complex.c $(ARLIB) # Doesn't work since this requires pthreads -#test/concurrency: test/concurrency.c test/parse_tests.c $(SOLIB) -# $(CC) $(TEST_CFLAGS) -o $@ test/concurrency.c /link $(SOLIB) $(TEST_LDFLAGS) +#test/concurrency: test/concurrency.c test/parse_tests.c $(ARLIB) +# $(CC) $(CFLAGS) -o $@ test/concurrency.c $(ARLIB) -test/deparse: test/deparse.c test/deparse_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/deparse.c /link $(SOLIB) $(TEST_LDFLAGS) +test/deparse: test/deparse.c test/deparse_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/deparse.c $(ARLIB) -test/fingerprint: test/fingerprint.c test/fingerprint_tests.c $(SOLIB) +test/fingerprint: test/fingerprint.c test/fingerprint_tests.c $(ARLIB) # We have "-Isrc/" because this test uses pg_query_fingerprint_with_opts - $(CC) $(TEST_CFLAGS) -o $@ -Isrc/ test/fingerprint.c /link $(SOLIB) $(TEST_LDFLAGS) + $(CC) $(CFLAGS) -o $@ -Isrc/ test/fingerprint.c $(ARLIB) -test/fingerprint_opts: test/fingerprint_opts.c test/fingerprint_opts_tests.c $(SOLIB) +test/fingerprint_opts: test/fingerprint_opts.c test/fingerprint_opts_tests.c $(ARLIB) # We have "-Isrc/" because this test uses pg_query_fingerprint_with_opts - $(CC) $(TEST_CFLAGS) -o $@ -Isrc/ test/fingerprint_opts.c /link $(SOLIB) $(TEST_LDFLAGS) + $(CC) $(CFLAGS) -o $@ -Isrc/ test/fingerprint_opts.c $(ARLIB) -test/normalize: test/normalize.c test/normalize_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/normalize.c /link $(SOLIB) $(TEST_LDFLAGS) +test/normalize: test/normalize.c test/normalize_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/normalize.c $(ARLIB) -test/parse: test/parse.c test/parse_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/parse.c /link $(SOLIB) $(TEST_LDFLAGS) +test/parse: test/parse.c test/parse_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/parse.c $(ARLIB) -test/parse_opts: test/parse_opts.c test/parse_opts_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/parse_opts.c /link $(SOLIB) $(TEST_LDFLAGS) +test/parse_opts: test/parse_opts.c test/parse_opts_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/parse_opts.c $(ARLIB) -test/parse_plpgsql: test/parse_plpgsql.c test/parse_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/parse_plpgsql.c /link $(SOLIB) $(TEST_LDFLAGS) +test/parse_plpgsql: test/parse_plpgsql.c test/parse_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/parse_plpgsql.c $(ARLIB) -test/parse_protobuf: test/parse_protobuf.c test/parse_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/parse_protobuf.c /link $(SOLIB) $(TEST_LDFLAGS) +test/parse_protobuf: test/parse_protobuf.c test/parse_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/parse_protobuf.c $(ARLIB) -test/parse_protobuf_opts: test/parse_protobuf_opts.c test/parse_opts_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/parse_protobuf_opts.c /link $(SOLIB) $(TEST_LDFLAGS) +test/parse_protobuf_opts: test/parse_protobuf_opts.c test/parse_opts_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/parse_protobuf_opts.c $(ARLIB) -test/scan: test/scan.c test/scan_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/scan.c /link $(SOLIB) $(TEST_LDFLAGS) +test/scan: test/scan.c test/scan_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/scan.c $(ARLIB) -test/split: test/split.c test/split_tests.c $(SOLIB) - $(CC) $(TEST_CFLAGS) -o $@ test/split.c /link $(SOLIB) $(TEST_LDFLAGS) +test/split: test/split.c test/split_tests.c $(ARLIB) + $(CC) $(CFLAGS) -o $@ test/split.c $(ARLIB)