aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-04-13 15:14:34 -0400
committerYour Name <you@example.com>2021-04-13 15:14:34 -0400
commit2ab51e507d620c4479e07ca0ec47d22c8c66bc90 (patch)
tree90906ecb043c01034280c767b83a88eb6df6956f /configure
downloaddmtool-2ab51e507d620c4479e07ca0ec47d22c8c66bc90.tar.gz
dmtool-2ab51e507d620c4479e07ca0ec47d22c8c66bc90.tar.bz2
dmtool-2ab51e507d620c4479e07ca0ec47d22c8c66bc90.zip
Initial commit
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure72
1 files changed, 72 insertions, 0 deletions
diff --git a/configure b/configure
new file mode 100755
index 0000000..ead98f8
--- /dev/null
+++ b/configure
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+# These are the project-specific variables
+
+EXECUTABLE="test"
+
+# e.g., foo.so
+LIBRARY=
+
+# List of libs as given to pkg-config
+LIBS=
+
+CFLAGS="-c -Wall -fPIC -std=c++20"
+
+LDFLAGS=
+
+SOURCE_DIR="src"
+
+# Below here shouldn't need editing
+
+SOURCES=`ls $SOURCE_DIR/*.cc | tr '\n' ' '`
+
+PKG_CONFIG_CFLAGS=
+PKG_CONFIG_LIBS=
+if [ -n "$LIBS" ]; then
+ PKG_CONFIG_CFLAGS='`pkg-config $(LIBS) --cflags`'
+ PKG_CONFIG_LIBS='`pkg-config $(LIBS) --libs`'
+fi
+
+ALL="all: \$(SOURCES)"
+
+LIBRULE=
+if [ -n "$LIBRARY" ]; then
+ LIBRULE="
+\$(LIBRARY): \$(OBJECTS)
+ \$(CC) \$(OBJECTS) -shared -o \$@ \$(LDFLAGS) $PKG_CONFIG_LIBS
+"
+ ALL="$ALL \$(LIBRARY)"
+fi
+
+EXERULE=
+if [ -n "$EXECUTABLE" ]; then
+ EXERULE="
+\$(EXECUTABLE): \$(OBJECTS)
+ \$(CC) \$(OBJECTS) -o \$@ \$(LDFLAGS) $PKG_CONFIG_LIBS
+"
+ ALL="$ALL \$(EXECUTABLE)"
+fi
+
+ORULES=$(for cc in `ls $SOURCE_DIR/*.cc`; do g++ -MM -MT `cut -d'.' -f-1 <<< $cc`.o $cc; echo -e "\t"'$(CC) $(CFLAGS) $< -o $@ '"$PKG_CONFIG_CFLAGS\n"; done)
+
+cat << EOF > Makefile
+CC=g++
+LIBS=$LIBS
+CFLAGS=$CFLAGS
+LDFLAGS=$LDFLAGS
+SOURCES=$SOURCES
+OBJECTS=\$(SOURCES:.cc=.o)
+LIBRARY=$LIBRARY
+EXECUTABLE=$EXECUTABLE
+ifeq (\$(PREFIX),)
+ PREFIX := /usr
+endif
+
+$ALL
+$LIBRULE$EXERULE
+
+$ORULES
+
+clean:
+ rm -f $SOURCE_DIR/*.o \$(LIBRARY) \$(EXECUTABLE)
+EOF