aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-08-09 16:57:53 -0400
committerYour Name <you@example.com>2022-08-09 16:57:53 -0400
commit5937d893da5656be3f486c863ae54e08bbe66579 (patch)
tree15aedaf0753fcf73fe85e90e88a7d0af33036eca /configure
parent947d83c59ea86615e3a81a2ec122d843b5eceee9 (diff)
downloaddmtool-5937d893da5656be3f486c863ae54e08bbe66579.tar.gz
dmtool-5937d893da5656be3f486c863ae54e08bbe66579.tar.bz2
dmtool-5937d893da5656be3f486c863ae54e08bbe66579.zip
Added generic items, worked on features
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure56
1 files changed, 34 insertions, 22 deletions
diff --git a/configure b/configure
index b6488b4..61c60b2 100755
--- a/configure
+++ b/configure
@@ -7,10 +7,12 @@ EXECUTABLE="dmtool"
# e.g., foo.so
LIBRARY=
+TEST=
+
# List of libs as given to pkg-config
LIBS="libconfuse nlohmann_json"
-CFLAGS="-c -Wall -fPIC -std=c++20"
+CXXFLAGS="-Wall -fPIC -std=c++20"
LDFLAGS=
@@ -22,15 +24,15 @@ parsed: parser/scrapeToJson.py parser/utils.py parser/verified.txt
touch parsed/
"
-INSTALL="
-install: \$(EXECUTABLE) parsed
- install -d \$(DESTDIR)\$(PREFIX)/share/dmtool/
- cp -r parsed/* \$(DESTDIR)\$(PREFIX)/share/dmtool/
- install -d \$(DESTDIR)\$(PREFIX)/bin/
- install -m 755 \$(EXECUTABLE) \$(DESTDIR)\$(PREFIX)/bin/
- install -m 644 files/dmtool.bash \$(DESTDIR)`pkg-config --variable=completionsdir bash-completion`/dmtool
- install -m 644 files/dmtool.conf \$(DESTDIR)/etc/dmtool.conf
-"
+INSTALL='
+install: $(EXECUTABLE) parsed
+ install -d $(DESTDIR)$(PREFIX)/share/dmtool/
+ cp -r parsed/* $(DESTDIR)$(PREFIX)/share/dmtool/
+ install -d $(DESTDIR)$(PREFIX)/bin/
+ install -m 755 $(EXECUTABLE) $(DESTDIR)$(PREFIX)/bin/
+ install -m 644 files/dmtool.bash $(DESTDIR)`pkg-config --variable=completionsdir bash-completion`/dmtool
+ install -m 644 files/dmtool.conf $(DESTDIR)/etc/dmtool.conf
+'
# Below here shouldn't need editing
@@ -49,7 +51,7 @@ LIBRULE=
if [ -n "$LIBRARY" ]; then
LIBRULE="
\$(LIBRARY): \$(OBJECTS)
- \$(CC) \$(OBJECTS) -shared -o \$@ \$(LDFLAGS) $PKG_CONFIG_LIBS
+ \$(CXX) \$(OBJECTS) -shared -o \$@ \$(LDFLAGS) \$(LDLIBS)
"
ALL="$ALL \$(LIBRARY)"
fi
@@ -58,32 +60,42 @@ EXERULE=
if [ -n "$EXECUTABLE" ]; then
EXERULE="
\$(EXECUTABLE): \$(OBJECTS)
- \$(CC) \$(OBJECTS) -o \$@ \$(LDFLAGS) $PKG_CONFIG_LIBS
+ \$(CXX) \$(OBJECTS) -o \$@ \$(LDFLAGS) \$(LDLIBS)
"
ALL="$ALL \$(EXECUTABLE)"
fi
-ORULES=$(for cc in `find $SOURCE_DIR | grep .cc$`; do g++ -MM -MT `cut -d'.' -f-1 <<< $cc`.o $cc; echo -e "\t"'$(CC) $(CFLAGS) $< -o $@ '"$PKG_CONFIG_CFLAGS\n"; done)
+TESTRULE=
+if [ -n "$TEST" ]; then
+ TESTRULE="
+\$(TEST): \$(OBJECTS)
+ \$(CXX) \$(OBJECTS) -o \$@ \$(LDFLAGS) \$(LDLIBS) -lcppunit
+
+test: \$(TEST)
+ ./\$(TEST)
+"
+ ALL="$ALL \$(TEST)"
+fi
+
+
+ORULES=$(for cc in `find $SOURCE_DIR | grep .cc$`; do g++ -MM -MT `cut -d'.' -f-1 <<< $cc`.o $cc; done)
cat << EOF > Makefile
-CC=g++
LIBS=$LIBS
-CFLAGS=$CFLAGS
-LDFLAGS=$LDFLAGS
+override CXXFLAGS += $CXXFLAGS $PKG_CONFIG_CFLAGS
+override LDFLAGS += $LDFLAGS $PKG_CONFIG_LIBS
+CC=\$(CXX)
SOURCES=$SOURCES
OBJECTS=\$(SOURCES:.cc=.o)
LIBRARY=$LIBRARY
EXECUTABLE=$EXECUTABLE
-ifeq (\$(PREFIX),)
- PREFIX := /usr
-endif
+PREFIX := /usr
$ALL
-$EXTRAS$INSTALL$LIBRULE$EXERULE
+$EXTRAS$INSTALL$LIBRULE$EXERULE$TESTRULE
$ORULES
clean:
- rm -f \$(LIBRARY) \$(EXECUTABLE)
- find . | grep .o\$ | xargs rm -f
+ \$(RM) \$(LIBRARY) \$(EXECUTABLE) \$(TEST) \$(OBJECTS)
EOF