Skip to content
Advertisement

wondering what this makefile means

So I was browsing repl.it and saw that someone made it possible to run firefox in the repl window. There was a file called Makefile and it had this code in it. I’m wondering what it means and where they are getting Firefox from.

.PHONY: run

run:
    install-pkg python firefox
    python3 launch.py 

Then there is a python file called launch.py

def delete():
  time.sleep(10)
  os.remove("nohup.out")
  print ("Deleted nohup.out.")
thread = threading.Thread(target=delete)
thread.start()
os.system("firefox")

I’m genuinely curious where firefox is coming from and if I can substitute for another app like discord. Aswell as what is makefile Here is a link to the repl where you can hten view the code. https://replit.com/@Jackerin0/Firefox-fixed-originally-made-by-polygott?v=1

Advertisement

Answer

Makefile is a utility for writing and executing series of command-line instructions for things like compiling code, testing code, formatting code, running code, downloading/uploading data, cleaning your directory etc … Basically, it helps automate your dev workflows into simple commands (make run, make test, make clean).

Here’s what it does in this case:

.PHONY: run # explicitly declare the a routine "run" exists, which can be called with `make run`

run: # run routine
    install-pkg python firefox # first, install python and firefox. This will make both firefox and python available as executable binaries that can be launched from the command line
    python3 launch.py # this runs the python script

So when you type make run in terminal, it will run the install-pkg and python3 commands.

Then in the python file:

def delete():
  time.sleep(10) # sleep for 10 seconds
  os.remove("nohup.out") # remove the file named nohup.out
  print ("Deleted nohup.out.")
thread = threading.Thread(target=delete) # create a thread to run the delete function
thread.start() # start the thread
os.system("firefox") # run the executable for firefox (you can replace this with any command from the command line)

The nohup file is created when running a background task. Not sure why it’s being created in this context (maybe because of something specific to firefox or repl), or why you need to delete it.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement