Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: makefile running order  (Read 840 times)

0 Members and 1 Guest are viewing this topic.

danchoy

  • Newbie
  • *
  • Posts: 1
    • View Profile
makefile running order
« on: November 13, 2022, 03:06:26 am »
Hi, I'm not sure if I'm a weird case.
Here is my case, normally when I run my makefile on Linux I put the variable DEPS under the CFLAGS line without any issues.
I just installed brew and SFML on my macOS then I modified my makefile to set the paths to my local SFML includes and libraries.
Strangely, after I put the path into the makefile and run it, it prompts me with an error saying the SFML/anyfile.hpp file cannot be found.

Finally, I found that if I relocated the variable DEPS below the compile session, it ran it successfully.

Does anyone else have any ideas?

Thanks

CC = g++
lint = cpplint
CFLAGS = --std=c++14 -Wall -Werror -pedantic
SFML_INCLUDE = -I/opt/homebrew/Cellar/sfml/2.5.1_2/include
SFML_LIB = -L/opt/homebrew/Cellar/sfml/2.5.1_2/lib/
BOOST_INCLUDE = -I/opt/homebrew/Cellar/boost/1.80.0/include
BOOST_LIB = -L/opt/homebrew/Cellar/boost/1.80.0/lib/
LIB = -lboost_unit_test_framework -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
LintFlags = --linelength=120 --filter=-build/header_guard,-runtime/references --counting=detailed $$( find . -name \*.hpp -or -name \*.cpp | grep -vE "^\.\/build\/" )

all: sfml-app

%.o: %.cpp $(DEPS)
        $(CC) $(CFLAGS) -c $< $(SFML_INCLUDE) $(BOOST_INCLUDE)
DEPS = header/%.hpp
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: makefile running order
« Reply #1 on: November 16, 2022, 08:20:51 am »
I'd assume if you put it at the bottom then $(DEPS) will simply resolve "nothing", as the variable is only declared further down and thus it runs, but then again I've no idea about the make file syntax.
You don't really need to specify header files when building, the compiler just needs to know where to look for the headers when building all the cpp source files.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything