diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 56 |
1 files changed, 34 insertions, 22 deletions
@@ -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 |