Files
libsst/BuildConfig/DetectLibs.rules
2026-04-03 00:22:39 -05:00

37 lines
1.5 KiB
Plaintext

# BuildConfig/DetectLibs.rules
# Author: Patrick Baggett <ptbaggett@762studios.com>
# Created: 4/24/2014
#
# Purpose:
#
# Detects presence of libraries
#
# License:
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
# There is no reason for us to do this here - the reason being is that automatic detection with no alternative is simply a waste of time.
# It's better to have individual makefiles that you include for system stacks. Compiler detection and bifurcation is really solid - the auto
# detection is best left to full fledged build tools - since that's literally what auto-tools does.
#
# Use this file as as temp file
TEMPFILE := $(shell mktemp 2>/dev/null || mktemp -t 'mytmpdir')
#Detect a library, called as: $(call detectLib,file.h,HAVE_FILE_H)
detectLib = $(shell echo "\#include $(1)" > $(TEMPFILE); $(CC) -E $(TEMPFILE) >/dev/null 2>&1; if [ $$? -eq 0 ]; then echo "-D$(2)"; else echo ""; fi)
DETECTED_LIBS :=
DETECTED_LIBS += $(call detectLib,<X11/Xlib.h>,HAVE_XLIB)
DETECTED_LIBS += $(call detectLib,<X11/extensions/XInput2.h>,HAVE_XINPUT2)
DETECTED_LIBS += $(call detectLib,<wayland-client.h>,HAVE_WAYLAND)
DETECTED_LIBS += $(call detectLib,<EGL/egl.h>,HAVE_EGL)
FORCE_REMOVE := $(shell rm $(TEMPFILE))
OS_CXXFLAGS += $(DETECTED_LIBS)
OS_CFLAGS += $(DETECTED_LIBS)