daniel hoggan
daniel hoggan

Reputation: 1

Is this the right way to include a subdir in a makefile

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@

CFLAGS  = -pipe -O2 -g `freetype-config --cflags` -c -Wall -Wno-multichar `cat @top_srcdir@/madlax.specs` 
CPPFLAGS= $(CFLAGS) -Woverloaded-virtual -Wnon-virtual-dtor

CC      = @CC@
EXE = jpegtranslator
MLXLIBDIR = @top_srcdir@/src/kits/objs

SUBDIR = libjpeg
SRC := $(SUBDIR)/jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jcdiffct.c \
jchuff.c jcinit.c jclhuff.c jclossls.c jclossy.c jcmainct.c jcmarker.c jcmaster.c jcodec.c \
jcomapi.c jcparam.c jcphuff.c jcpred.c jcprepct.c jcsample.c jcscale.c jcshuff.c jctrans.c \
jdapimin.c jdapistd.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jddiffct.c jdhuff.c \
jdinput.c jdlhuff.c jdlossls.c jdlossy.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \
jdpostct.c jdpred.c jdsample.c jdscale.c jdshuff.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \
jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jmemmgr.c jmemnobs.c jquant1.c jquant2.c \
jutils.c

OBJS =  be_jdatadst.o be_jdatasrc.o be_jerror.o JPEGTranslator.o $(SRC)
OBJDIR := objs

include @top_srcdir@/makefile.rules

all :   $(OBJDIR) $(OBJDIR)/$(EXE)

$(OBJDIR):
    mkdir $(OBJDIR) -C $(SUBDIR)

The main part of concern is the $(OBJDIR) -C $(SUBDIR), because I don't really know if I also need the -I$(SUBDIR) or the -L$(SUBDIR), or if I just use -ljpeg

Upvotes: 0

Views: 46

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409422

First of all the -l option (lower-case L) is for linking with a library, and -L is for adding a path to the linkers library-search-path-list.

And yes you need -L if you want to link with a library in a non-standard location using -l.

You can also skip both the -L and -l options, and provide the full path to the library instead.

Upvotes: 0

Related Questions