1

My current makefile worked fine. But since then some files have been moved to a different new 'Common' directory. So what should my makefile look like to build this scenario. Currently (cut down version pasted here):

SERVER_OLIST = file1.o file2.o file3.o $(CRYPT_LIST)

INCLUDES =  
LIBRARIES =  -lpthread -lrt `mysql_config --cflags` `mysql_config --libs`
DEFINES = 
VERSION_DEFINES = -DBUILD_VERSION='"1.3.0"'
COMPILE_OPTIONS = -posix -fexceptions $(DEFINES)
LINK_OPTIONS = -posix

all: loraserver loracmd

loraserver: testbuild
    cp $^ $@

.PHONY: updateBuildTime
updateBuildTime:
    rm -f BuildVersion.o

testbuild: updateBuildTime $(SERVER_OLIST)
    g++ -o $@ $(SERVER_OLIST) $(LINK_OPTIONS) $(LIBRARIES)

and so I tried this with server list changed to be:

SERVER_OLIST = file1.o ../Common/file2.o file3.o $(CRYPT_LIST)

but when it tried to build it said: 'No rule to make target ../Common/file2.o needed by 'testbuild' Rather than rewrite the whole makefile is there a way of specifying different dirs for different files ?

ade
  • 379
  • 1
  • 6
  • 15
  • all the other answers to this questions would require me to totally rewrite the makefile or create other makefiles in other directories from scratch - and I don't to create libraries in these other directories. – ade Jun 25 '14 at 11:57
  • You'll have to provide more details, because this works for me. Are you sure that there's a file `../Common/file2.cpp`? Is that really your entire makefile? – MadScientist Jun 25 '14 at 12:16
  • ok I added a new line called COMMON_OLIST = ../Common/File2.cpp and added this to the testbuild: line with $(notdir $(COMMON_OLIST)) and this worked. However I am unsure about $(CRYPT_LIST). Do i need to add this to the end of COMMON_O_LIST now ? – ade Jun 25 '14 at 12:47

0 Answers0