<commit_before>
-include config.mak

# config
MKAR = $(AR) rcs
CFLAGS += $(WFLAGS)
CPPFLAGS = $(USUAL_CPPFLAGS)

# sources
USUAL_DIR = .
USUAL_OBJDIR = obj
USUAL_MODULES = $(filter-out pgsocket, $(subst .h,, $(notdir $(wildcard $(USUAL_DIR)/usual/*.h))))
include $(USUAL_DIR)/Setup.mk

# tgz generation
FULL = libusual-$(shell date +%Y-%m-%d)
DIRS = usual m4 test
IGNORE = usual/config.h test/config.h test/test_config.h
FILES = $(filter-out $(IGNORE), $(wildcard usual/*.[ch] test/*.[ch])) \
	m4/usual.m4 configure configure.ac COPYRIGHT \
	Makefile README config.mak.in Setup.mk \
	find_modules.sh test/force_compat.sed test/Makefile

# pgutil_kwlookup generation
PG_CONFIG ?= pg_config
KWLIST = $(shell $(PG_CONFIG) --includedir-server)/parser/kwlist.h
GPERF = gperf -m5

# full path for files
srcs = $(USUAL_SRCS)
hdrs = $(USUAL_HDRS)
objs = $(USUAL_OBJS)

# Quiet by default, 'make V=1' shows commands
V=0
ifeq ($(V), 0)
Q = @
E = @echo
else
Q =
E = @true
endif

# rules follow

all: info libusual.a obj/testcompile

libusual.a: $(objs)
	$(E) "	AR" $@
	$(Q) $(MKAR) $@ $(objs)

$(USUAL_OBJDIR)/%.o: $(USUAL_DIR)/usual/%.c config.mak $(hdrs)
	@mkdir -p $(USUAL_OBJDIR)
	$(E) "	CC" $<
	$(Q) $(CC) -c -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $<

$(USUAL_OBJDIR)/%.s: $(USUAL_DIR)/usual/%.c config.mak $(hdrs)
	@mkdir -p $(USUAL_OBJDIR)
	$(E) "	CC -S" $<
	$(Q) $(CC) -S -fverbose-asm -o - $(DEFS) $(CPPFLAGS) $(CFLAGS) $< \
	| cleanasm > $@

obj/testcompile: test/compile.c libusual.a config.mak $(hdrs)
	$(E) "	CHECK" $<
	$(Q) $(CC) -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS)

test/test_string: test/test_string.c libusual.a config.mak $(hdrs)
	$(E) "	TEST" $@
	$(Q) $(CC) -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS)
	$(Q) ./$@

check: config.mak
	mkdir -p test/usual
	sed -f test/compat.sed usual/config.h > test/usual/config.h
	make clean
	make CPPFLAGS="-I./test $(CPPFLAGS)" all
	make CPPFLAGS="-I./test $(CPPFLAGS)" test/test_string

clean:
	rm -f libusual.a obj/*.[os] obj/test* aclocal* config.log
	rm -rf autom4te*
	rm -f usual/pgutil_kwlookup.h.gp

distclean: clean
	rm -f config.mak usual/config.h

realclean:
	rm -f usual/pgutil_kwlookup.h

boot:
	rm -rf usual/config.*
	aclocal -I ./m4
	autoheader
	autoconf
	rm -rf aclocal* autom4te.*

#config.mak:
#	@echo "Config out-of-date, please run ./configure again"
#	@exit 1

#usual/config.h:
#	@echo "Please run ./configure first"
#	@exit 1

# run sparse over code
sparse: config.mak
	REAL_CC="$(CC)" \
	$(MAKE) clean libusual.a CC="cgcc -Wsparse-all -Wno-transparent-union"

asms = $(objs:.o=.s)<commit_msg>make distclean now rips out config.status, too<commit_after>
-include config.mak

# config
MKAR = $(AR) rcs
CFLAGS += $(WFLAGS)
CPPFLAGS = $(USUAL_CPPFLAGS)

# sources
USUAL_DIR = .
USUAL_OBJDIR = obj
USUAL_MODULES = $(filter-out pgsocket, $(subst .h,, $(notdir $(wildcard $(USUAL_DIR)/usual/*.h))))
include $(USUAL_DIR)/Setup.mk

# tgz generation
FULL = libusual-$(shell date +%Y-%m-%d)
DIRS = usual m4 test
IGNORE = usual/config.h test/config.h test/test_config.h
FILES = $(filter-out $(IGNORE), $(wildcard usual/*.[ch] test/*.[ch])) \
	m4/usual.m4 configure configure.ac COPYRIGHT \
	Makefile README config.mak.in Setup.mk \
	find_modules.sh test/force_compat.sed test/Makefile

# pgutil_kwlookup generation
PG_CONFIG ?= pg_config
KWLIST = $(shell $(PG_CONFIG) --includedir-server)/parser/kwlist.h
GPERF = gperf -m5

# full path for files
srcs = $(USUAL_SRCS)
hdrs = $(USUAL_HDRS)
objs = $(USUAL_OBJS)

# Quiet by default, 'make V=1' shows commands
V=0
ifeq ($(V), 0)
Q = @
E = @echo
else
Q =
E = @true
endif

# rules follow

all: info libusual.a obj/testcompile

libusual.a: $(objs)
	$(E) "	AR" $@
	$(Q) $(MKAR) $@ $(objs)

$(USUAL_OBJDIR)/%.o: $(USUAL_DIR)/usual/%.c config.mak $(hdrs)
	@mkdir -p $(USUAL_OBJDIR)
	$(E) "	CC" $<
	$(Q) $(CC) -c -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $<

$(USUAL_OBJDIR)/%.s: $(USUAL_DIR)/usual/%.c config.mak $(hdrs)
	@mkdir -p $(USUAL_OBJDIR)
	$(E) "	CC -S" $<
	$(Q) $(CC) -S -fverbose-asm -o - $(DEFS) $(CPPFLAGS) $(CFLAGS) $< \
	| cleanasm > $@

obj/testcompile: test/compile.c libusual.a config.mak $(hdrs)
	$(E) "	CHECK" $<
	$(Q) $(CC) -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS)

test/test_string: test/test_string.c libusual.a config.mak $(hdrs)
	$(E) "	TEST" $@
	$(Q) $(CC) -o $@ $(DEFS) $(CPPFLAGS) $(CFLAGS) $< $(USUAL_LDFLAGS) $(USUAL_LIBS) $(LIBS)
	$(Q) ./$@

check: config.mak
	mkdir -p test/usual
	sed -f test/compat.sed usual/config.h > test/usual/config.h
	make clean
	make CPPFLAGS="-I./test $(CPPFLAGS)" all
	make CPPFLAGS="-I./test $(CPPFLAGS)" test/test_string

clean:
	rm -f libusual.a obj/*.[os] obj/test* aclocal* config.log
	rm -rf autom4te*
	rm -f usual/pgutil_kwlookup.h.gp

distclean: clean
	rm -f config.mak usual/config.h config.status

realclean:
	rm -f usual/pgutil_kwlookup.h

boot:
	rm -rf usual/config.*
	aclocal -I ./m4
	autoheader
	autoconf
	rm -rf aclocal* autom4te.*

#config.mak:
#	@echo "Config out-of-date, please run ./configure again"
#	@exit 1

#usual/config.h:
#	@echo "Please run ./configure first"
#	@exit 1

# run sparse over code
sparse: config.mak
	REAL_CC="$(CC)" \
	$(MAKE) clean libusual.a CC="cgcc -Wsparse-all -Wno-transparent-union"

asms = $(objs:.o=.s)
{'fraction_non_alphanumeric': 0.19570540591448485, 'fraction_numerical': 0.004520625353173856, 'mean_word_length': 3.9349442379182156, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6353663', 'n_tokens_mistral': 2347, 'n_tokens_neox': 2219, 'n_words': 540}