aboutsummaryrefslogblamecommitdiffstats
path: root/configure
blob: bffe525f37c08e5c1a543f89a6aa84f6b9d57a11 (plain) (tree)
1
2
3
4
5
6
7
                 
                                                                      

                                                                    


                                                                                    













                                  
                                        

                                                                      




                                      

                    









                                                                            
                                                                            
                                                                                   


                                                                                                          
                                                                                                                                                                                                                             

                                                                                                       
                              






                                                          
                                                      



                                                                     

            
#!/usr/bin/env sh
# configure script for nytpu's implementation of ed(1), in POSIX shell
# It should be pretty generic though, with just slight modifications
#
# Copyright (c) 2021 nytpu <alex@nytpu.com>
# SPDX-License-Identifier: MIT
# For more license details, see LICENSE_MIT or <https://spdx.org/licenses/MIT.html>.
set -eu

add_cflags() {
	echo "CFLAGS += $*"
}
add_ld() {
	echo "LDLIBS += $*"
}

set_macro() {
	add_cflags "-D'$1=\"$2\"'"
}

add_lib() {
	${pkgconfig} --print-errors "$@"
	add_cflags $(${pkgconfig} --cflags "$@")
	for lib in "$@"; do add_ld $(${pkgconfig} --libs "$lib"); done
}

# save stdout and redirec to config.mk
exec >config.mk

pkgconfig=pkg-config

echo "# Configuration for makefile for nytpu's implementation of ed(1)"
echo "# This file was generated automatically by configure. Don't edit."

for opt in "$@"; do
	case "${opt}" in
		--help | -h)
			exec 1>&2
			echo "Usage: $0 [--OPTION]..."
			echo
			echo "Options and variables: [defaults in brackets]"
			echo "  -h, --help           display this help text"
			echo "  --prefix=DIR         install into DIR [/usr/local]"
			echo "  --bindir=DIR         location to install executables [\$(PREFIX)/bin]"
			echo "  --mandir=DIR         location to install man pages [\$(PREFIX)/share/man]"
			echo "  --cc=COMPILER        command to invoke the C11 compiler [cc]"
			echo "  --cflags=FLAGS       command line options for the C compiler [-Wall -Wextra -pedantic -Wfatal-errors -std=c11 -O3 -Wno-missing-field-initializers -Wno-unused-parameter -Werror=return-type]"
			echo "  --ldflags=FLAGS      command line options for the linker []"
			echo "  --pkgconfig=COMMAND  command to run to configure packages [pkg-config]"
			exit 0
			;;
		--prefix=*) echo "PREFIX = ${opt#*=}" ;;
		--bindir=*) echo "BINDIR = ${opt#*=}" ;;
		--mandir=*) echo "MANDIR = ${opt#*=}" ;;
		--cc=*) echo "CC = ${opt#*=}" ;;
		--cflags=*) echo "CFLAGS = ${opt#*=}" ;;
		--ldflags=*) echo "LDFLAGS = ${opt#*=}" ;;
		--pkg-config=*) pkgconfig=${opt#*=} ;;
		*)
			echo "warning: unsupported option ${opt}" >&2
			exit 1
			;;
	esac
done