inukaze
inukaze

Reputation: 439

How i can use sed or another to replace specific string in Makefile

i am back after some users try to put negatives to all my post just with the bad intetion i can't post any question anymore. Well after of that, to the point.

I need help to edit a Makefile, to be more specific the Makefile from "mupen64plus-ui" -> https://github.com/robalni/mupen64plus-ui

The Original Line :

INCPATH       = -I. -isystem /usr/include/SDL2 
-isystem /usr/local/include/mupen64plus
 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtXml -isystem /usr/include/qt5/QtSql -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib64/qt5/mkspecs/linux-g++

I Need :

INCPATH       = -I. -isystem /usr/include/SDL2 
-isystem "$TARGETDIR/include"
 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtXml -isystem /usr/include/qt5/QtSql -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib64/qt5/mkspecs/linux-g++

You notice i just need to change a very specific detail and reaplace with the content i had on a variable on my script, right now that is the line 18 for that Makefile can find the files : m64p_common.h, m64p_types.h, m64p_frontend.h, m64p_config.h

Needed to finish the compilation without errors.

And the another thing i need to understand is the follow lines :

LFLAGS        = -L/usr/lib64 -Wl,-O1
LIBS          = $(SUBLIBS) -lquazip5 -lSDL2 -lmupen64plus -ldl -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Xml -lQt5Sql -lQt5Core -lGL -lpthread

When i try to compile, the output showme can't find "lmupen64plus" i think is searching for the file "libmupen64plus.so.2" in /usr/lib64 , but never can find there because i not compile the emulator and his file for system, just to a very specific prefix on another place.

Well i don't had any idea how i can indicate to the Makefile to search too in "$TARGETDIR/lib" for find that library can compile without errors.

If you want or need check entire script, had a lot of spanish text comment, you can do it visiting -> https://pastebin.com/mxwxHc6P

Well i hope someone can help me with the mupen64plus-ui part of Makefile to finish my macro script to download, compile & install it.

Upvotes: 0

Views: 489

Answers (2)

inukaze
inukaze

Reputation: 439

Thank you very much i use the follow

sed -i "Makefile" -e "s#/usr/local/include/mupen64plus#$TARGETDIR/include#" Makefile

sed -i "Makefile" -e "s#LFLAGS        = -L/usr/lib64 -Wl,-O1#LFLAGS        = -L/usr/lib64 -L$TARGETDIR/lib -Wl,-O1#" Makefile

Thanks solve the edition, but i can't compile yet, still the output is

g++ -L/usr/lib64 -L/media/Compartido/Videojuegos/Linux/Emulador/mupen64plus/64Bits/lib -Wl,-O1 -o mupen64plus main.o cheatparse.o common.o core.o mainwindow.o error.o plugin.o sdl.o settings.o configcontrolcollection.o keyspec.o aboutguidialog.o cheatdialog.o cheattree.o configeditor.o downloaddialog.o gamesettingsdialog.o inputdialog.o logdialog.o pluginconfigdialog.o settingsdialog.o emulation.o emuthread.o glwindow.o vidext.o osal_dynamiclib.o romcollection.o thegamesdbscraper.o gridview.o listview.o tableview.o clickablewidget.o treewidgetitem.o qrc_mupen64plus.o moc_mainwindow.o moc_aboutguidialog.o moc_cheatdialog.o moc_cheattree.o moc_configeditor.o moc_downloaddialog.o moc_gamesettingsdialog.o moc_inputdialog.o moc_logdialog.o moc_pluginconfigdialog.o moc_settingsdialog.o moc_emulation.o moc_emuthread.o moc_romcollection.o moc_thegamesdbscraper.o moc_gridview.o moc_listview.o moc_tableview.o moc_clickablewidget.o   -lquazip5 -lSDL2 -lmupen64plus -ldl -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Xml -lQt5Sql -lQt5Core -lGL -lpthread 
/usr/lib64/gcc/x86_64-slackware-linux/5.5.0/../../../../x86_64-slackware-linux/bin/ld: no se puede encontrar -lmupen64plus
collect2: error: ld devolvió el estado de salida 1
Makefile:420: fallo en las instrucciones para el objetivo 'mupen64plus'
make: *** [mupen64plus] Error 1

well LD can't find -lmupen64plus, but i don't understand what i need to solved it

Upvotes: 0

keithpjolley
keithpjolley

Reputation: 2263

First part's easy. Not sure why you want sed instead of just editing by hand.

sed -i "bak" -e 's#/usr/local/include/mupen64plus#"$TARGETDIR/include"#' Makefile

You are on the track for the second part. Include the search path you want like:

LFLAGS        = -L/usr/lib64 -Wl,-O1

becomes:

LFLAGS        = -L/usr/lib64 -L$TARGETDIR/lib -Wl,-O1

Be sure $TARGETDIR is defined prior to using it in your Makefile. If TARGETDIR has spaces in it then you need to include it quotes.

Upvotes: 1

Related Questions