AUTOMAKE_OPTIONS =

RUST_SRC = \
	src/WINGsP.rs \
	src/button.rs \
	src/color.rs \
	src/configuration.rs \
	src/ffi.rs \
	src/font.rs \
	src/font_panel.rs \
	src/lib.rs \
	src/list.rs \
	src/pango_extras.rs \
	src/screen.rs \
	src/widget.rs

RUST_EXTRA = \
	Cargo.lock \
	Cargo.toml

src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs/WUtil.h Makefile patch_WINGsP.sh
	$(BINDGEN) ../WINGs/WINGsP.h \
	--no-recursive-allowlist \
	--allowlist-type "^W_.+|^WM(View|Array|DragOperationType|Point|Data|OpenPanel|SavePanel|HashTable|DraggingInfo|SelectionProcs|Rect|EventProc|Widget|Size|Pixmap|FilePanel|List|ListItem)" \
	--allowlist-type "^WM(FontPanel|Screen|Button)" \
	--allowlist-function "^WMCreateScreen|^WM(Get|Show)FontPanel|^WMCreateCommandButton|^WM(Initialize|Release)Application|^WMScreenMainLoop|^WMHandleEvent" \
	--allowlist-function "^WMWidgetScreen|^WM(Initialize|Release)Application|^WM(ScreenMainLoop|HandleEvent)|^WM(((Get|Set)TextFieldFont)|GetTextFieldText|SetTextFieldText|SelectTextFieldRange)" \
	--allowlist-type "WMList" \
	--allowlist-function "^WM(CreateList|SetListAction|GetListSelectedItem|InsertListItem|ClearList|FindRowOfListItemWithTitle|SelectListItem|SetListPosition|SortListItems)" \
	--allowlist-type "^WM(Window|Action)" \
	--allowlist-function "^WM(CreateWindow|SetWindowTitle|SetWindowMinSize|SetWindowCloseAction)" \
	--allowlist-type "^WMWidget" \
	--allowlist-function "^WM(Map|Destroy|Unmap|Resize|Realize|Move)Widget" \
	--allowlist-function "^WMWidget(Width|Height)" \
	--allowlist-function "^WM(SetWidgetBackgroundColor|SetWidgetBackgroundColor|MapSubwidgets)" \
	--allowlist-type "^WM(SplitView|SplitViewConstrainProc)" \
	--allowlist-function "^WM(SetViewNotifySizeChanges|CreateSplitView|SetSplitViewConstrainProc|GetSplitViewDividerThickness|AddSplitViewSubview)" \
	--allowlist-type "^WMNotification" \
	--allowlist-function "^WM(Add|Remove)NotificationObserver|^WMGetNotification(Object|Name)" \
	--allowlist-item "^WMNotificationObserverAction" \
	--allowlist-item "^WMViewSizeDidChangeNotification" \
	--allowlist-type "^WMFrame" \
	--allowlist-function "^WM(CreateFrame|SetFrameRelief)" \
	--allowlist-function "^WM(White|DarkGray|Release)Color" \
	--allowlist-type "^WMTextField" \
	--allowlist-function "^WM(CreateTextField)" \
	--allowlist-type "^WMLabel" \
	--allowlist-function "^WM(CreateLabel|SetLabelText|SetLabelFont|SetLabelTextColor|SetLabelRelief|SetLabelTextAlignment)" \
	--allowlist-type "^WM(Button|ButtonBehaviorMask)" \
	--allowlist-function "^WM(CreateCustomButton|SetButtonText|SetButtonAction|SetButtonText)" \
	--allowlist-type "_WINGsConfiguration" \
	--allowlist-item "^WMAlignment" \
	--allowlist-item "^WMReliefType" \
	--allowlist-function "^WM(Create|Release|Draw)Pixmap|^WMCreate(|Blended|ScaledBlended)PixmapFromFile|^WMCreate(|Blended)PixmapFromRImage" \
	-o src/WINGsP.rs -- \
	@PANGO_CFLAGS@ \
	-I../../wrlib \
	-I.. && ./patch_WINGsP.sh src/WINGsP.rs

Cargo.lock:
	$(CARGO) build

target/debug/libwings_rs.so: $(RUST_SRC) $(RUST_EXTRA)
	$(CARGO) build

check-local:
	$(CARGO) test

clean-local:
	$(CARGO) clean
	rm -f src/WINGsP.rs

all: target/debug/libwings_rs.so
